Skip to content

Commit 4e59188

Browse files
authored
Rollup merge of #104532 - GuillaumeGomez:migrate-tooltip-css, r=notriddle
Migrate tooltip style to CSS variables
2 parents 5829287 + 11d0c97 commit 4e59188

File tree

5 files changed

+87
-35
lines changed

5 files changed

+87
-35
lines changed

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,8 @@ pre.rust .doccomment {
11591159
width: max-content;
11601160
top: -2px;
11611161
z-index: 1;
1162+
background-color: var(--tooltip-background-color);
1163+
color: var(--tooltip-color);
11621164
}
11631165

11641166
.example-wrap .tooltip::before {
@@ -1167,10 +1169,10 @@ pre.rust .doccomment {
11671169
top: 50%;
11681170
left: 16px;
11691171
margin-top: -5px;
1170-
border-width: 5px;
1171-
border-style: solid;
11721172
display: none;
11731173
z-index: 1;
1174+
border: 5px solid transparent;
1175+
border-right-color: var(--tooltip-background-color);
11741176
}
11751177

11761178
.example-wrap.ignore .tooltip::after {

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

+2-9
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ Original by Dempfi (https://github.com/dempfi/ayu)
6565
--test-arrow-hover-background-color: rgba(57, 175, 215, 0.368);
6666
--target-background-color: rgba(255, 236, 164, 0.06);
6767
--target-border-color: rgba(255, 180, 76, 0.85);
68+
--tooltip-background-color: #314559;
69+
--tooltip-color: #c5c5c5;
6870
--rust-logo-filter: drop-shadow(1px 0 0px #fff)
6971
drop-shadow(0 1px 0 #fff)
7072
drop-shadow(-1px 0 0 #fff)
@@ -160,15 +162,6 @@ details.rustdoc-toggle > summary::before {
160162
color: #788797;
161163
}
162164

163-
.tooltip::after {
164-
background-color: #314559;
165-
color: #c5c5c5;
166-
}
167-
168-
.tooltip::before {
169-
border-color: transparent #314559 transparent transparent;
170-
}
171-
172165
#titles > button.selected {
173166
background-color: #141920 !important;
174167
border-bottom: 1px solid #ffb44c !important;

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

+2-10
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
--test-arrow-hover-background-color: #4e8bca;
6161
--target-background-color: #494a3d;
6262
--target-border-color: #bb7410;
63+
--tooltip-background-color: #000;
64+
--tooltip-color: #fff;
6365
--rust-logo-filter: drop-shadow(1px 0 0px #fff)
6466
drop-shadow(0 1px 0 #fff)
6567
drop-shadow(-1px 0 0 #fff)
@@ -82,16 +84,6 @@ details.rustdoc-toggle > summary::before {
8284
filter: invert(100%);
8385
}
8486

85-
.tooltip::after {
86-
background-color: #000;
87-
color: #fff;
88-
border-color: #000;
89-
}
90-
91-
.tooltip::before {
92-
border-color: transparent black transparent transparent;
93-
}
94-
9587
#titles > button:not(.selected) {
9688
background-color: #252525;
9789
border-top-color: #252525;

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

+3-10
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@
5858
--test-arrow-background-color: rgba(78, 139, 202, 0.2);
5959
--test-arrow-hover-color: #f5f5f5;
6060
--test-arrow-hover-background-color: #4e8bca;
61-
--target-background-color: #fdFfd3;
61+
--target-background-color: #fdffd3;
6262
--target-border-color: #ad7c37;
63+
--tooltip-background-color: #fdffd3;
64+
--tooltip-color: #fff;
6365
--rust-logo-filter: initial;
6466
/* match border-color; uses https://codepen.io/sosuke/pen/Pjoqqp */
6567
--crate-search-div-filter: invert(100%) sepia(0%) saturate(4223%) hue-rotate(289deg)
@@ -75,15 +77,6 @@ body.source .example-wrap pre.rust a {
7577
background: #eee;
7678
}
7779

78-
.tooltip::after {
79-
background-color: #000;
80-
color: #fff;
81-
}
82-
83-
.tooltip::before {
84-
border-color: transparent black transparent transparent;
85-
}
86-
8780
#titles > button:not(.selected) {
8881
background-color: #e6e6e6;
8982
border-top-color: #e6e6e6;

src/test/rustdoc-gui/codeblock-tooltip.goml

+76-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ show-text: true
44

55
define-function: (
66
"check-colors",
7-
(theme),
7+
(theme, background, color, border),
88
[
99
// Setting the theme.
1010
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
@@ -30,6 +30,25 @@ define-function: (
3030
".docblock .example-wrap.compile_fail",
3131
{"border-left": "2px solid rgb(255, 0, 0)"},
3232
)),
33+
("assert-css", (
34+
".docblock .example-wrap.compile_fail .tooltip::after",
35+
{
36+
"content": '"This example deliberately fails to compile"',
37+
"text-align": "center",
38+
"padding": "5px 3px 3px",
39+
"background-color": |background|,
40+
"color": |color|,
41+
"border": "1px solid " + |border|,
42+
},
43+
)),
44+
("assert-css", (
45+
".docblock .example-wrap.compile_fail .tooltip::before",
46+
{
47+
"border-width": "5px",
48+
"border-style": "solid",
49+
"border-color": "rgba(0, 0, 0, 0) " + |background| + " rgba(0, 0, 0, 0) rgba(0, 0, 0, 0)",
50+
},
51+
)),
3352

3453
// should_panic block
3554
("assert-css", (
@@ -51,6 +70,25 @@ define-function: (
5170
".docblock .example-wrap.should_panic",
5271
{"border-left": "2px solid rgb(255, 0, 0)"},
5372
)),
73+
("assert-css", (
74+
".docblock .example-wrap.should_panic .tooltip::after",
75+
{
76+
"content": '"This example panics"',
77+
"text-align": "center",
78+
"padding": "5px 3px 3px",
79+
"background-color": |background|,
80+
"color": |color|,
81+
"border": "1px solid " + |border|,
82+
},
83+
)),
84+
("assert-css", (
85+
".docblock .example-wrap.should_panic .tooltip::before",
86+
{
87+
"border-width": "5px",
88+
"border-style": "solid",
89+
"border-color": "rgba(0, 0, 0, 0) " + |background| + " rgba(0, 0, 0, 0) rgba(0, 0, 0, 0)",
90+
},
91+
)),
5492

5593
// ignore block
5694
("assert-css", (
@@ -72,9 +110,43 @@ define-function: (
72110
".docblock .example-wrap.ignore",
73111
{"border-left": "2px solid rgb(255, 142, 0)"},
74112
)),
113+
("assert-css", (
114+
".docblock .example-wrap.ignore .tooltip::after",
115+
{
116+
"content": '"This example is not tested"',
117+
"text-align": "center",
118+
"padding": "5px 3px 3px",
119+
"background-color": |background|,
120+
"color": |color|,
121+
"border": "1px solid " + |border|,
122+
},
123+
)),
124+
("assert-css", (
125+
".docblock .example-wrap.ignore .tooltip::before",
126+
{
127+
"border-width": "5px",
128+
"border-style": "solid",
129+
"border-color": "rgba(0, 0, 0, 0) " + |background| + " rgba(0, 0, 0, 0) rgba(0, 0, 0, 0)",
130+
},
131+
)),
75132
],
76133
)
77134

78-
call-function: ("check-colors", ("ayu"))
79-
call-function: ("check-colors", ("dark"))
80-
call-function: ("check-colors", ("light"))
135+
call-function: ("check-colors", {
136+
"theme": "ayu",
137+
"background": "rgb(49, 69, 89)",
138+
"color": "rgb(197, 197, 197)",
139+
"border": "rgb(92, 103, 115)",
140+
})
141+
call-function: ("check-colors", {
142+
"theme": "dark",
143+
"background": "rgb(0, 0, 0)",
144+
"color": "rgb(255, 255, 255)",
145+
"border": "rgb(224, 224, 224)",
146+
})
147+
call-function: ("check-colors", {
148+
"theme": "light",
149+
"background": "rgb(253, 255, 211)",
150+
"color": "rgb(255, 255, 255)",
151+
"border": "rgb(224, 224, 224)",
152+
})

0 commit comments

Comments
 (0)