ui: the Or breaks the rule, it is not enclosed by one

Two fixes to the divider from review.

No disc.  The rule runs down, stops at the word, and picks up below it -- the
break made by painting the word with `--panel` rather than by drawing a shape
around it.  So the label carries no border and no radius, only enough padding to
open the gap.

And a stray 1px line down the word's own left edge.  The label is a third child
of the grid -- absolutely positioned, so it takes no column -- but `> * + *`
still matched it and gave it a border of its own, beside the one running behind
it.  Both the divider rules exclude it now.

The test that was meant to catch that read `borderTopWidth` and nothing else, so
a rule on the left survived an assertion named "no outline around the word".  It
reads all four sides, and fails on the Left edge against the old selector.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Roland 2026-08-05 17:45:43 -06:00
parent aa44bcd1c1
commit 872fd5f92c
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
3 changed files with 47 additions and 20 deletions

View file

@ -378,9 +378,10 @@ export function ThemeSamplePage() {
</div>
</Panel>
<p style={{fontSize: '0.75rem', color: 'var(--muted)'}}>
The disc masks the rule behind it and is painted with <code>--panel</code>, so it
only disappears into the surface on a Panel — on any other ground it reads as a
chip. Below the tablet breakpoint the halves stack and the rule turns horizontal.
The rule runs down, stops at the word, and picks up below it. That break is made
by painting the word with <code>--panel</code>, so it only disappears into the
surface on a Panel — on any other ground the paint reads as a chip. Below the
tablet breakpoint the halves stack and the rule turns horizontal.
</p>
</Section>

View file

@ -525,15 +525,35 @@ describe('two choices of equal weight are split down the middle', () => {
});
});
it('masks the rule behind its label rather than letting it strike through', () => {
// An "Or" with a line through it is the thing the disc exists to prevent, so it has to be
// painted -- and with the Panel's own color, or it reads as a chip laid on the surface.
it('breaks the rule at the word rather than letting it strike through', () => {
/*
* The rule runs down, stops at the word, and picks up below it. The break is made by
* painting the word with the Panel's own color -- so the paint is load-bearing, and it has
* to be that color or the word reads as a chip laid on the surface.
*
* The word carries no shape of its own: it is not a disc, and a border or a radius would
* enclose it instead of breaking the line.
*/
mountSplit();
cy.get('.wrolpi-or-label').should(($label) => {
const styles = getComputedStyle($label[0]);
const panel = getComputedStyle(Cypress.$('.wrolpi-panel')[0]).backgroundColor;
expect(getComputedStyle($label[0]).backgroundColor, 'painted with the panel')
.to.equal(panel);
expect(styles.backgroundColor, 'painted with the panel').to.equal(panel);
/*
* All four sides, not just the top. Reading one side was how a stray rule down the
* word's left edge survived this test: the label is a third child of the grid, so the
* `> * + *` that draws the divider matched it too and gave it a border of its own.
*/
['Top', 'Right', 'Bottom', 'Left'].forEach(side => expect(
parseFloat(styles[`border${side}Width`]), `no rule on the word's ${side} edge`,
).to.equal(0));
expect(parseFloat(styles.borderRadius), 'and no disc').to.equal(0);
// Padded enough to actually open a gap, rather than sitting on the line unbroken.
expect(parseFloat(styles.paddingTop), 'padded enough to break the rule')
.to.be.greaterThan(0);
});
});
});

View file

@ -1404,40 +1404,46 @@ html[data-theme="amber"] .wrolpi-progress-fill {
padding: 1.5rem 1rem;
}
.wrolpi-or-split > * + * {
/*
* `:not(.wrolpi-or-label)` on both sides. The label is a third child of the grid -- absolutely
* positioned, so it takes no column, but `> * + *` still matches it and gave the word a 1px rule
* down its own left edge, a stray line beside "OR" rather than the one running behind it.
*/
.wrolpi-or-split > *:not(.wrolpi-or-label) + *:not(.wrolpi-or-label) {
border-left: 1px solid var(--border);
}
/*
* The "Or" sits ON the rule, in a disc that masks the line behind it. `--panel` because that is
* what the surrounding Panel is painted with; on any other surface the disc would show as a chip.
* The "Or" sits ON the rule, breaking it rather than being enclosed by it -- the rule runs down,
* stops at the word, and picks up below it.
*
* The break is made by painting the word with `--panel`, which is what the surrounding Panel is
* painted with, so the line simply ends where the word begins. That means the label carries no
* shape of its own: no border and no radius, only enough padding to open the gap. On any surface
* that is not a Panel the paint would show as a chip, which is the one thing to know before
* reusing this.
*/
.wrolpi-or-label {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
align-items: center;
justify-content: center;
width: 2rem;
height: 2rem;
border-radius: 50%;
/* Vertical padding opens the gap in the rule; horizontal keeps the halves off the word. */
padding: 0.375rem 0.5rem;
background: var(--panel);
border: 1px solid var(--border);
color: var(--muted);
font-size: 0.8125rem;
font-weight: 600;
text-transform: uppercase;
}
/* Stacked on a phone: the rule turns horizontal, and the disc rides it. */
/* Stacked on a phone: the rule turns horizontal, and the word breaks it there instead. */
@media (max-width: 699px) {
.wrolpi-or-split {
grid-template-columns: 1fr;
}
.wrolpi-or-split > * + * {
.wrolpi-or-split > *:not(.wrolpi-or-label) + *:not(.wrolpi-or-label) {
border-left: none;
border-top: 1px solid var(--border);
}