Skip to content

Commit f28a8ca

Browse files
committed
rustdoc: simplify CSS for codeblock tooltips
Instead of making its parts `display: none` and then changing it on hover, just make the pseudo-element itself on hover.
1 parent 984eab5 commit f28a8ca

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,8 +1114,7 @@ pre.rust .doccomment {
11141114
top: 5px;
11151115
}
11161116

1117-
.example-wrap .tooltip::after {
1118-
display: none;
1117+
.example-wrap .tooltip:hover::after {
11191118
text-align: center;
11201119
padding: 5px 3px 3px 3px;
11211120
border-radius: 6px;
@@ -1130,35 +1129,30 @@ pre.rust .doccomment {
11301129
color: var(--tooltip-color);
11311130
}
11321131

1133-
.example-wrap .tooltip::before {
1132+
.example-wrap .tooltip:hover::before {
11341133
content: " ";
11351134
position: absolute;
11361135
top: 50%;
11371136
left: 16px;
11381137
margin-top: -5px;
1139-
display: none;
11401138
z-index: 1;
11411139
border: 5px solid transparent;
11421140
border-right-color: var(--tooltip-background-color);
11431141
}
11441142

1145-
.example-wrap.ignore .tooltip::after {
1143+
.example-wrap.ignore .tooltip:hover::after {
11461144
content: "This example is not tested";
11471145
}
1148-
.example-wrap.compile_fail .tooltip::after {
1146+
.example-wrap.compile_fail .tooltip:hover::after {
11491147
content: "This example deliberately fails to compile";
11501148
}
1151-
.example-wrap.should_panic .tooltip::after {
1149+
.example-wrap.should_panic .tooltip:hover::after {
11521150
content: "This example panics";
11531151
}
1154-
.example-wrap.edition .tooltip::after {
1152+
.example-wrap.edition .tooltip:hover::after {
11551153
content: "This code runs with edition " attr(data-edition);
11561154
}
11571155

1158-
.example-wrap .tooltip:hover::before, .example-wrap .tooltip:hover::after {
1159-
display: inline;
1160-
}
1161-
11621156
.example-wrap.compile_fail .tooltip,
11631157
.example-wrap.should_panic .tooltip,
11641158
.example-wrap.ignore .tooltip {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ define-function: (
2020
{"border-left": "2px solid rgba(255, 0, 0, 0.5)"},
2121
)),
2222

23-
("move-cursor-to", ".docblock .example-wrap.compile_fail"),
23+
("move-cursor-to", ".docblock .example-wrap.compile_fail .tooltip"),
2424

2525
("assert-css", (
2626
".docblock .example-wrap.compile_fail .tooltip",
@@ -60,7 +60,7 @@ define-function: (
6060
{"border-left": "2px solid rgba(255, 0, 0, 0.5)"},
6161
)),
6262

63-
("move-cursor-to", ".docblock .example-wrap.should_panic"),
63+
("move-cursor-to", ".docblock .example-wrap.should_panic .tooltip"),
6464

6565
("assert-css", (
6666
".docblock .example-wrap.should_panic .tooltip",
@@ -100,7 +100,7 @@ define-function: (
100100
{"border-left": "2px solid rgba(255, 142, 0, 0.6)"},
101101
)),
102102

103-
("move-cursor-to", ".docblock .example-wrap.ignore"),
103+
("move-cursor-to", ".docblock .example-wrap.ignore .tooltip"),
104104

105105
("assert-css", (
106106
".docblock .example-wrap.ignore .tooltip",

0 commit comments

Comments
 (0)