Skip to content

Commit 6e9cbac

Browse files
Rollup merge of rust-lang#46938 - hellow554:rustdoc-kbd-style, r=GuillaumeGomez
add kbd style tag to main.css in rustdoc Added css style for kbd tags so they actually look like keys. Result preview and discussion was going on in rust-lang#46900 .
2 parents 10333dd + 0c946c0 commit 6e9cbac

File tree

3 files changed

+30
-19
lines changed

3 files changed

+30
-19
lines changed

src/librustdoc/html/layout.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,22 @@ r##"<!DOCTYPE html>
9494
<h2>Keyboard Shortcuts</h2>
9595
9696
<dl>
97-
<dt>?</dt>
97+
<dt><kbd>?</kbd></dt>
9898
<dd>Show this help dialog</dd>
99-
<dt>S</dt>
99+
<dt><kbd>S</kbd></dt>
100100
<dd>Focus the search field</dd>
101-
<dt></dt>
101+
<dt><kbd>↑</kbd></dt>
102102
<dd>Move up in search results</dd>
103-
<dt></dt>
103+
<dt><kbd>↓</kbd></dt>
104104
<dd>Move down in search results</dd>
105-
<dt></dt>
105+
<dt><kbd>↹</kbd></dt>
106106
<dd>Switch tab</dd>
107-
<dt>&#9166;</dt>
107+
<dt><kbd>&#9166;</kbd></dt>
108108
<dd>Go to active search result</dd>
109-
<dt style="width:31px;">+ / -</dt>
110-
<dd>Collapse/expand all sections</dd>
109+
<dt><kbd>+</kbd></dt>
110+
<dd>Expand all sections</dd>
111+
<dt><kbd>-</kbd></dt>
112+
<dd>Collapse all sections</dd>
111113
</dl>
112114
</div>
113115

src/librustdoc/html/static/rustdoc.css

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -585,18 +585,13 @@ body.blur > :not(#help) {
585585
flex: 0 0 auto;
586586
box-shadow: 0 0 6px rgba(0,0,0,.2);
587587
width: 550px;
588-
height: 354px;
588+
height: auto;
589589
border: 1px solid;
590590
}
591591
#help dt {
592592
float: left;
593-
border-radius: 4px;
594-
border: 1px solid;
595-
width: 23px;
596-
text-align: center;
597593
clear: left;
598594
display: block;
599-
margin-top: -1px;
600595
}
601596
#help dd { margin: 5px 35px; }
602597
#help .infos { padding-left: 0; }
@@ -1134,3 +1129,14 @@ h3.important {
11341129
left: -42px;
11351130
margin-top: 2px;
11361131
}
1132+
1133+
kbd {
1134+
display: inline-block;
1135+
padding: 3px 5px;
1136+
font: 15px "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
1137+
line-height: 10px;
1138+
vertical-align: middle;
1139+
border: solid 1px;
1140+
border-radius: 3px;
1141+
box-shadow: inset 0 -1px 0;
1142+
}

src/librustdoc/html/static/styles/main.css

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,6 @@ a.test-arrow {
194194
border-color: #bfbfbf;
195195
}
196196

197-
#help dt {
198-
border-color: #bfbfbf;
199-
background: #fff;
200-
}
201-
202197
.since {
203198
color: grey;
204199
}
@@ -348,3 +343,11 @@ pre.ignore:hover, .information:hover + pre.ignore {
348343
border-bottom-color: #e0e0e0;
349344
}
350345
}
346+
347+
kbd {
348+
color: #444d56;
349+
background-color: #fafbfc;
350+
border-color: #d1d5da;
351+
border-bottom-color: #c6cbd1;
352+
box-shadow-color: #c6cbd1;
353+
}

0 commit comments

Comments
 (0)