Skip to content

Commit d0563c6

Browse files
authored
Rollup merge of #105504 - notriddle:notriddle/stab-css, r=GuillaumeGomez
rustdoc: make stability badge CSS more consistent # Before ![image](https://user-images.githubusercontent.com/1593513/206763667-8e0deb74-be63-4906-8229-9a7eb51725c2.png) ![image](https://user-images.githubusercontent.com/1593513/206764007-6301c0e8-4594-4a41-ba93-105824dffee6.png) # After ![image](https://user-images.githubusercontent.com/1593513/206763698-e187cee2-3a50-4e48-b7b5-c3cfa41a797d.png) ![image](https://user-images.githubusercontent.com/1593513/206764058-3999ee67-1439-4c98-8216-b90575342aa8.png) # Description * They all get rounded corners now. A test case has been added for this, too. * There are now broadly two kinds of stability badge, where there used to be three: item-info "fat badge", and the "thin badge" in both item tables and in docblocks (which got merged). The fat badges can have icons, while the thin badges can't. * The old Ayu design doesn't make sense to me. Does anyone know why it was done that way?
2 parents f78babd + d60967b commit d0563c6

File tree

3 files changed

+54
-27
lines changed

3 files changed

+54
-27
lines changed

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

+13-22
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ pre.rust a,
212212
.mobile-topbar h2 a,
213213
h1 a,
214214
.search-results a,
215-
.item-left .stab,
215+
.stab,
216216
.result-name .primitive > i, .result-name .keyword > i {
217217
color: var(--main-color);
218218
}
@@ -960,22 +960,29 @@ so that we can apply CSS-filters to change the arrow color in themes */
960960
}
961961

962962
.item-info .stab {
963-
width: fit-content;
964963
/* This min-height is needed to unify the height of the stab elements because some of them
965964
have emojis.
966965
*/
967966
min-height: 36px;
968967
display: flex;
969-
align-items: center;
970-
white-space: pre-wrap;
971-
}
972-
.stab {
973968
padding: 3px;
974969
margin-bottom: 5px;
970+
}
971+
.item-left .stab {
972+
margin-left: 0.3125em;
973+
}
974+
.stab {
975+
padding: 0 2px;
975976
font-size: 0.875rem;
976977
font-weight: normal;
977978
color: var(--main-color);
978979
background-color: var(--stab-background-color);
980+
width: fit-content;
981+
align-items: center;
982+
white-space: pre-wrap;
983+
border-radius: 3px;
984+
display: inline-flex;
985+
vertical-align: text-bottom;
979986
}
980987

981988
.stab.portability > code {
@@ -988,12 +995,6 @@ so that we can apply CSS-filters to change the arrow color in themes */
988995
margin-right: 0.3rem;
989996
}
990997

991-
/* This is to prevent the `.stab` elements to overflow the .docblock elements. */
992-
.docblock .stab {
993-
padding: 0 0.125em;
994-
margin-bottom: 0;
995-
}
996-
997998
/* Black one-pixel outline around emoji shapes */
998999
.emoji {
9991000
text-shadow:
@@ -1003,16 +1004,6 @@ so that we can apply CSS-filters to change the arrow color in themes */
10031004
0 -1px 0 black;
10041005
}
10051006

1006-
.item-left .stab {
1007-
border-radius: 3px;
1008-
display: inline-block;
1009-
line-height: 1.2;
1010-
margin-bottom: 0;
1011-
margin-left: 0.3125em;
1012-
padding: 2px;
1013-
vertical-align: text-bottom;
1014-
}
1015-
10161007
.module-item.unstable,
10171008
.import-item.unstable {
10181009
opacity: 0.65;

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

-5
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,6 @@ body.source .example-wrap pre.rust a {
160160
background: #333;
161161
}
162162

163-
.module-item .stab,
164-
.import-item .stab {
165-
color: #000;
166-
}
167-
168163
.result-name .primitive > i, .result-name .keyword > i {
169164
color: #788797;
170165
}

src/test/rustdoc-gui/stab-badge.goml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// All stability badges should have rounded corners and colored backgrounds.
2+
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
3+
show-text: true
4+
define-function: (
5+
"check-badge",
6+
(theme, background, color),
7+
[
8+
("local-storage", {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|}),
9+
("goto", "file://" + |DOC_PATH| + "/test_docs/index.html"),
10+
("assert", (".docblock .stab")),
11+
("assert", (".item-table .stab")),
12+
("assert-css", (".stab", {
13+
"border-radius": "3px",
14+
"color": |color|,
15+
"background-color": |background|,
16+
})),
17+
("goto", "file://" + |DOC_PATH| + "/test_docs/fn.replaced_function.html"),
18+
("assert", (".item-info .stab")),
19+
("assert-css", (".stab", {
20+
"border-radius": "3px",
21+
"color": |color|,
22+
"background-color": |background|,
23+
})),
24+
]
25+
)
26+
27+
call-function: ("check-badge", {
28+
"theme": "ayu",
29+
"color": "rgb(197, 197, 197)",
30+
"background": "rgb(49, 69, 89)",
31+
})
32+
call-function: ("check-badge", {
33+
"theme": "dark",
34+
"color": "rgb(221, 221, 221)",
35+
"background": "rgb(49, 69, 89)",
36+
})
37+
call-function: ("check-badge", {
38+
"theme": "light",
39+
"color": "rgb(0, 0, 0)",
40+
"background": "rgb(255, 245, 214)",
41+
})

0 commit comments

Comments
 (0)