Skip to content

Commit 9b81a2a

Browse files
committed
rustdoc: add margin between scrollbar/resizer and links
This makes it easier to interact with these things without accidentally dragging a link around.
1 parent 96afcaa commit 9b81a2a

File tree

6 files changed

+16
-13
lines changed

6 files changed

+16
-13
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ ul.block, .block li {
570570
display: block;
571571
padding: 0.25rem; /* 4px */
572572
margin-left: -0.25rem;
573+
margin-right: 0.25rem;
573574
}
574575

575576
.sidebar h2 {
@@ -593,6 +594,7 @@ ul.block, .block li {
593594
color: var(--sidebar-link-color);
594595
}
595596
.sidebar .current,
597+
.sidebar .current a,
596598
.sidebar a:hover:not(.logo-container) {
597599
background-color: var(--sidebar-current-link-background-color);
598600
}
@@ -799,7 +801,7 @@ h2.small-section-header > .anchor {
799801
text-decoration: underline;
800802
}
801803

802-
.crate.block a.current { font-weight: 500; }
804+
.crate.block li.current a { font-weight: 500; }
803805

804806
/* In most contexts we use `overflow-wrap: anywhere` to ensure that we can wrap
805807
as much as needed on mobile (see

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

+1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ pre, pre > code,
132132
}
133133

134134
.sidebar .current,
135+
.sidebar .current a,
135136
.sidebar a:hover,
136137
#src-sidebar div.files > a:hover, details.dir-entry summary:hover,
137138
#src-sidebar div.files > a:focus, details.dir-entry summary:focus,

src/librustdoc/html/static/js/main.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,11 @@ function preLoadCss(cssUrl) {
476476
const current_page = document.location.href.split("/").pop();
477477
const link = document.createElement("a");
478478
link.href = path;
479-
if (path === current_page) {
480-
link.className = "current";
481-
}
482479
link.textContent = name;
483480
const li = document.createElement("li");
481+
if (path === current_page) {
482+
li.className = "current";
483+
}
484484
li.appendChild(link);
485485
ul.appendChild(li);
486486
}
@@ -613,12 +613,12 @@ function preLoadCss(cssUrl) {
613613
for (const crate of window.ALL_CRATES) {
614614
const link = document.createElement("a");
615615
link.href = window.rootPath + crate + "/index.html";
616-
if (window.rootPath !== "./" && crate === window.currentCrate) {
617-
link.className = "current";
618-
}
619616
link.textContent = crate;
620617

621618
const li = document.createElement("li");
619+
if (window.rootPath !== "./" && crate === window.currentCrate) {
620+
li.className = "current";
621+
}
622622
li.appendChild(link);
623623
ul.appendChild(li);
624624
}

tests/rustdoc-gui/links-color.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ define-function: (
2626
assert-css: (".item-table .keyword", {"color": |keyword|}, ALL)
2727
// Checking sidebar elements.
2828
assert-css: (
29-
".sidebar-elems a:not(.current)",
29+
".sidebar-elems li:not(.current) a",
3030
{"color": |sidebar|, "background-color": "rgba(0, 0, 0, 0)", "font-weight": "400"},
3131
ALL,
3232
)
3333
assert-css: (
34-
".sidebar-elems a.current",
34+
".sidebar-elems li.current a",
3535
{
3636
"color": |sidebar_current|,
3737
"background-color": |sidebar_current_background|,

tests/rustdoc-gui/sidebar-links-color.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ define-function: (
1717
reload:
1818
// Struct
1919
assert-css: (
20-
".sidebar .block.struct a:not(.current)",
20+
".sidebar .block.struct li:not(.current) a",
2121
{"color": |struct|, "background-color": "rgba(0, 0, 0, 0)"},
2222
)
23-
move-cursor-to: ".sidebar .block.struct a:not(.current)"
23+
move-cursor-to: ".sidebar .block.struct li:not(.current) a"
2424
assert-css: (
2525
".sidebar .block.struct a:hover",
2626
{"color": |struct_hover|, "background-color": |struct_hover_background|},

tests/rustdoc-gui/sidebar.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ assert-count: (".sidebar h2", 1)
5757
assert-text: ("#all-types", "All Items")
5858
assert-css: ("#all-types", {"color": "#356da4"})
5959
// We check that we have the crates list and that the "current" on is "test_docs".
60-
assert-text: (".sidebar-elems ul.crate > li > a.current", "test_docs")
60+
assert-text: (".sidebar-elems ul.crate > li.current > a", "test_docs")
6161
// And we're also supposed to have the list of items in the current module.
6262
assert-text: (".sidebar-elems section ul > li:nth-child(1)", "Re-exports")
6363
assert-text: (".sidebar-elems section ul > li:nth-child(2)", "Modules")
@@ -96,7 +96,7 @@ go-to: "file://" + |DOC_PATH| + "/lib2/index.html"
9696
assert-property: (".sidebar", {"clientWidth": "200"})
9797
assert-text: (".sidebar > .location", "Crate lib2")
9898
// We check that we have the crates list and that the "current" on is now "lib2".
99-
assert-text: (".sidebar-elems ul.crate > li > a.current", "lib2")
99+
assert-text: (".sidebar-elems ul.crate > li.current > a", "lib2")
100100
// We now go to the "foobar" function page.
101101
assert-text: (".sidebar-elems > section ul.block > li:nth-child(1)", "Modules")
102102
assert-text: (".sidebar-elems > section ul.block > li:nth-child(2)", "Structs")

0 commit comments

Comments
 (0)