about summary refs log tree commit diff
path: root/src/librustdoc/html/static/css
AgeCommit message (Collapse)AuthorLines
2023-12-15Rollup merge of #115660 - notriddle:notriddle/sidebar-resize, r=GuillaumeGomezGuillaume Gomez-10/+167
rustdoc: allow resizing the sidebar / hiding the top bar Fixes #97306 Preview: http://notriddle.com/rustdoc-html-demo-4/sidebar-resize/std/index.html ![image](https://github.com/rust-lang/rust/assets/1593513/a2f40ea2-0436-4e44-99e8-d160dab2a680) ## Summary This feature adds: 1. A checkbox to the Settings popover to hide the persistent navigation bar (the sidebar on large viewports and the top bar on small ones). 2. On large viewports, it adds a resize handle to the persistent sidebar. Resizing it into nothing is equivalent to turning off the persistent navigation bar checkbox in Settings. 3. If the navigation bar is hidden, a toolbar button to the left of the search appears. Clicking it brings the navigation bar back. ## Motivation While "mobile mode" is definitely a good default, it's not the only reason people have wanted to hide the sidebar: * Some people use tiling window managers, and don't like rustdoc's current breakpoints. Changing the breakpoints might help with that, but there's no perfect solution, because there's a gap between "huge screen" and "smartphone" where reasonable people can disagree about whether it makes sense for the sidebar to be on-screen. https://github.com/rust-lang/rust/issues/97306 * Some people ask for ways to reduce on-screen clutter because it makes it easier to focus. There's not a media query for that (and if there was, privacy-conscious users would turn it off). https://github.com/rust-lang/rust/issues/59829 This feature is designed to avoid these problems. Resizing the sidebar especially helps, because it provides a way to hide the sidebar without adding a new top-level button (which would add clutter), and it provides a way to make rustdoc play nicer in complex, custom screen layouts. ## Guide and Reference-level explanation On a desktop or laptop with a mouse, resize the sidebar by dragging its right edge. On any browser, including mobile phones, the sticky top bar or side bar can be hidden from the Settings area (the button with the cog wheel, next to the search bar). When it's hidden, a convenient button will appear on the search bar's left. ## Drawbacks This adds more JavaScript code to the render blocking area. ## Rationale and alternatives The most obvious way to allow people to hide the sidebar would have been to let them "manually enter mobile mode." The upside is that it's a feature we already have. The downside is that it's actually really hard to come up with a terse description. Is it: * A Setting that forces desktop viewers to always have the mobile-style top bar? If so, how do we label it? Should it be visible on mobile, and, if so, does it just not do anything? * A persistent hide/show sidebar button, present on desktop, just like on mobile? That's clutter that I'd like to avoid. ## Prior art * The new file browser in GitHub uses a similar divider with a mouse-over indicator * mdBook and macOS Finder both allow you to resize the sidebar to nothing as a gesture to hide it * https://www.nngroup.com/articles/drag-drop/ ## Future possibilities https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Table.20of.20contents proposes a new, second sidebar (a table of contents). How should it fit in with this feature? Should it be resizeable? Hideable? Can it be accessed on mobile?
2023-12-07Fix display of features in rustdocGuillaume Gomez-9/+12
2023-11-30rustdoc: `div.where` instead of fmt-newline classMichael Howell-5/+2
This is about equally readable, a lot more terse, and stops special-casing functions and methods. ```console $ du -hs doc-old/ doc-new/ 671M doc-old/ 670M doc-new/ ```
2023-11-29rustdoc: remove small from `small-section-header`Michael Howell-5/+5
There's no such thing as a big section header, so I don't know why the name was used.
2023-10-23Rollup merge of #105666 - notriddle:notriddle/stab-baseline, r=GuillaumeGomezMatthias Krüger-0/+1
rustdoc: align stability badge to baseline instead of bottom | desc | img | |------|-----| | before | ![image](https://user-images.githubusercontent.com/1593513/207412598-3a6468ca-a169-4810-a689-4797688385df.png) | | | | | after | ![image](https://user-images.githubusercontent.com/1593513/207412720-b120269a-48a3-40e9-a9b0-6769bb05e104.png) | Preview: http://notriddle.com/notriddle-rustdoc-demos/stab-baseline/test_dingus/index.html Based on comment from https://github.com/rust-lang/rust/pull/105509#discussion_r1044816673 r? ``@joshtriplett``
2023-10-11rustdoc: avoid whole page layout on each frameMichael Howell-4/+14
This makes two changes, based on experimenting with different browsers: - It debounces resizing the body text. This improves behavior on huge pages like struct.Vec.html, because it doesn't have to do layout. - It does the sidebar width updates directly on the sidebar instead of doing it on the `<HTML>` element. Doing it on `<HTML>` causes it to recalculate CSS for the entire document, also causing layout jank.
2023-10-11rustdoc: bundle sidebar button icon into CSSMichael Howell-1/+22
This removes an HTTP request from the loading pipeline, and allows it to be changed with a media query.
2023-10-11rustdoc: enforce BODY_MIN constraint on sidebar resizeMichael Howell-7/+12
2023-10-11rustdoc: allow resizing the sidebarMichael Howell-8/+129
2023-10-08Clean up subversion layoutMichael Howell-0/+5
2023-10-08rustdoc: clean up the In [name] up-pointerMichael Howell-1/+1
This commit makes three changes for consistency and readability: - It shows the sibling navigation on module pages. It's weird that it didn't work before, and is inconsistent with everything else (even Crates have sibling navigation with other Crates). - It hides the "In [parent]" header if it's the same as the current crate, and if there's no other header between them. We need to keep it on modules and types, since they have their own header and data between them, and we don't want to show siblings under a header implying that they're children. - It adds a margin to deal with the headers butting directly into the branding lockup.
2023-10-08rustdoc: align crate name with search barMichael Howell-5/+27
Based on PR feedback.
2023-10-08rustdoc: remove rust logo from non-Rust cratesMichael Howell-2/+3
2023-10-08rustdoc: clean up the layout for annotated version numbersMichael Howell-0/+1
This should result in a layout for the actual standard library, when built on CI, that looks like this: _____ / \ std | R | 1.74.0-nightly \_____/ (203c57dbe 2023-09-17) Having the whole version as one string caused it to flex wrap, because the sidebar isn't wide enough to fit the whole thing.
2023-10-08rustdoc: show crate name beside small logoMichael Howell-12/+45
This commit changes the layout to something a bit less "look at my logo!!!111" gigantic, and makes it clearer where clicking the logo will actually take you. It also means the crate name is persistently at the top of the sidebar, even when in a sub-item page, and clicking that name takes you back to the root. | | Short crate name | Long crate name | |---------|------------------|-----------------| | Root | ![short-root] | ![long-root] | Subpage | ![short-subpage] | ![long-subpage] [short-root]: https://github.com/rust-lang/rust/assets/1593513/fe2ce102-d4b8-44e6-9f7b-68636a907f56 [short-subpage]: https://github.com/rust-lang/rust/assets/1593513/29501663-56c0-4151-b7de-d2637e167125 [long-root]: https://github.com/rust-lang/rust/assets/1593513/f6a385c0-b4c5-4a9c-954b-21b38de4192f [long-subpage]: https://github.com/rust-lang/rust/assets/1593513/97ec47b4-61bf-4ebe-b461-0d2187b8c6ca https://notriddle.com/rustdoc-html-demo-4/logo-lockup/image/index.html https://notriddle.com/rustdoc-html-demo-4/logo-lockup/crossbeam_channel/index.html https://notriddle.com/rustdoc-html-demo-4/logo-lockup/adler/struct.Adler32.html https://notriddle.com/rustdoc-html-demo-4/logo-lockup/crossbeam_channel/struct.Sender.html This improves visual information density (the construct with the logo and crate name is *shorter* than the logo on its own, because it's not square) and navigation clarity (we can now see what clicking the Rust logo does, specifically). Compare this with the layout at [Phoenix's Hexdocs] (which is what this proposal is closely based on), the old proposal on [Internals Discourse] (which always says "Rust standard library" in the sidebar, but doesn't do the side-by-side layout). [Phoenix's Hexdocs]: https://hexdocs.pm/phoenix/1.7.7/overview.html [Internals Discourse]: https://internals.rust-lang.org/t/poc-of-a-new-design-for-the-generated-rustdoc/11018 In newer versions of rustdoc, the crate name and version are always shown in the sidebar, even in subpages. Clicking the crate name does the same thing clicking the logo always did: return you to the crate root. While this actually takes up less screen real estate than the old layout on desktop, it takes up more HTML. It's also a bit more visually complex. I could do what the Internals POC did and keep the vertically stacked layout all the time, instead of doing a horizontal stack where possible. It would take up more screen real estate, though. This design is lifted almost verbatim from Hexdocs. It seems to work for them. [`opentelemetry_process_propagator`], for example, has a long application name. [`opentelemetry_process_propagator`]: https://hexdocs.pm/opentelemetry_process_propagator/OpentelemetryProcessPropagator.html Has anyone written the rationale on why the Rust logo shows up on projects that aren't the standard library? If we turned it off on non-standard crates by default, it would line wrap crate names a lot less often. Or maybe we should encourage crate authors to include their own logo more often? It certainly helps give people a better sense of "place." I'm not sure of anything that directly follows up this one. Plenty of other changes could be made to improve the layout, like * coming up with a less cluttered way to do disclosure (there's a lot of `[-]` on the page) * doing a better job of separating lateral navigation (vec::Vec links to vec::IntoIter) and the table of contents (vec::Vec links to vec::Vec::new) * giving readers more control of how much rustdoc hows them, and giving doc authors more control of how much it generates * better search that reduces the need to browse But those are mostly orthogonal, not future possibilities unlocked by this change.
2023-09-19rustdoc: add test cases, and fix, search tabsMichael Howell-4/+8
2023-09-15rustdoc: merge theme css into rustdoc.cssMichael Howell-382/+623
Based on https://github.com/rust-lang/rust/pull/115812#issuecomment-1717960119 Having them in separate files used to make more sense, before the migration to CSS variables made the theme files as small as they are nowadays. This is already how docs.rs and mdBook do it.
2023-09-13Merge settings.css into rustdoc.cssGuillaume Gomez-63/+64
2023-08-27Unify CSS color formats a bit moreGuillaume Gomez-14/+14
2023-08-14Add warning block support in rustdocGuillaume Gomez-3/+26
2023-08-04Use similar color scheme to make it obvious they are linkedGuillaume Gomez-2/+2
2023-07-31rustdoc: align stability badge to baseline instead of bottomMichael Howell-0/+1
r? @joshtripplet
2023-07-20Remove adjustments that used to be necessary for search's crate selector ↵Frank Steffahn-9/+0
appearance (padding) to look identical on Firefox. New versions of Firefox appear to have changed behavior to agree with Chrome.
2023-07-18Fix display of aliases in rustdoc search resultsGuillaume Gomez-1/+4
2023-07-14rustdoc: use `src` consistently over `source` in JavaScriptMichael Howell-1/+1
Since the directory that contains source files is called `src`, it makes sense to name the scripts that way, too.
2023-07-14rustdoc: use `src` consistently over `source` in codeMichael Howell-41/+41
The CSS uses an inconsistent mix of both. This commit switches it to always use `src`.
2023-07-03Fix display of long inline cfg labelsGuillaume Gomez-3/+3
2023-06-28Fix display of long items in search resultsGuillaume Gomez-6/+24
2023-06-23Reduce typename width to 6.25remNoah Lev-1/+1
This makes "existential type" look slightly cramped (though still readable), but it makes all other typenames look better. Existential types are currently very rare, and we can always tweak this later if necessary.
2023-06-23Make typenames a bit wider to support "existential type"Noah Lev-1/+1
2023-06-22Align search results horizontally for easy scanningNoah Lev-0/+2
The recent PR #110688 added info about an item's kind before its name in search results. However, because the kind and name are inline with no alignment, it's now hard to visually scan downward through the search results, looking at item names. This PR fixes that by horizontally aligning search results such that there are now two columns of information.
2023-06-19rustdoc: js: change color and reduce size of typename in search resultAlexis (Poliorcetics) Bourget-0/+4
2023-06-03Move type name directly into the same DOM elementGuillaume Gomez-13/+0
2023-06-02Improve new search result display on mobileGuillaume Gomez-0/+8
2023-06-02Move item kind before the item nameGuillaume Gomez-0/+5
2023-06-02Add search result item types after their nameGuillaume Gomez-2/+2
2023-05-23rustdoc: add hover indicator for notable trait tooltipMichael Howell-0/+4
2023-05-23rustdoc: add interaction delays for tooltip popoversMichael Howell-0/+8
Designing a good hover microinteraction is a matter of guessing user intent from what are, literally, vague gestures. In this case, guessing if hovering in our out of the tooltip base is intentional or not. To figure this out, a few different techniques are used: * When the mouse pointer enters a tooltip anchor point, its hitbox is grown on the bottom, where the popover is/will appear. This was already there before this commit: search "hover tunnel" in rustdoc.css for the implementation. * This commit adds a delay when the mouse pointer enters the base anchor, in case the mouse pointer was just passing through and the user didn't want to open it. * This commit also adds a delay when the mouse pointer exits the tooltip's base anchor or its popover, before hiding it. * A fade-out animation is layered onto the pointer exit delay to immediately inform the user that they successfully dismissed the popover, while still providing a way for them to cancel it if it was a mistake and they still wanted to interact with it. * No animation is used for revealing it, because we don't want people to try to interact with an element while it's in the middle of fading in: either they're allowed to interact with it while it's fading in, meaning it can't serve as mistake- proofing for opening the popover, or they can't, but they might try and be frustrated. See also: * https://www.nngroup.com/articles/timing-exposing-content/ * https://www.nngroup.com/articles/tooltip-guidelines/ * https://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown
2023-05-22rustdoc: remove unneeded `position: relative` setting CSSMichael Howell-1/+0
This was added to control percentage sizes, in 79956b96e875e6ba2bfa551fabda6b7896f988ac Now, the only percentage size is [`border-radius`], which is based on the size of the box itself, not its containing block. This leaves the property unused. [`border-radius`]: https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius
2023-05-22rustdoc: merge identical CSS rulesMichael Howell-5/+3
2023-05-03Rollup merge of #110371 - notriddle:notriddle/search-corrections, ↵Manish Goregaokar-0/+4
r=GuillaumeGomez rustdoc: restructure type search engine to pick-and-use IDs Fixes #110029 Preview: https://notriddle.com/rustdoc-demo-html-3/search-corrections/std/index.html?search=-%3E%20streaming ![image](https://user-images.githubusercontent.com/1593513/233494900-ae77d5b4-e395-41f8-bbac-53ee55bb4a76.png) This change makes it so, instead of mixing string distance with type unification, function signature search works by mapping names to IDs at the start, reporting to the user any cases where it had to make corrections, and then matches with IDs when going through the items. This only changes function searches. Name searches are left alone, and corrections are only done when there's a single item in the search query.
2023-04-21rustdoc: remove unused CSS `color: inherit`Michael Howell-1/+0
This code was added back when `border-color: currentColor` was used. Since it was changed in ad9a89eef2857a24ef049b9eee2d1db5bcbf1d11, the current color is not used any more.
2023-04-17rustdoc: restructure type search engine to pick-and-use IDsMichael Howell-0/+4
This change makes it so, instead of mixing string distance with type unification, function signature search works by mapping names to IDs at the start, reporting to the user any cases where it had to make corrections, and then matches with IDs when going through the items. This only changes function searches. Name searches are left alone, and corrections are only done when there's a single item in the search query.
2023-04-12Rollup merge of #110205 - notriddle:notriddle/pixelated-border, r=GuillaumeGomezMatthias Krüger-1/+5
rustdoc: make settings radio and checks thicker, less contrast This is very dependent on subjectivity and what screen you use, but this change makes the radio buttons' outer circle less ugly. This is because I could see the pixels very clearly, thanks to the very thin line and high contrast. This change makes both less severe, giving your browser's antialiasing algorithm more to work with. Since it's thicker, lowering the contrast shouldn't impact visibility. ## Preview https://notriddle.com/rustdoc-demo-html-3/pixelated-border/settings.html ## Before ![image](https://user-images.githubusercontent.com/1593513/231274191-143acbea-c433-4fb1-b46d-e5e4fe328d60.png) ## After ![image](https://user-images.githubusercontent.com/1593513/231287415-c1e59fe8-8bf8-489d-b607-95ebb71e4ac5.png) <details><summary>Original "after" image with 2px border around checked box</summary> ![image](https://user-images.githubusercontent.com/1593513/231274253-8b5011c6-82fb-4396-84d0-47b6bdff2260.png) </details>
2023-04-12rustdoc: use CSS `overscroll-behavior` instead of JavaScriptMichael Howell-1/+2
Fixes the desktop scrolling weirdness mentioned in https://github.com/rust-lang/rust/pull/98775#issuecomment-1182575603 As described in the MDN page for this property: * The current Firefox ESR is 102, and the first Firefox version to support this feature is 59. * The current Chrome version 112, and the first version to support this is 63. * Edge is described as having a minor bug in `none` mode, but we use `contain` mode anyway, so it doesn't matter. * Safari 16, released September 2022, is the last browser to add this feature, and is also the oldest version we officially support.
2023-04-12rustdoc: make settings radio and checks thicker, less contrastMichael Howell-1/+5
This is very dependent on subjectivity and what screen you use, but this change makes the radio buttons' outer circle less ugly. This is because I could see the pixels very clearly, thanks to the very thin line and high contrast. This change makes both less severe, giving your browser's antialiasing algorithm more to work with. Since it's thicker, lowering the contrast shouldn't impact visibility.
2023-04-06Rollup merge of #109977 - notriddle:notriddle/data-nosnippet, r=jsha,the8472Matthias Krüger-7/+7
rustdoc: avoid including line numbers in Google SERP snippets ![image](https://user-images.githubusercontent.com/1593513/230141184-9171c8e0-de92-48e6-85b6-8baee35e6d86.png)
2023-04-05rustdoc: avoid including line numbers in Google SERP snippetsMichael Howell-7/+7
2023-04-05Improve display of logo on very small screensGuillaume Gomez-1/+6
2023-04-04Move scrollbar on the <main> element rather than only on the code block to ↵Guillaume Gomez-0/+4
improve UX