Skip to content

Commit 7bf43c3

Browse files
authored
Rollup merge of #96958 - GuillaumeGomez:settings-menu-display, r=jsha
Improve settings menu display and remove theme menu We talked about improving the settings menu and we mentioned that firefox pocket was a nice inspiration so I implemented it. The result looks like this: ![Screenshot from 2022-05-11 23-59-53](https://user-images.githubusercontent.com/3050060/167954743-438c0a06-4628-478c-bf0c-d20313c1fdfc.png) You can test it [here](https://rustdoc.crud.net/imperio/settings-menu-display/doc/foo/index.html). Only question I have is: should I re-assign the shortcut `T` to this setting menu now that the theme menu is gone? For now I simply removed it. Important to be noted: the full settings page (at `settings.html`) is still rendered the same as currently. r? ``@jsha``
2 parents 7fb2d0e + dee2947 commit 7bf43c3

File tree

16 files changed

+152
-276
lines changed

16 files changed

+152
-276
lines changed

src/doc/rustdoc/src/how-to-read-rustdoc.md

+7-10
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,8 @@ or the current item whose documentation is being displayed.
5959
## The Theme Picker and Search Interface
6060

6161
When viewing `rustdoc`'s output in a browser with JavaScript enabled,
62-
a dynamic interface appears at the top of the page.
63-
To the left is the theme picker, denoted with a paint-brush icon,
64-
and the search interface, help screen, and options appear to the right of that.
65-
66-
### The Theme Picker
67-
68-
Clicking on the theme picker provides a list of themes -
69-
by default `ayu`, `light`, and `dark` -
70-
which are available for viewing.
62+
a dynamic interface appears at the top of the page composed of the search
63+
interface, help screen, and options.
7164

7265
### The Search Interface
7366

@@ -91,12 +84,16 @@ When typing in the search bar, you can prefix your search term with a type
9184
followed by a colon (such as `mod:`) to restrict the results to just that
9285
kind of item. (The available items are listed in the help popup.)
9386

87+
### Changing displayed theme
88+
89+
You can change the displayed theme by opening the settings menu (the gear
90+
icon in the upper right) and then pick a new one from there.
91+
9492
### Shortcuts
9593

9694
Pressing `S` while focused elsewhere on the page will move focus to the
9795
search bar, and pressing `?` shows the help screen,
9896
which includes all these shortcuts and more.
99-
Pressing `T` focuses the theme picker.
10097

10198
When the search results are focused,
10299
the left and right arrows move between tabs and the up and down arrows move

src/doc/rustdoc/src/write-documentation/what-to-include.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ rustdoc --extend-css custom.css src/lib.rs
109109

110110
A good example of using this feature to create a dark theme is documented [on
111111
this blog]. Just remember, dark theme is already included in the rustdoc output
112-
by clicking on the paintbrush. Adding additional options to the themes are
113-
as easy as creating a custom theme `.css` file and using the following syntax:
112+
by clicking on the gear icon in the upper right. Adding additional options to the
113+
themes are as easy as creating a custom theme `.css` file and using the following
114+
syntax:
114115

115116
```bash
116117
rustdoc --theme awesome.css src/lib.rs

src/librustdoc/html/markdown.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1448,8 +1448,6 @@ fn init_id_map() -> FxHashMap<Cow<'static, str>, usize> {
14481448
// used in tera template files).
14491449
map.insert("mainThemeStyle".into(), 1);
14501450
map.insert("themeStyle".into(), 1);
1451-
map.insert("theme-picker".into(), 1);
1452-
map.insert("theme-choices".into(), 1);
14531451
map.insert("settings-menu".into(), 1);
14541452
map.insert("help-button".into(), 1);
14551453
map.insert("main-content".into(), 1);

src/librustdoc/html/render/write_shared.rs

-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ pub(super) fn write_shared(
238238
write_toolchain("favicon-16x16.png", static_files::RUST_FAVICON_PNG_16)?;
239239
write_toolchain("favicon-32x32.png", static_files::RUST_FAVICON_PNG_32)?;
240240
}
241-
write_toolchain("brush.svg", static_files::BRUSH_SVG)?;
242241
write_toolchain("wheel.svg", static_files::WHEEL_SVG)?;
243242
write_toolchain("clipboard.svg", static_files::CLIPBOARD_SVG)?;
244243
write_toolchain("down-arrow.svg", static_files::DOWN_ARROW_SVG)?;

src/librustdoc/html/static/css/noscript.css

-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,3 @@ rules.
1818
/* The search bar and related controls don't work without JS */
1919
display: none;
2020
}
21-
22-
#theme-picker {
23-
display: none;
24-
}

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

+36-19
Original file line numberDiff line numberDiff line change
@@ -1379,31 +1379,30 @@ pre.rust {
13791379
margin-bottom: 6px;
13801380
}
13811381

1382-
.theme-picker {
1383-
position: absolute;
1384-
left: -38px;
1385-
top: 4px;
1386-
}
1387-
1388-
.theme-picker button {
1389-
outline: none;
1390-
}
1391-
13921382
#settings-menu, #help-button {
13931383
margin-left: 4px;
13941384
outline: none;
13951385
}
13961386

1397-
#theme-picker, #copy-path {
1387+
#copy-path {
13981388
height: 34px;
13991389
}
1400-
#theme-picker, #settings-menu, #help-button, #copy-path {
1390+
#settings-menu > a, #help-button, #copy-path {
14011391
padding: 5px;
14021392
width: 33px;
14031393
border: 1px solid;
14041394
border-radius: 2px;
14051395
cursor: pointer;
14061396
}
1397+
#settings-menu {
1398+
padding: 0;
1399+
}
1400+
#settings-menu > a {
1401+
padding: 5px;
1402+
width: 100%;
1403+
height: 100%;
1404+
display: block;
1405+
}
14071406

14081407
@keyframes rotating {
14091408
from {
@@ -1413,9 +1412,33 @@ pre.rust {
14131412
transform: rotate(360deg);
14141413
}
14151414
}
1416-
#settings-menu.rotate img {
1415+
#settings-menu.rotate > a img {
14171416
animation: rotating 2s linear infinite;
14181417
}
1418+
#settings-menu #settings {
1419+
position: absolute;
1420+
right: 0;
1421+
z-index: 1;
1422+
display: block;
1423+
margin-top: 7px;
1424+
border-radius: 3px;
1425+
border: 1px solid;
1426+
}
1427+
#settings-menu #settings .setting-line {
1428+
margin: 0.6em;
1429+
}
1430+
/* This rule is to draw the little arrow connecting the settings menu to the gear icon. */
1431+
#settings-menu #settings::before {
1432+
content: '';
1433+
position: absolute;
1434+
right: 11px;
1435+
border: solid;
1436+
border-width: 1px 1px 0 0;
1437+
display: inline-block;
1438+
padding: 4px;
1439+
transform: rotate(-45deg);
1440+
top: -5px;
1441+
}
14191442

14201443
#help-button {
14211444
font-family: "Fira Sans", Arial, sans-serif;
@@ -1838,12 +1861,6 @@ details.rustdoc-toggle[open] > summary.hideme::after {
18381861
margin-left: 32px;
18391862
}
18401863

1841-
/* Space is at a premium on mobile, so remove the theme-picker icon. */
1842-
#theme-picker {
1843-
display: none;
1844-
width: 0;
1845-
}
1846-
18471864
.content {
18481865
margin-left: 0px;
18491866
}

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

+8-11
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Original by Dempfi (https://github.com/dempfi/ayu)
55

66
/* General structure and fonts */
77

8-
body {
8+
body, #settings-menu #settings, #settings-menu #settings::before {
99
background-color: #0f1419;
1010
color: #c5c5c5;
1111
}
@@ -531,16 +531,20 @@ kbd {
531531
box-shadow: inset 0 -1px 0 #5c6773;
532532
}
533533

534-
#theme-picker, #settings-menu, #help-button {
534+
#settings-menu > a, #help-button {
535535
border-color: #5c6773;
536536
background-color: #0f1419;
537537
color: #fff;
538538
}
539539

540-
#theme-picker > img, #settings-menu > img {
540+
#settings-menu > a img {
541541
filter: invert(100);
542542
}
543543

544+
#settings-menu #settings, #settings-menu #settings::before {
545+
border-color: #5c6773;
546+
}
547+
544548
#copy-path {
545549
color: #fff;
546550
}
@@ -551,8 +555,7 @@ kbd {
551555
filter: invert(100%);
552556
}
553557

554-
#theme-picker:hover, #theme-picker:focus,
555-
#settings-menu:hover, #settings-menu:focus,
558+
#settings-menu > a:hover, #settings-menu > a:focus,
556559
#help-button:hover, #help-button:focus {
557560
border-color: #e0e0e0;
558561
}
@@ -570,12 +573,6 @@ kbd {
570573
background-color: rgba(110, 110, 110, 0.33);
571574
}
572575

573-
@media (max-width: 700px) {
574-
#theme-picker {
575-
background: #0f1419;
576-
}
577-
}
578-
579576
.search-results .result-name span.alias {
580577
color: #c5c5c5;
581578
}

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

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
body {
1+
body, #settings-menu #settings, #settings-menu #settings::before {
22
background-color: #353535;
33
color: #ddd;
44
}
@@ -408,18 +408,21 @@ kbd {
408408
box-shadow: inset 0 -1px 0 #c6cbd1;
409409
}
410410

411-
#theme-picker, #settings-menu, #help-button {
411+
#settings-menu > a, #help-button {
412412
border-color: #e0e0e0;
413413
background: #f0f0f0;
414414
color: #000;
415415
}
416416

417-
#theme-picker:hover, #theme-picker:focus,
418-
#settings-menu:hover, #settings-menu:focus,
417+
#settings-menu > a:hover, #settings-menu > a:focus,
419418
#help-button:hover, #help-button:focus {
420419
border-color: #ffb900;
421420
}
422421

422+
#settings-menu #settings, #settings-menu #settings::before {
423+
border-color: #d2d2d2;
424+
}
425+
423426
#copy-path {
424427
color: #999;
425428
}
@@ -443,12 +446,6 @@ kbd {
443446
background-color: #4e4e4e;
444447
}
445448

446-
@media (max-width: 700px) {
447-
#theme-picker {
448-
background: #f0f0f0;
449-
}
450-
}
451-
452449
.search-results .result-name span.alias {
453450
color: #fff;
454451
}

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

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* General structure and fonts */
22

3-
body {
3+
body, #settings-menu #settings, #settings-menu #settings::before {
44
background-color: white;
55
color: black;
66
}
@@ -394,17 +394,20 @@ kbd {
394394
box-shadow: inset 0 -1px 0 #c6cbd1;
395395
}
396396

397-
#theme-picker, #settings-menu, #help-button {
397+
#settings-menu > a, #help-button {
398398
border-color: #e0e0e0;
399399
background-color: #fff;
400400
}
401401

402-
#theme-picker:hover, #theme-picker:focus,
403-
#settings-menu:hover, #settings-menu:focus,
402+
#settings-menu > a:hover, #settings-menu > a:focus,
404403
#help-button:hover, #help-button:focus {
405404
border-color: #717171;
406405
}
407406

407+
#settings-menu #settings, #settings-menu #settings::before {
408+
border-color: #DDDDDD;
409+
}
410+
408411
#copy-path {
409412
color: #999;
410413
}
@@ -428,12 +431,6 @@ kbd {
428431
background-color: #eee;
429432
}
430433

431-
@media (max-width: 700px) {
432-
#theme-picker {
433-
background: #fff;
434-
}
435-
}
436-
437434
.search-results .result-name span.alias {
438435
color: #000;
439436
}

0 commit comments

Comments
 (0)