summary refs log tree commit diff
path: root/src/librustdoc/html/static/css
AgeCommit message (Collapse)AuthorLines
2024-08-19rustdoc: animate the `:target` highlightMichael Howell-0/+13
This approach is, roughly, based on how Discourse does it. It came up while discussing some other possible sidebar changes, as a design that made rapid scanning easier while avoiding the inherent trade-offs in summarizing.
2024-08-05Unify run button display with "copy code" button and with mdbook buttonsGuillaume Gomez-41/+21
2024-08-03rustdoc: make the hover trail for doc anchors a bit biggerMichael Howell-1/+1
https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/Weird.20markdown.20heading.20rendering.3F
2024-07-30Rollup merge of #128339 - GuillaumeGomez:click-code-example, r=notriddleMatthias Krüger-1/+14
[rustdoc] Make the buttons remain when code example is clicked Follow-up of https://github.com/rust-lang/rust/pull/125779. One current issue we have with "run" button and the newly added copy code button is that if you're on mobile devices, you can't use them. I took a look at how `mdbook` is handling it and when you click on a code example, they show the buttons. I think it's a really good idea as if you want to copy the code on your mobile device, you will click on it, showing the buttons. Feature can be tested [here](https://rustdoc.crud.net/imperio/click-code-example/foo/struct.Bar.html). r? `@notriddle`
2024-07-29Make the buttons remain when code example is clickedGuillaume Gomez-1/+14
2024-07-29rustdoc: properly handle path wrappingMichael Howell-1/+4
2024-07-28Rollup merge of #125779 - GuillaumeGomez:copy-code, r=rustdoc-teamGuillaume Gomez-27/+66
[rustdoc] Add copy code feature This PR adds a "copy code" to code blocks. Since this is a JS only feature, the HTML is generated with JS when the user hovers the code block to prevent generating DOM unless needed. Two things to note: 1. I voluntarily kept the current behaviour of the run button (only when hovering a code block with a mouse) so it doesn't do anything on mobile. I plan to send a follow-up where the buttons would "expandable" or something. Still need to think which approach would be the best. 2. I used a picture and not text like the run button to remain consistent with the "copy path" button. I'd also prefer for the run button to use a picture (like what is used in mdbook) but again, that's something to be discussed later on. The rendering looks like this: ![Screenshot from 2024-06-03 21-29-48](https://github.com/rust-lang/rust/assets/3050060/a0b18f9c-b3dd-4a65-89a7-5a7a303b5c2b) ![Screenshot from 2024-06-03 21-30-20](https://github.com/rust-lang/rust/assets/3050060/b3b084ff-2716-4160-820b-d4774681a961) It can be tested [here](https://guillaume-gomez.fr/rustdoc/bar/struct.Bar.html) (without the run button) and [here](https://guillaume-gomez.fr/rustdoc/foo/struct.Bar.html) (with the run button). Fixes #86851. r? ``@notriddle``
2024-07-21rustdoc: revert spacing change in item-tableMichael Howell-1/+0
It really wasn't necessary for the bug fix, and could reasonably be considered a functional regression.
2024-07-21Rollup merge of #128023 - Kijewski:pr-table-width, r=notriddleJubilee-0/+1
rustdoc: short descriptions cause word-breaks in tables The `.item-table` class is used to display name+description lists, e.g. the exported functions, as a table. If the names are long and the descriptions are short, then the width of the table does not expand to the whole size, but only uses a fraction. This causes a some names to break inside a word. This change makes the table always use 100% of its parent width. The `.width-limiter` wrapper already ensures that the used width still does not become excessive. See e.g. <https://docs.rs/mathlab/0.3.0/mathlab/fun/vec_num/index.html> or <https://docs.rs/cw-events/0.0.9/cw_events/> (random choices out of the list of the recent releases). [![](https://i.imgur.com/XnH4eeT.png)](https://imgur.com/XnH4eeT) [![](https://i.imgur.com/7iQ9xE2.png)](https://imgur.com/7iQ9xE2) The problem occurs (at least) in Firefox 130, Falkon 24, and Konqueror 22. It does not occur in Chrome 126.
2024-07-21rustdoc: short descr. cause word-breaks in tablesRené Kijewski-0/+1
The `.item-table` class is used to display name+description lists, e.g. the exported functions, as a table. If the names are long and the descriptions are short, then the width of the table does not expand to the whole size, but only uses a fraction. This causes a some names to break inside a word. This change makes the table always use 100% of its parent width. The `.width-limiter` wrapper already ensures that the used width still does not become excessive. Signed-off-by: René Kijewski <rene.kijewski@fu-berlin.de>
2024-07-20Fix stab display in doc blocksGuillaume Gomez-0/+4
2024-07-19Rollup merge of #127963 - GuillaumeGomez:fix-logo-display, r=notriddleMatthias Krüger-1/+0
Fix display of logo "border" Before: ![Screenshot from 2024-07-19 13-32-17](https://github.com/user-attachments/assets/381bb9c8-0ae0-408b-8476-9785ef1b5fd4) After: ![Screenshot from 2024-07-19 13-37-46](https://github.com/user-attachments/assets/19cdb71f-3912-4fcd-95de-99b9f86a8293) r? `@notriddle`
2024-07-19Fix display of logo "border"Guillaume Gomez-1/+0
2024-07-18Wrap too long item name and improve the item list display a bitGuillaume Gomez-0/+8
2024-07-18Unify UI between code block buttons and top buttonsGuillaume Gomez-7/+14
2024-07-18Make "copy code" button the same size as the "copy path" buttonGuillaume Gomez-23/+11
2024-07-18Add copy code buttonGuillaume Gomez-19/+63
2024-07-15rustdoc: make sidebar highlight cover whole click targetMichael Howell-2/+41
2024-07-01rustdoc: click target for sidebar items flush leftMichael Howell-4/+12
2024-05-05Fix bad color for setting cog in ayu themeGuillaume Gomez-0/+5
2024-04-28Add some missing comments to describe what the inlined SVG isGuillaume Gomez-0/+4
2024-04-28Inline `wheel.svg` into CSSGuillaume Gomez-1/+14
2024-04-28Inline `clipboard.svg` into CSSGuillaume Gomez-1/+11
2024-04-17Fix copy-path buttonGuillaume Gomez-7/+10
2024-04-09rustdoc: load icons from css instead of inlineMichael Howell-2/+18
This cuts the HTML overhead for a page by about 1KiB, significantly reducing the overall size of the docs bundle.
2024-04-03Default to light theme is JS is enabled but not workingGuillaume Gomez-3/+9
2024-02-18Rollup merge of #120526 - GuillaumeGomez:mobile-long-crate-name, r=notriddleLeón Orell Valerian Liehr-6/+1
rustdoc: Correctly handle long crate names on mobile Fixes https://github.com/rust-lang/rust/issues/120471. It now renders like this: ![image](https://github.com/rust-lang/rust/assets/3050060/065b4b8b-ba55-4163-a928-8d7bf735c111) r? `@notriddle`
2024-01-31rustdoc: Correctly handle long crate names on mobileGuillaume Gomez-6/+1
2024-01-29Improve display of crate name when hoveredGuillaume Gomez-4/+2
2024-01-19Rollup merge of #117662 - GuillaumeGomez:links-in-headings, r=notriddleMatthias Krüger-1/+20
[rustdoc] Allows links in headings Reopening of https://github.com/rust-lang/rust/pull/94360. # Explanations Rustdoc currently doesn't follow the markdown spec on headings: we don't allow links in them. So instead of having headings linking to themselves, this PR generates an anchor on the left side like this: ![image](https://github.com/rust-lang/rust/assets/3050060/a118a7e9-5ef8-4d07-914f-46defc3245c3) <details> <summary>previous version</summary> ![image](https://github.com/rust-lang/rust/assets/3050060/c34fa844-9cd4-47dc-bb51-b37f5f66afee) </details> Having the anchor always displayed allows for mobile devices users to be able to have a link to the anchor. The different color used for the anchor itself is the same as links so people notice when looking at it that they can click on it. You can test it [here](https://rustdoc.crud.net/imperio/links-in-headings/std/index.html). cc `@camelid` r? `@notriddle`
2024-01-01use css variable for z-index of the sidebarLukas Markeffsky-5/+5
and calculate the z-indices of things that go over the sidebar
2023-12-31rustdoc ui: adjust tooltip z-index to be above sidebarLukas Markeffsky-1/+1
2023-12-31Auto merge of #119066 - notriddle:notriddle/sidebar-source-redesign, ↵bors-94/+78
r=GuillaumeGomez rustdoc: clean up source sidebar hide button This is a redesign of the feature, with parts pulled from https://github.com/rust-lang/rust/pull/119049 but with a button that looks more like a button and matches the one used on other sidebar pages. Preview: * http://notriddle.com/rustdoc-html-demo-8/source-sidebar-resize/src/std/lib.rs.html * http://notriddle.com/rustdoc-html-demo-8/source-sidebar-resize/std/index.html | | Before | After | |--|--|--| | Closed | ![image](https://github.com/rust-lang/rust/assets/1593513/092bed75-79c3-412f-8e7b-557f30dfb1e3) | ![image](https://github.com/rust-lang/rust/assets/1593513/b68e1ee9-9aef-484d-a5b1-2fd29c9d72ea) | Open | ![image](https://github.com/rust-lang/rust/assets/1593513/95cf9545-25b1-48ec-820b-02e1aec99839) | ![image](https://github.com/rust-lang/rust/assets/1593513/923532f6-59e0-4d7c-9976-21699c30d42e) | Mobile Closed | ![image](https://github.com/rust-lang/rust/assets/1593513/9bc00cc5-937c-4120-94be-94c7cb6d5297) | ![image](https://github.com/rust-lang/rust/assets/1593513/76a744d8-aac2-46fe-abb9-3b34e2d3ccaa) | Mobile Open | ![image](https://github.com/rust-lang/rust/assets/1593513/d19a94fe-47b1-462d-a280-44fc215b9b72) | ![image](https://github.com/rust-lang/rust/assets/1593513/2b2e3dec-b610-4b12-8a72-35b86359ba45)
2023-12-24Fix display of warning block if it is first element of the top doc blockGuillaume Gomez-0/+3
2023-12-19Fix corner cases when dealing with mobile modeMichael Howell-6/+9
2023-12-18Use folder icon instead of hamburger and sidebarMichael Howell-17/+26
2023-12-18Add border bottom for source sidebar title areaMichael Howell-8/+3
2023-12-18Stop using the trigram of heaven as a hamburger buttonMichael Howell-7/+22
It doesn't look quite right, because the lines are too far apart, and it's not going to be announced by screenreaders as a menu button, since that's not what the symbol means. This adds a real tooltip and uses a better drawing of the icon.
2023-12-18Add back the columnMichael Howell-19/+16
2023-12-17rustdoc: clean up source sidebar hide buttonMichael Howell-87/+52
This is a redesign of the feature, with parts pulled from https://github.com/rust-lang/rust/pull/119049 but with a button that looks more like a button and matches the one used on other sidebar pages.
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-12-05Make headings anchor hidden by default and show on hoverGuillaume Gomez-3/+19
2023-12-05Rework doc blocks headings by not turning them into links anymore and ↵Guillaume Gomez-0/+3
putting an anchor to their left side
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