Skip to content

Commit fdc6c49

Browse files
committed
rustdoc: make the resize handle easier to find
This commit makes two related changes: * The resize handle is now a bit bigger, 10px specifically. * A visible indicator appears when you're in the area to tell you that you can interact with the border.
1 parent 4463bb3 commit fdc6c49

File tree

5 files changed

+40
-15
lines changed

5 files changed

+40
-15
lines changed

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

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -407,22 +407,22 @@ img {
407407
}
408408

409409
.sidebar-resizer {
410-
width: 3px;
411-
margin: 0 3px;
410+
width: 9px;
412411
cursor: col-resize;
413412
z-index: 10;
414413
position: absolute;
415414
height: 100%;
416-
left: var(--desktop-sidebar-width, 200px);
415+
/* make sure there's a 1px gap between the scrollbar and resize handle */
416+
left: calc(var(--desktop-sidebar-width, 200px) + 1px);
417417
}
418418

419419
.rustdoc.src .sidebar-resizer {
420-
left: 50px;
421-
width: 6px;
422-
margin: 0 3px 0 0;
420+
/* when closed, place resizer glow on top of the normal src sidebar border (no need to worry about sidebar) */
421+
left: 49px;
423422
}
424423

425424
.src-sidebar-expanded .rustdoc.src .sidebar-resizer {
425+
/* for src sidebar, gap is already provided by 1px border on sidebar itself, so place resizer to right of it */
426426
left: var(--src-sidebar-width, 300px);
427427
}
428428

@@ -439,16 +439,35 @@ img {
439439

440440
.sidebar-resizer:hover,
441441
.sidebar-resizer:active,
442-
.sidebar-resizer:focus {
443-
width: 9px;
442+
.sidebar-resizer:focus,
443+
.sidebar-resizer.active {
444+
width: 10px;
444445
margin: 0;
446+
/* when active or hovered, place resizer glow on top of the sidebar (right next to, or even on top of, the scrollbar) */
447+
left: var(--desktop-sidebar-width, 200px);
448+
border-left: solid 1px var(--sidebar-resizer-hover);
449+
}
450+
451+
.src-sidebar-expanded .rustdoc.src .sidebar-resizer:hover,
452+
.src-sidebar-expanded .rustdoc.src .sidebar-resizer:active,
453+
.src-sidebar-expanded .rustdoc.src .sidebar-resizer:focus,
454+
.src-sidebar-expanded .rustdoc.src .sidebar-resizer.active {
455+
/* when active or hovered, place resizer glow on top of the normal src sidebar border */
456+
left: calc(var(--src-sidebar-width, 300px) - 1px);
445457
}
446458

447459
.sidebar-resizer.active {
448-
/* when dragging the sidebar into nothing, make sure the items inside
449-
don't get hovered over */
450-
width: 141px;
451-
margin: 0 -66px;
460+
/* make the resize tool bigger when actually resizing, to avoid :hover styles on other stuff while resizing */
461+
padding: 0 140px;
462+
width: 2px;
463+
margin-left: -140px;
464+
border-left: none;
465+
}
466+
.sidebar-resizer.active:before {
467+
border-left: solid 2px var(--sidebar-resizer-active);
468+
display: block;
469+
height: 100%;
470+
content: "";
452471
}
453472

454473
.sidebar, .mobile-topbar, .sidebar-menu-toggle,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ Original by Dempfi (https://github.com/dempfi/ayu)
104104
--scrape-example-help-hover-color: #fff;
105105
--scrape-example-code-wrapper-background-start: rgba(15, 20, 25, 1);
106106
--scrape-example-code-wrapper-background-end: rgba(15, 20, 25, 0);
107+
--sidebar-resizer-hover: hsl(34, 50%, 33%);
108+
--sidebar-resizer-active: hsl(34, 100%, 66%);
107109
}
108110

109111
h1, h2, h3, h4,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,6 @@
9999
--scrape-example-help-hover-color: #fff;
100100
--scrape-example-code-wrapper-background-start: rgba(53, 53, 53, 1);
101101
--scrape-example-code-wrapper-background-end: rgba(53, 53, 53, 0);
102+
--sidebar-resizer-hover: hsl(207, 30%, 54%);
103+
--sidebar-resizer-active: hsl(207, 90%, 54%);
102104
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,6 @@
9696
--scrape-example-help-hover-color: #000;
9797
--scrape-example-code-wrapper-background-start: rgba(255, 255, 255, 1);
9898
--scrape-example-code-wrapper-background-end: rgba(255, 255, 255, 0);
99+
--sidebar-resizer-hover: hsl(207, 90%, 66%);
100+
--sidebar-resizer-active: hsl(207, 90%, 54%);
99101
}

tests/rustdoc-gui/sidebar-resize.goml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ set-local-storage: {"rustdoc-hide-sidebar": "false"}
1212

1313
// Now same thing, but for source code
1414
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
15-
assert-property: (".sidebar", {"clientWidth": "49"})
15+
assert-property: (".sidebar", {"clientWidth": "46"})
1616
drag-and-drop: ((52, 100), (185, 100))
17-
assert-property: (".sidebar", {"clientWidth": "181"})
17+
assert-property: (".sidebar", {"clientWidth": "151"})
1818
drag-and-drop: ((185, 100), (5, 100))
1919
// instead of hiding the sidebar entirely, this
2020
// will switch to the toggle mode
21-
assert-property: (".sidebar", {"clientWidth": "49"})
21+
assert-property: (".sidebar", {"clientWidth": "46"})

0 commit comments

Comments
 (0)