Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5b23dc6

Browse files
Make impl section headers sticky
1 parent 1555074 commit 5b23dc6

File tree

1 file changed

+36
-12
lines changed

1 file changed

+36
-12
lines changed

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

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ xmlns="http://www.w3.org/2000/svg" fill="black" height="18px">\
3838
--code-block-border-radius: 6px;
3939
--impl-items-indent: 0.3em;
4040
--docblock-indent: 24px;
41+
--mobile-top-navbar-height: 45px;
42+
--collapse-toggle-left: -24px;
4143
}
4244

4345
/* See FiraSans-LICENSE.txt for the Fira Sans license. */
@@ -746,7 +748,8 @@ ul.block, .block li, .block ul {
746748
/* extend click target to far edge of screen (mile wide bar) */
747749
border-left: solid var(--sidebar-elems-left-padding) transparent;
748750
background-clip: border-box;
749-
margin: 0 calc(-24px + 0.25rem) 0 calc(-0.2rem - var(--sidebar-elems-left-padding));
751+
margin: 0 calc(var(--collapse-toggle-left) + 0.25rem) 0
752+
calc(-0.2rem - var(--sidebar-elems-left-padding));
750753
/* Align the sidebar crate link with the search bar, which have different
751754
font sizes.
752755
@@ -2163,13 +2166,13 @@ details.toggle > summary.hideme::before {
21632166

21642167
details.toggle > summary:not(.hideme)::before {
21652168
position: absolute;
2166-
left: -24px;
2169+
left: var(--collapse-toggle-left);
21672170
top: 4px;
21682171
}
21692172

21702173
.impl-items > details.toggle > summary:not(.hideme)::before {
21712174
position: absolute;
2172-
left: -24px;
2175+
left: var(--collapse-toggle-left);
21732176
}
21742177

21752178
/* We indent items of an impl block to have a visual marker that these items are part
@@ -2181,6 +2184,26 @@ details.toggle > summary:not(.hideme)::before {
21812184
margin-left: var(--impl-items-indent);
21822185
}
21832186

2187+
h2.section-header + div > details.implementors-toggle > summary,
2188+
details.toggle.big-toggle > summary {
2189+
position: sticky;
2190+
top: 0;
2191+
background: var(--main-background-color);
2192+
z-index: 1;
2193+
padding-left: calc(var(--collapse-toggle-left) * -1);
2194+
margin-left: var(--collapse-toggle-left);
2195+
}
2196+
h2.section-header + div > details.implementors-toggle > summary:not(.hideme)::before,
2197+
details.toggle.big-toggle > summary:not(.hideme)::before {
2198+
left: -4px;
2199+
}
2200+
h2.section-header + div > details.implementors-toggle > summary .anchor {
2201+
left: calc(-0.5rem - var(--collapse-toggle-left));
2202+
}
2203+
details.toggle.big-toggle > summary .anchor {
2204+
left: -0.8rem;
2205+
}
2206+
21842207
details.big-toggle > summary:not(.hideme)::before {
21852208
left: -34px;
21862209
top: 9px;
@@ -2272,14 +2295,15 @@ in src-script.js and main.js
22722295
@media (max-width: 700px) {
22732296
:root {
22742297
--impl-items-indent: 0.7em;
2298+
--collapse-toggle-left: -11px;
22752299
}
22762300

22772301
/* When linking to an item with an `id` (for instance, by clicking a link in the sidebar,
22782302
or visiting a URL with a fragment like `#method.new`, we don't want the item to be obscured
22792303
by the topbar. Anything with an `id` gets scroll-margin-top equal to .mobile-topbar's size.
22802304
*/
22812305
*[id] {
2282-
scroll-margin-top: 45px;
2306+
scroll-margin-top: var(--mobile-top-navbar-height);
22832307
}
22842308

22852309
/* We don't display this button on mobile devices. */
@@ -2327,13 +2351,13 @@ in src-script.js and main.js
23272351

23282352
.sidebar {
23292353
position: fixed;
2330-
top: 45px;
2354+
top: var(--mobile-top-navbar-height);
23312355
/* Hide the sidebar offscreen while not in use. Doing this instead of display: none means
23322356
the sidebar stays visible for screen readers, which is useful for navigation. */
23332357
left: -1000px;
23342358
z-index: 11;
23352359
/* Reduce height slightly to account for mobile topbar. */
2336-
height: calc(100vh - 45px);
2360+
height: calc(100vh - var(--mobile-top-navbar-height));
23372361
width: 200px;
23382362
}
23392363

@@ -2390,7 +2414,7 @@ in src-script.js and main.js
23902414
position: sticky;
23912415
z-index: 10;
23922416
font-size: 2rem;
2393-
height: 45px;
2417+
height: var(--mobile-top-navbar-height);
23942418
width: 100%;
23952419
left: 0;
23962420
top: 0;
@@ -2418,11 +2442,6 @@ in src-script.js and main.js
24182442
display: none !important;
24192443
}
24202444

2421-
#main-content > details.toggle > summary::before,
2422-
#main-content > div > details.toggle > summary::before {
2423-
left: -11px;
2424-
}
2425-
24262445
/* sidebar button becomes topbar button */
24272446
#sidebar-button > a:before {
24282447
content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" \
@@ -2493,6 +2512,11 @@ in src-script.js and main.js
24932512
margin: 0 0 -25px 0;
24942513
padding: var(--nav-sub-mobile-padding);
24952514
}
2515+
2516+
h2.section-header + div > details.implementors-toggle > summary,
2517+
details.toggle.big-toggle > summary {
2518+
top: var(--mobile-top-navbar-height);
2519+
}
24962520
}
24972521

24982522

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /