Skip to content

Commit 871e7ad

Browse files
committed
rustdoc: add a handle that makes sidebar resizing more obvious
This change is based on some discussion on [lolbinarycat's idea], but with a more "traditional" design. Specifically, this is the closest thing I could find to a consensus across many systems I looked at for inspiration: - In Jira, resizable sidebars have a stack of four dots. - In The GIMP, resizable sidebars have a stack of three dots. - In [old Windows], "panes" are defined to have the same border style as a window, which has a raised appearance. - In [NeXT], a drag point usually had an innie, whether the line in a slider or the circle in a scroller; I can also hide and show the favorites bar in Workspace by dragging on a circular "grip spot" - In [old Mac], drag handles for things usually had a "grip track" of parallel lines. - [OSX] kept that, but the "Source List" part of the Finder still had the circle grip for a time the same way Workspace did [lolbinarycat's idea]: rust-lang#139420 [old Windows]: https://archive.org/details/windowsinterface00micr/page/n9/mode/2up [old Mac]: https://archive.org/details/apple-hig/1996_Human_Interface_Guidelines_for_Mac_OS_8_%28WWDC_Release%29/page/16/mode/2up [NeXT]: https://archive.org/details/apple-hig/1993%20NeXTSTEP%20User%20Interface%20Guidelines%20-%20Release%203/page/145/mode/2up [OSX]: https://dn721903.ca.archive.org/0/items/apple-hig/MacOSX_HIG_2005_09_08.pdf#page=267
1 parent d934244 commit 871e7ad

File tree

2 files changed

+53
-7
lines changed

2 files changed

+53
-7
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ nav.sub {
4343
--settings-button-border-focus: #717171;
4444
--sidebar-background-color: #f5f5f5;
4545
--sidebar-background-color-hover: #e0e0e0;
46+
--sidebar-border-color: #ddd;
4647
--code-block-background-color: #f5f5f5;
4748
--scrollbar-track-background-color: #dcdcdc;
4849
--scrollbar-thumb-background-color: rgba(36, 37, 39, 0.6);
@@ -135,6 +136,8 @@ nav.sub {
135136
--scrape-example-code-wrapper-background-end: rgba(255, 255, 255, 0);
136137
--sidebar-resizer-hover: hsl(207, 90%, 66%);
137138
--sidebar-resizer-active: hsl(207, 90%, 54%);
139+
--sidebar-resizer-img-filter: opacity(66%);
140+
--sidebar-resizer-img-hover-filter: none;
138141
}
139142
/* End theme: light */
140143

@@ -149,6 +152,7 @@ nav.sub {
149152
--settings-button-border-focus: #ffb900;
150153
--sidebar-background-color: #505050;
151154
--sidebar-background-color-hover: #676767;
155+
--sidebar-border-color: #2A2A2A;
152156
--code-block-background-color: #2A2A2A;
153157
--scrollbar-track-background-color: #717171;
154158
--scrollbar-thumb-background-color: rgba(32, 34, 37, .6);
@@ -244,6 +248,8 @@ nav.sub {
244248
--scrape-example-code-wrapper-background-end: rgba(53, 53, 53, 0);
245249
--sidebar-resizer-hover: hsl(207, 30%, 54%);
246250
--sidebar-resizer-active: hsl(207, 90%, 54%);
251+
--sidebar-resizer-img-filter: opacity(66%);
252+
--sidebar-resizer-img-hover-filter: none;
247253
}
248254
/* End theme: dark */
249255
}

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

+47-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
/* When static files are updated, their suffixes need to be updated.
1+
/*
2+
// ignore-tidy-filelength
3+
When static files are updated, their suffixes need to be updated.
24
1. In the top directory run:
35
./x.py doc --stage 1 library/core
46
2. Find the directory containing files named with updated suffixes:
@@ -493,12 +495,13 @@ img {
493495
top: 0;
494496
left: 0;
495497
z-index: var(--desktop-sidebar-z-index);
498+
/* resize indicator: hide this when on touch or mobile */
499+
border-right: solid 1px var(--sidebar-border-color);
496500
}
497501

498502
.rustdoc.src .sidebar {
499503
flex-basis: 50px;
500504
width: 50px;
501-
border-right: 1px solid;
502505
overflow-x: hidden;
503506
/* The sidebar is by default hidden */
504507
overflow-y: hidden;
@@ -516,8 +519,28 @@ img {
516519
z-index: calc(var(--desktop-sidebar-z-index) + 1);
517520
position: fixed;
518521
height: 100%;
519-
/* make sure there's a 1px gap between the scrollbar and resize handle */
520-
left: calc(var(--desktop-sidebar-width) + 1px);
522+
left: var(--desktop-sidebar-width);
523+
display: flex;
524+
align-items: center;
525+
justify-content: center;
526+
}
527+
528+
.sidebar-resizer::after {
529+
content: url('data:image/svg+xml,\
530+
<svg xmlns="http://www.w3.org/2000/svg" width="8" height="24" viewBox="0 0 8 24"> \
531+
<linearGradient id="x" x1="0" x2="0" y1="0" y2="1"> \
532+
<stop offset="0.5" stop-color="%23666"/><stop offset="0.5" stop-color="%23ccc"/> \
533+
</linearGradient> \
534+
<circle r="2" fill="none" stroke-width="2" stroke="url(%23x)" cy="21" cx="3"/> \
535+
<circle r="2" fill="none" stroke-width="2" stroke="url(%23x)" cy="15" cx="3"/> \
536+
<circle r="2" fill="none" stroke-width="2" stroke="url(%23x)" cy="9" cx="3"/> \
537+
<circle r="2" fill="none" stroke-width="2" stroke="url(%23x)" cy="3" cx="3"/></svg>');
538+
width: 8px;
539+
height: 24px;
540+
filter: var(--sidebar-resizer-img-filter);
541+
}
542+
.sidebar-resizer:hover::after {
543+
filter: var(--sidebar-resizer-img-hover-filter);
521544
}
522545
523546
.rustdoc.src .sidebar-resizer {
@@ -540,7 +563,7 @@ img {
540563
}
541564
542565
.sidebar-resizing * {
543-
cursor: col-resize !important;
566+
cursor: ew-resize !important;
544567
}
545568
546569
.sidebar-resizing .sidebar {
@@ -558,7 +581,7 @@ img {
558581
margin: 0;
559582
/* when active or hovered, place resizer glow on top of the sidebar (right next to, or even
560583
on top of, the scrollbar) */
561-
left: var(--desktop-sidebar-width);
584+
left: calc(var(--desktop-sidebar-width) - 1px);
562585
border-left: solid 1px var(--sidebar-resizer-hover);
563586
}
564587
@@ -575,6 +598,10 @@ img {
575598
/* too easy to hit the resizer while trying to hit the [-] toggle */
576599
display: none !important;
577600
}
601+
.sidebar {
602+
/* resize indicator: hide this when on touch or mobile */
603+
border-right: none;
604+
}
578605
}
579606
580607
.sidebar-resizer.active {
@@ -585,8 +612,10 @@ img {
585612
margin-left: -140px;
586613
border-left: none;
587614
}
588-
.sidebar-resizer.active:before {
615+
.sidebar-resizer.active::before {
589616
border-left: solid 2px var(--sidebar-resizer-active);
617+
margin-left: 8px;
618+
padding-left: 1px;
590619
display: block;
591620
height: 100%;
592621
content: "";
@@ -2510,6 +2539,8 @@ in src-script.js and main.js
25102539
/* Reduce height slightly to account for mobile topbar. */
25112540
height: calc(100vh - 45px);
25122541
width: 200px;
2542+
/* resize indicator: hide this when on touch or mobile */
2543+
border-right: none;
25132544
}
25142545

25152546
/* The source view uses a different design for the sidebar toggle, and doesn't have a topbar,
@@ -2893,6 +2924,7 @@ by default.
28932924
--settings-button-border-focus: #717171;
28942925
--sidebar-background-color: #f5f5f5;
28952926
--sidebar-background-color-hover: #e0e0e0;
2927+
--sidebar-border-color: #ddd;
28962928
--code-block-background-color: #f5f5f5;
28972929
--scrollbar-track-background-color: #dcdcdc;
28982930
--scrollbar-thumb-background-color: rgba(36, 37, 39, 0.6);
@@ -2985,6 +3017,8 @@ by default.
29853017
--scrape-example-code-wrapper-background-end: rgba(255, 255, 255, 0);
29863018
--sidebar-resizer-hover: hsl(207, 90%, 66%);
29873019
--sidebar-resizer-active: hsl(207, 90%, 54%);
3020+
--sidebar-resizer-img-filter: opacity(66%);
3021+
--sidebar-resizer-img-hover-filter: none;
29883022
}
29893023
/* End theme: light */
29903024

@@ -2998,6 +3032,7 @@ by default.
29983032
--settings-button-border-focus: #ffb900;
29993033
--sidebar-background-color: #505050;
30003034
--sidebar-background-color-hover: #676767;
3035+
--sidebar-border-color: #2A2A2A;
30013036
--code-block-background-color: #2A2A2A;
30023037
--scrollbar-track-background-color: #717171;
30033038
--scrollbar-thumb-background-color: rgba(32, 34, 37, .6);
@@ -3093,6 +3128,8 @@ by default.
30933128
--scrape-example-code-wrapper-background-end: rgba(53, 53, 53, 0);
30943129
--sidebar-resizer-hover: hsl(207, 30%, 54%);
30953130
--sidebar-resizer-active: hsl(207, 90%, 54%);
3131+
--sidebar-resizer-img-filter: opacity(66%);
3132+
--sidebar-resizer-img-hover-filter: none;
30963133
}
30973134
/* End theme: dark */
30983135

@@ -3110,6 +3147,7 @@ Original by Dempfi (https://github.com/dempfi/ayu)
31103147
--settings-button-border-focus: #e0e0e0;
31113148
--sidebar-background-color: #14191f;
31123149
--sidebar-background-color-hover: rgba(70, 70, 70, 0.33);
3150+
--sidebar-border-color: #000;
31133151
--code-block-background-color: #191f26;
31143152
--scrollbar-track-background-color: transparent;
31153153
--scrollbar-thumb-background-color: #5c6773;
@@ -3205,6 +3243,8 @@ Original by Dempfi (https://github.com/dempfi/ayu)
32053243
--scrape-example-code-wrapper-background-end: rgba(15, 20, 25, 0);
32063244
--sidebar-resizer-hover: hsl(34, 50%, 33%);
32073245
--sidebar-resizer-active: hsl(34, 100%, 66%);
3246+
--sidebar-resizer-img-filter: opacity(66%);
3247+
--sidebar-resizer-img-hover-filter: none;
32083248
}
32093249

32103250
:root[data-theme="ayu"] h1,

0 commit comments

Comments
 (0)