Skip to content

Commit cd6ddcc

Browse files
hattonclaude
andcommitted
De-duplicate Device/Ebook selectors in rounded-border-ebook theme
Every rule in appearance-theme-rounded-border-ebook.css applied equally to the Ebook* and Device* page sizes but repeated each (often long) selector once per size. Factor the size classes into a single :is() per rule (and :where() for the zero-specificity override rule) so each selector path is written once. :is()/:where() take the specificity of their most specific argument, and the size selectors are all single classes/attributes, so every rule's specificity is unchanged. Raised by John Thomson while reviewing the same code as it appears in PR #7949 (API-for-Conversion). Making the change here on the 6.4 StoryWeaver page-size branch so it flows to master with the rest of that work instead of diverging and conflicting at merge time. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 0577153 commit cd6ddcc

1 file changed

Lines changed: 28 additions & 43 deletions

File tree

src/content/appearanceThemes/appearance-theme-rounded-border-ebook.css

Lines changed: 28 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@
33
/* This theme applies to the eBook page sizes: Device 16x9 (Landscape and Portrait)
44
and the StoryWeaver Ebook sizes (Ebook2x3 Portrait and Ebook7x5 Landscape). */
55

6+
/* Every rule here applies equally to the Ebook* and Device* page sizes. Rather than repeat
7+
each (often long) selector once per size, we factor the size classes into a single :is()
8+
(or :where(), where zero specificity is wanted). :is()/:where() take the specificity of
9+
their most specific argument, so combining same-specificity size classes this way does not
10+
change which rules win. */
11+
612
/* The below statements control the size and color of the marginbox. It holds the text and picture of that page.
713
* The top and left numbers determine the position of the margin box on the page. */
814

9-
[class*="Ebook"].numberedPage:not(.bloom-interactive-page),
10-
[class*="Device"].numberedPage:not(.bloom-interactive-page) {
15+
:is([class*="Ebook"], [class*="Device"]).numberedPage:not(
16+
.bloom-interactive-page
17+
) {
1118
--page-margin-top: 2mm;
1219
--page-margin-bottom: 2mm;
1320
--page-margin-left: 2mm;
@@ -26,17 +33,21 @@
2633
}
2734

2835
/* using "where:" so that the user's custom appearance can override the theme if specified */
29-
.numberedPage:where([class*="Ebook"]:not(.bloom-interactive-page)),
30-
.numberedPage:where([class*="Device"]:not(.bloom-interactive-page)) {
36+
.numberedPage:where(
37+
[class*="Ebook"]:not(.bloom-interactive-page),
38+
[class*="Device"]:not(.bloom-interactive-page)
39+
) {
3140
--topLevel-text-padding: 0.5em;
3241
}
33-
[class*="Ebook"].numberedPage:not(.bloom-interactive-page),
34-
[class*="Device"].numberedPage:not(.bloom-interactive-page) {
42+
:is([class*="Ebook"], [class*="Device"]).numberedPage:not(
43+
.bloom-interactive-page
44+
) {
3545
--pageNumber-extra-height: 0mm !important; /* we put the page number on top of the image so we don't need a margin boost */
3646
--pageNumber-outline-color: white;
3747
}
38-
[class*="Ebook"].numberedPage:not(.bloom-interactive-page)::after,
39-
[class*="Device"].numberedPage:not(.bloom-interactive-page)::after {
48+
:is([class*="Ebook"], [class*="Device"]).numberedPage:not(
49+
.bloom-interactive-page
50+
)::after {
4051
--pageNumber-bottom: var(--page-margin-bottom);
4152
--pageNumber-top: unset;
4253
--pageNumber-font-size: 11pt;
@@ -54,13 +65,7 @@
5465

5566
/* Rules for rounding the corner of images */
5667
/* Picture on left */
57-
.Ebook7x5Landscape.numberedPage
58-
.marginBox
59-
> .vertical-percent
60-
> .position-left
61-
> .split-pane-component-inner
62-
> .bloom-canvas,
63-
.Device16x9Landscape.numberedPage
68+
:is(.Ebook7x5Landscape, .Device16x9Landscape).numberedPage
6469
.marginBox
6570
> .vertical-percent
6671
> .position-left
@@ -70,13 +75,7 @@
7075
var(--marginBox-border-radius); /* left corners */
7176
}
7277
/* Picture on right */
73-
.Ebook7x5Landscape.numberedPage
74-
.marginBox
75-
> .vertical-percent
76-
> .position-right
77-
> .split-pane-component-inner
78-
> .bloom-canvas,
79-
.Device16x9Landscape.numberedPage
78+
:is(.Ebook7x5Landscape, .Device16x9Landscape).numberedPage
8079
.marginBox
8180
> .vertical-percent
8281
> .position-right
@@ -86,13 +85,7 @@
8685
var(--marginBox-border-radius) 0px; /* right corners */
8786
}
8887
/* Picture on top */
89-
.Ebook2x3Portrait.numberedPage
90-
.marginBox
91-
> .horizontal-percent
92-
> .position-top
93-
> .split-pane-component-inner
94-
> .bloom-canvas,
95-
.Device16x9Portrait.numberedPage
88+
:is(.Ebook2x3Portrait, .Device16x9Portrait).numberedPage
9689
.marginBox
9790
> .horizontal-percent
9891
> .position-top
@@ -102,13 +95,7 @@
10295
var(--marginBox-border-radius) 0px 0px; /* top corners */
10396
}
10497
/* Picture on bottom */
105-
.Ebook2x3Portrait.numberedPage
106-
.marginBox
107-
> .horizontal-percent
108-
> .position-bottom
109-
> .split-pane-component-inner
110-
> .bloom-canvas,
111-
.Device16x9Portrait.numberedPage
98+
:is(.Ebook2x3Portrait, .Device16x9Portrait).numberedPage
11299
.marginBox
113100
> .horizontal-percent
114101
> .position-bottom
@@ -118,11 +105,7 @@
118105
var(--marginBox-border-radius); /* bottom corners */
119106
}
120107
/* Picture only */
121-
[class*="Ebook"].numberedPage
122-
.marginBox
123-
> .split-pane-component-inner
124-
> .bloom-canvas,
125-
[class*="Device"].numberedPage
108+
:is([class*="Ebook"], [class*="Device"]).numberedPage
126109
.marginBox
127110
> .split-pane-component-inner
128111
> .bloom-canvas {
@@ -131,8 +114,10 @@
131114

132115
/* End Rules for rounding the corner of images */
133116

134-
.Ebook7x5Landscape.numberedPage.pictureOnRight.pictureOnRight::after,
135-
.Device16x9Landscape.numberedPage.pictureOnRight.pictureOnRight::after {
117+
:is(
118+
.Ebook7x5Landscape,
119+
.Device16x9Landscape
120+
).numberedPage.pictureOnRight.pictureOnRight::after {
136121
--pageNumber-right-margin: var(--page-margin-right);
137122
--pageNumber-left-margin: deliberately-invalid; /* prevents left being set at all. unset does not work. Prevent centering for this layout */
138123
--pageNumber-always-left-margin: deliberately-invalid; /* prevents left being set at all. unset does not work. Prevent centering for this layout */

0 commit comments

Comments
 (0)