Skip to content

Commit 0840044

Browse files
authored
Rollup merge of rust-lang#101934 - GuillaumeGomez:theme-links-cleanup, r=notriddle
Continue migration of CSS themes Now that rust-lang#101898 has been merged, we can move forward. This PR moves more CSS theme rules as CSS variables. I also added a GUI test to prevent regressions. Part of rust-lang#98460. r? `@notriddle`
2 parents 16823e2 + 5d449a0 commit 0840044

File tree

5 files changed

+152
-78
lines changed

5 files changed

+152
-78
lines changed

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

+43
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,49 @@ pre.rust a,
240240
color: var(--main-color);
241241
}
242242

243+
.content span.enum, .content a.enum,
244+
.content span.struct, .content a.struct,
245+
.content span.union, .content a.union,
246+
.content span.primitive, .content a.primitive,
247+
.content span.type, .content a.type,
248+
.content span.foreigntype, .content a.foreigntype {
249+
color: var(--type-link-color);
250+
}
251+
252+
.content span.trait, .content a.trait,
253+
.content span.traitalias, .content a.traitalias {
254+
color: var(--trait-link-color);
255+
}
256+
257+
.content span.associatedtype, .content a.associatedtype,
258+
.content span.constant, .content a.constant,
259+
.content span.static, .content a.static {
260+
color: var(--assoc-item-link-color);
261+
}
262+
263+
.content span.fn, .content a.fn,
264+
.content .fnname {
265+
color: var(--function-link-color);
266+
}
267+
268+
.content span.attr, .content a.attr,
269+
.content span.derive, .content a.derive,
270+
.content span.macro, .content a.macro {
271+
color: var(--macro-link-color);
272+
}
273+
274+
.content span.mod, .content a.mod, .block a.current.mod {
275+
color: var(--mod-link-color);
276+
}
277+
278+
.content span.keyword, .content a.keyword {
279+
color: var(--keyword-link-color);
280+
}
281+
282+
a {
283+
color: var(--link-color);
284+
}
285+
243286
ol, ul {
244287
padding-left: 24px;
245288
}

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

+8-32
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ Original by Dempfi (https://github.com/dempfi/ayu)
2727
--codeblock-error-color: rgba(255, 0, 0, .5);
2828
--codeblock-ignore-hover-color: rgb(255, 142, 0);
2929
--codeblock-ignore-color: rgba(255, 142, 0, .6);
30+
--type-link-color: #ffa0a5;
31+
--trait-link-color: #39afd7;
32+
--assoc-item-link-color: #39afd7;
33+
--function-link-color: #fdd687;
34+
--macro-link-color: #a37acc;
35+
--keyword-link-color: #39afd7;
36+
--mod-link-color: #39afd7;
37+
--link-color: #39afd7;
3038
}
3139

3240
.slider {
@@ -111,44 +119,12 @@ pre, .rustdoc.source .example-wrap {
111119

112120
.content .item-info::before { color: #ccc; }
113121

114-
.content span.foreigntype, .content a.foreigntype { color: #ffa0a5; }
115-
.content span.union, .content a.union { color: #ffa0a5; }
116-
.content span.constant, .content a.constant,
117-
.content span.static, .content a.static { color: #39AFD7; }
118-
.content span.primitive, .content a.primitive { color: #ffa0a5; }
119-
.content span.traitalias, .content a.traitalias { color: #39AFD7; }
120-
.content span.keyword, .content a.keyword { color: #39AFD7; }
121-
.content span.mod, .content a.mod {
122-
color: #39AFD7;
123-
}
124-
.content span.struct, .content a.struct {
125-
color: #ffa0a5;
126-
}
127-
.content span.enum, .content a.enum {
128-
color: #ffa0a5;
129-
}
130-
.content span.trait, .content a.trait {
131-
color: #39AFD7;
132-
}
133-
.content span.type, .content a.type { color: #39AFD7; }
134-
.content span.associatedtype, .content a.associatedtype { color: #39AFD7; }
135-
.content span.fn, .content a.fn,
136-
.content .fnname { color: #fdd687; }
137-
.content span.attr, .content a.attr, .content span.derive,
138-
.content a.derive, .content span.macro, .content a.macro {
139-
color: #a37acc;
140-
}
141-
142122
.sidebar a { color: #53b1db; }
143123
.sidebar a.current.type { color: #53b1db; }
144124

145125
pre.rust .comment { color: #788797; }
146126
pre.rust .doccomment { color: #a1ac88; }
147127

148-
a {
149-
color: #39AFD7;
150-
}
151-
152128
.sidebar h2 a,
153129
.sidebar h3 a {
154130
color: white;

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

+8-23
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222
--codeblock-error-color: rgba(255, 0, 0, .5);
2323
--codeblock-ignore-hover-color: rgb(255, 142, 0);
2424
--codeblock-ignore-color: rgba(255, 142, 0, .6);
25+
--type-link-color: #2dbfb8;
26+
--trait-link-color: #b78cf2;
27+
--assoc-item-link-color: #d2991d;
28+
--function-link-color: #2bab63;
29+
--macro-link-color: #09bd00;
30+
--keyword-link-color: #d2991d;
31+
--mod-link-color: #d2991d;
32+
--link-color: #d2991d;
2533
}
2634

2735
.slider {
@@ -83,25 +91,6 @@ a.result-keyword:focus { background-color: #884719; }
8391

8492
.content .item-info::before { color: #ccc; }
8593

86-
.content span.enum, .content a.enum { color: #2dbfb8; }
87-
.content span.struct, .content a.struct { color: #2dbfb8; }
88-
.content span.type, .content a.type { color: #2dbfb8; }
89-
.content span.associatedtype, .content a.associatedtype { color: #D2991D; }
90-
.content span.foreigntype, .content a.foreigntype { color: #2dbfb8; }
91-
.content span.attr, .content a.attr,
92-
.content span.derive, .content a.derive,
93-
.content span.macro, .content a.macro { color: #09bd00; }
94-
.content span.union, .content a.union { color: #2dbfb8; }
95-
.content span.constant, .content a.constant,
96-
.content span.static, .content a.static { color: #D2991D; }
97-
.content span.primitive, .content a.primitive { color: #2dbfb8; }
98-
.content span.mod, .content a.mod { color: #D2991D; }
99-
.content span.trait, .content a.trait { color: #b78cf2; }
100-
.content span.traitalias, .content a.traitalias { color: #b78cf2; }
101-
.content span.fn, .content a.fn,
102-
.content .fnname { color: #2BAB63; }
103-
.content span.keyword, .content a.keyword { color: #D2991D; }
104-
10594
.sidebar a { color: #fdbf35; }
10695
.sidebar a.current.enum { color: #12ece2; }
10796
.sidebar a.current.struct { color: #12ece2; }
@@ -122,10 +111,6 @@ a.result-keyword:focus { background-color: #884719; }
122111
pre.rust .comment { color: #8d8d8b; }
123112
pre.rust .doccomment { color: #8ca375; }
124113

125-
a {
126-
color: #D2991D;
127-
}
128-
129114
body.source .example-wrap pre.rust a {
130115
background: #333;
131116
}

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

+8-23
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222
--codeblock-error-color: rgba(255, 0, 0, .5);
2323
--codeblock-ignore-hover-color: rgb(255, 142, 0);
2424
--codeblock-ignore-color: rgba(255, 142, 0, .6);
25+
--type-link-color: #ad378a;
26+
--trait-link-color: #6e4fc9;
27+
--assoc-item-link-color: #3873ad;
28+
--function-link-color: #ad7c37;
29+
--macro-link-color: #068000;
30+
--keyword-link-color: #3873ad;
31+
--mod-link-color: #3873ad;
32+
--link-color: #3873ad;
2533
}
2634

2735
.slider {
@@ -82,25 +90,6 @@ a.result-keyword:focus { background-color: #afc6e4; }
8290

8391
.content .item-info::before { color: #ccc; }
8492

85-
.content span.enum, .content a.enum { color: #AD378A; }
86-
.content span.struct, .content a.struct { color: #AD378A; }
87-
.content span.type, .content a.type { color: #AD378A; }
88-
.content span.associatedtype, .content a.associatedtype { color: #3873AD; }
89-
.content span.foreigntype, .content a.foreigntype { color: #3873AD; }
90-
.content span.attr, .content a.attr,
91-
.content span.derive, .content a.derive,
92-
.content span.macro, .content a.macro { color: #068000; }
93-
.content span.union, .content a.union { color: #AD378A; }
94-
.content span.constant, .content a.constant,
95-
.content span.static, .content a.static { color: #3873AD; }
96-
.content span.primitive, .content a.primitive { color: #AD378A; }
97-
.content span.mod, .content a.mod { color: #3873AD; }
98-
.content span.trait, .content a.trait { color: #6E4FC9; }
99-
.content span.traitalias, .content a.traitalias { color: #5137AD; }
100-
.content span.fn, .content a.fn,
101-
.content .fnname { color: #AD7C37; }
102-
.content span.keyword, .content a.keyword { color: #3873AD; }
103-
10493
.sidebar a { color: #356da4; }
10594
.sidebar a.current.enum { color: #a63283; }
10695
.sidebar a.current.struct { color: #a63283; }
@@ -118,10 +107,6 @@ a.result-keyword:focus { background-color: #afc6e4; }
118107
.sidebar a.current.fn { color: #a67736; }
119108
.sidebar a.current.keyword { color: #356da4; }
120109

121-
a {
122-
color: #3873AD;
123-
}
124-
125110
body.source .example-wrap pre.rust a {
126111
background: #eee;
127112
}

src/test/rustdoc-gui/links-color.goml

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// This test checks links colors.
2+
goto: file://|DOC_PATH|/test_docs/index.html
3+
4+
// This is needed so that the text color is computed.
5+
show-text: true
6+
7+
// Ayu theme
8+
local-storage: {
9+
"rustdoc-theme": "ayu",
10+
"rustdoc-use-system-theme": "false",
11+
}
12+
reload:
13+
14+
assert-css: (".item-table .mod", {"color": "rgb(57, 175, 215)"}, ALL)
15+
assert-css: (".item-table .macro", {"color": "rgb(163, 122, 204)"}, ALL)
16+
assert-css: (".item-table .struct", {"color": "rgb(255, 160, 165)"}, ALL)
17+
assert-css: (".item-table .enum", {"color": "rgb(255, 160, 165)"}, ALL)
18+
assert-css: (".item-table .trait", {"color": "rgb(57, 175, 215)"}, ALL)
19+
assert-css: (".item-table .fn", {"color": "rgb(253, 214, 135)"}, ALL)
20+
assert-css: (".item-table .type", {"color": "rgb(255, 160, 165)"}, ALL)
21+
assert-css: (".item-table .union", {"color": "rgb(255, 160, 165)"}, ALL)
22+
assert-css: (".item-table .keyword", {"color": "rgb(57, 175, 215)"}, ALL)
23+
24+
assert-css: (
25+
".sidebar-elems a:not(.current)",
26+
{"color": "rgb(83, 177, 219)", "background-color": "rgba(0, 0, 0, 0)", "font-weight": "400"},
27+
ALL,
28+
)
29+
assert-css: (
30+
".sidebar-elems a.current",
31+
{"color": "rgb(255, 180, 76)", "background-color": "rgba(0, 0, 0, 0)", "font-weight": "500"},
32+
ALL,
33+
)
34+
35+
36+
// Dark theme
37+
local-storage: {"rustdoc-theme": "dark"}
38+
reload:
39+
40+
assert-css: (".item-table .mod", {"color": "rgb(210, 153, 29)"}, ALL)
41+
assert-css: (".item-table .macro", {"color": "rgb(9, 189, 0)"}, ALL)
42+
assert-css: (".item-table .struct", {"color": "rgb(45, 191, 184)"}, ALL)
43+
assert-css: (".item-table .enum", {"color": "rgb(45, 191, 184)"}, ALL)
44+
assert-css: (".item-table .trait", {"color": "rgb(183, 140, 242)"}, ALL)
45+
assert-css: (".item-table .fn", {"color": "rgb(43, 171, 99)"}, ALL)
46+
assert-css: (".item-table .type", {"color": "rgb(45, 191, 184)"}, ALL)
47+
assert-css: (".item-table .union", {"color": "rgb(45, 191, 184)"}, ALL)
48+
assert-css: (".item-table .keyword", {"color": "rgb(210, 153, 29)"}, ALL)
49+
50+
assert-css: (
51+
".sidebar-elems a:not(.current)",
52+
{"color": "rgb(253, 191, 53)", "background-color": "rgba(0, 0, 0, 0)", "font-weight": "400"},
53+
ALL,
54+
)
55+
assert-css: (
56+
".sidebar-elems a.current",
57+
{"color": "rgb(253, 191, 53)", "background-color": "rgb(68, 68, 68)", "font-weight": "500"},
58+
ALL,
59+
)
60+
61+
62+
// Light theme
63+
local-storage: {"rustdoc-theme": "light"}
64+
reload:
65+
66+
assert-css: (".item-table .mod", {"color": "rgb(56, 115, 173)"}, ALL)
67+
assert-css: (".item-table .macro", {"color": "rgb(6, 128, 0)"}, ALL)
68+
assert-css: (".item-table .struct", {"color": "rgb(173, 55, 138)"}, ALL)
69+
assert-css: (".item-table .enum", {"color": "rgb(173, 55, 138)"}, ALL)
70+
assert-css: (".item-table .trait", {"color": "rgb(110, 79, 201)"}, ALL)
71+
assert-css: (".item-table .fn", {"color": "rgb(173, 124, 55)"}, ALL)
72+
assert-css: (".item-table .type", {"color": "rgb(173, 55, 138)"}, ALL)
73+
assert-css: (".item-table .union", {"color": "rgb(173, 55, 138)"}, ALL)
74+
assert-css: (".item-table .keyword", {"color": "rgb(56, 115, 173)"}, ALL)
75+
76+
assert-css: (
77+
".sidebar-elems a:not(.current)",
78+
{"color": "rgb(53, 109, 164)", "background-color": "rgba(0, 0, 0, 0)", "font-weight": "400"},
79+
ALL,
80+
)
81+
assert-css: (
82+
".sidebar-elems a.current",
83+
{"color": "rgb(53, 109, 164)", "background-color": "rgb(255, 255, 255)", "font-weight": "500"},
84+
ALL,
85+
)

0 commit comments

Comments
 (0)