diff --git a/app/src/components/ThemeSamplePage.js b/app/src/components/ThemeSamplePage.js index 2cb49950..46a48592 100644 --- a/app/src/components/ThemeSamplePage.js +++ b/app/src/components/ThemeSamplePage.js @@ -378,9 +378,10 @@ export function ThemeSamplePage() {

- The disc masks the rule behind it and is painted with --panel, 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 --panel, 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.

diff --git a/app/src/components/ui/ui-layout.cy.js b/app/src/components/ui/ui-layout.cy.js index 729a887c..54299f63 100644 --- a/app/src/components/ui/ui-layout.cy.js +++ b/app/src/components/ui/ui-layout.cy.js @@ -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); }); }); }); diff --git a/app/src/components/ui/ui.css b/app/src/components/ui/ui.css index 656ee173..22bf8985 100644 --- a/app/src/components/ui/ui.css +++ b/app/src/components/ui/ui.css @@ -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); }