Skip to content

Commit d41a14f

Browse files
authored
Rollup merge of #107152 - GuillaumeGomez:migrate-to-css-var, r=notriddle
Migrate scraped-examples top and bottom "borders" to CSS variables r? `@notriddle`
2 parents d779a59 + 372ad13 commit d41a14f

File tree

5 files changed

+48
-21
lines changed

5 files changed

+48
-21
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -1907,9 +1907,15 @@ in storage.js
19071907
}
19081908
.scraped-example:not(.expanded) .code-wrapper:before {
19091909
top: 0;
1910+
background: linear-gradient(to bottom,
1911+
var(--scrape-example-code-wrapper-background-start),
1912+
var(--scrape-example-code-wrapper-background-end));
19101913
}
19111914
.scraped-example:not(.expanded) .code-wrapper:after {
19121915
bottom: 0;
1916+
background: linear-gradient(to top,
1917+
var(--scrape-example-code-wrapper-background-start),
1918+
var(--scrape-example-code-wrapper-background-end));
19131919
}
19141920

19151921
.scraped-example .code-wrapper .example-wrap {

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

+2-7
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ Original by Dempfi (https://github.com/dempfi/ayu)
9797
--scrape-example-help-color: #eee;
9898
--scrape-example-help-hover-border-color: #fff;
9999
--scrape-example-help-hover-color: #fff;
100+
--scrape-example-code-wrapper-background-start: rgba(15, 20, 25, 1);
101+
--scrape-example-code-wrapper-background-end: rgba(15, 20, 25, 0);
100102
}
101103

102104
h1, h2, h3, h4 {
@@ -203,10 +205,3 @@ above the `@media (max-width: 700px)` rules due to a bug in the css checker */
203205
#source-sidebar div.files > a.selected {
204206
color: #ffb44c;
205207
}
206-
207-
.scraped-example:not(.expanded) .code-wrapper::before {
208-
background: linear-gradient(to bottom, rgba(15, 20, 25, 1), rgba(15, 20, 25, 0));
209-
}
210-
.scraped-example:not(.expanded) .code-wrapper::after {
211-
background: linear-gradient(to top, rgba(15, 20, 25, 1), rgba(15, 20, 25, 0));
212-
}

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

+2-7
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@
9292
--scrape-example-help-color: #eee;
9393
--scrape-example-help-hover-border-color: #fff;
9494
--scrape-example-help-hover-color: #fff;
95+
--scrape-example-code-wrapper-background-start: rgba(53, 53, 53, 1);
96+
--scrape-example-code-wrapper-background-end: rgba(53, 53, 53, 0);
9597
}
9698

9799
#search-tabs > button:not(.selected) {
@@ -103,10 +105,3 @@
103105
border-top-color: #0089ff;
104106
background-color: #353535;
105107
}
106-
107-
.scraped-example:not(.expanded) .code-wrapper::before {
108-
background: linear-gradient(to bottom, rgba(53, 53, 53, 1), rgba(53, 53, 53, 0));
109-
}
110-
.scraped-example:not(.expanded) .code-wrapper::after {
111-
background: linear-gradient(to top, rgba(53, 53, 53, 1), rgba(53, 53, 53, 0));
112-
}

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

+2-7
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@
8989
--scrape-example-help-color: #333;
9090
--scrape-example-help-hover-border-color: #000;
9191
--scrape-example-help-hover-color: #000;
92+
--scrape-example-code-wrapper-background-start: rgba(255, 255, 255, 1);
93+
--scrape-example-code-wrapper-background-end: rgba(255, 255, 255, 0);
9294
}
9395

9496
#search-tabs > button:not(.selected) {
@@ -100,10 +102,3 @@
100102
background-color: #ffffff;
101103
border-top-color: #0089ff;
102104
}
103-
104-
.scraped-example:not(.expanded) .code-wrapper::before {
105-
background: linear-gradient(to bottom, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
106-
}
107-
.scraped-example:not(.expanded) .code-wrapper::after {
108-
background: linear-gradient(to top, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
109-
}

tests/rustdoc-gui/scrape-examples-color.goml

+36
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,39 @@ call-function: ("check-colors", {
5858
"help_hover_border": "rgb(0, 0, 0)",
5959
"help_hover_color": "rgb(0, 0, 0)",
6060
})
61+
62+
// Now testing the top and bottom background in case there is only one scraped examples.
63+
goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test.html"
64+
65+
define-function: (
66+
"check-background",
67+
(theme, background_color_start, background_color_end),
68+
block {
69+
local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", }
70+
reload:
71+
assert-css: (".scraped-example:not(.expanded) .code-wrapper::before", {
72+
"background-image": "linear-gradient(" + |background_color_start| + ", " +
73+
|background_color_end| + ")",
74+
})
75+
assert-css: (".scraped-example:not(.expanded) .code-wrapper::after", {
76+
"background-image": "linear-gradient(to top, " + |background_color_start| + ", " +
77+
|background_color_end| + ")",
78+
})
79+
},
80+
)
81+
82+
call-function: ("check-background", {
83+
"theme": "ayu",
84+
"background_color_start": "rgb(15, 20, 25)",
85+
"background_color_end": "rgba(15, 20, 25, 0)",
86+
})
87+
call-function: ("check-background", {
88+
"theme": "dark",
89+
"background_color_start": "rgb(53, 53, 53)",
90+
"background_color_end": "rgba(53, 53, 53, 0)",
91+
})
92+
call-function: ("check-background", {
93+
"theme": "light",
94+
"background_color_start": "rgb(255, 255, 255)",
95+
"background_color_end": "rgba(255, 255, 255, 0)",
96+
})

0 commit comments

Comments
 (0)