Skip to content

Commit f95385b

Browse files
authored
Rollup merge of #105132 - GuillaumeGomez:migrate-summary-toggle-to-var, r=notriddle
Migrate summary toggle filter to CSS variable r? `@notriddle`
2 parents 4c4dec4 + 188f31e commit f95385b

File tree

5 files changed

+33
-8
lines changed

5 files changed

+33
-8
lines changed

src/librustdoc/html/static/css/rustdoc.css

+1
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,7 @@ details.rustdoc-toggle > summary::before {
15161516
display: inline-block;
15171517
vertical-align: middle;
15181518
opacity: .5;
1519+
filter: var(--toggle-filter);
15191520
}
15201521

15211522
details.rustdoc-toggle > summary.hideme > span,

src/librustdoc/html/static/css/themes/ayu.css

+1-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Original by Dempfi (https://github.com/dempfi/ayu)
2121
--right-side-color: grey;
2222
--code-attribute-color: #999;
2323
--toggles-color: #999;
24+
--toggle-filter: invert(100%);
2425
--search-input-focused-border-color: #5c6773; /* Same as `--border-color`. */
2526
--copy-path-button-color: #fff;
2627
--copy-path-img-filter: invert(70%);
@@ -158,10 +159,6 @@ body.source .example-wrap pre.rust a {
158159
background: #333;
159160
}
160161

161-
details.rustdoc-toggle > summary::before {
162-
filter: invert(100%);
163-
}
164-
165162
.module-item .stab,
166163
.import-item .stab {
167164
color: #000;

src/librustdoc/html/static/css/themes/dark.css

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
--right-side-color: grey;
1717
--code-attribute-color: #999;
1818
--toggles-color: #999;
19+
--toggle-filter: invert(100%);
1920
--search-input-focused-border-color: #008dfd;
2021
--copy-path-button-color: #999;
2122
--copy-path-img-filter: invert(50%);
@@ -89,10 +90,6 @@ body.source .example-wrap pre.rust a {
8990
background: #333;
9091
}
9192

92-
details.rustdoc-toggle > summary::before {
93-
filter: invert(100%);
94-
}
95-
9693
#titles > button:not(.selected) {
9794
background-color: #252525;
9895
border-top-color: #252525;

src/librustdoc/html/static/css/themes/light.css

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
--right-side-color: grey;
1717
--code-attribute-color: #999;
1818
--toggles-color: #999;
19+
--toggle-filter: none;
1920
--search-input-focused-border-color: #66afe9;
2021
--copy-path-button-color: #999;
2122
--copy-path-img-filter: invert(50%);

src/test/rustdoc-gui/toggle-docs.goml

+29
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,32 @@ assert-attribute-false: (
4040
click: "#toggle-all-docs"
4141
wait-for-text: ("#toggle-all-docs", "[−]")
4242
assert-attribute: ("details.rustdoc-toggle", {"open": ""}, ALL)
43+
44+
// Checking the toggles style.
45+
show-text: true
46+
define-function: (
47+
"check-color",
48+
(theme, filter),
49+
[
50+
// Setting the theme.
51+
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
52+
// We reload the page so the local storage settings are being used.
53+
("reload"),
54+
55+
("assert-css", ("details.rustdoc-toggle > summary::before", {
56+
"opacity": "0.5",
57+
"filter": |filter|,
58+
}, ALL)),
59+
("move-cursor-to", "details.rustdoc-toggle summary"),
60+
("assert-css", ("details.rustdoc-toggle > summary:hover::before", {
61+
"opacity": "1",
62+
"filter": |filter|,
63+
})),
64+
// moving the cursor somewhere else to not mess with next function calls.
65+
("move-cursor-to", ".search-input"),
66+
]
67+
)
68+
69+
call-function: ("check-color", {"theme": "ayu", "filter": "invert(1)"})
70+
call-function: ("check-color", {"theme": "dark", "filter": "invert(1)"})
71+
call-function: ("check-color", {"theme": "light", "filter": "none"})

0 commit comments

Comments
 (0)