2021-07-15 15:12:28 -05:00
|
|
|
// This test ensure that the sidebar isn't "hidden" on mobile but instead moved out of the viewport.
|
|
|
|
// This is especially important for devices for "text-first" content (like for users with
|
|
|
|
// sight issues).
|
2023-04-11 12:11:34 -05:00
|
|
|
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
|
2021-07-15 15:12:28 -05:00
|
|
|
// Switching to "mobile view" by reducing the width to 600px.
|
2023-04-11 12:11:34 -05:00
|
|
|
set-window-size: (600, 600)
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-06 18:48:24 -06:00
|
|
|
assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
|
2021-07-15 15:12:28 -05:00
|
|
|
// Opening the sidebar menu.
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-06 18:48:24 -06:00
|
|
|
click: ".sidebar-menu-toggle"
|
|
|
|
assert-css: (".sidebar", {"display": "block", "left": "0px"})
|
2021-07-16 10:04:49 -05:00
|
|
|
// Closing the sidebar menu.
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-06 18:48:24 -06:00
|
|
|
click: ".sidebar-menu-toggle"
|
|
|
|
assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
|
2021-07-16 10:04:49 -05:00
|
|
|
// Force the sidebar open by focusing a link inside it.
|
|
|
|
// This makes it easier for keyboard users to get to it.
|
2022-10-15 13:53:47 -05:00
|
|
|
focus: ".sidebar-elems h3 a"
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-06 18:48:24 -06:00
|
|
|
assert-css: (".sidebar", {"display": "block", "left": "0px"})
|
2021-07-16 10:04:49 -05:00
|
|
|
// When we tab out of the sidebar, close it.
|
|
|
|
focus: ".search-input"
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-06 18:48:24 -06:00
|
|
|
assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
|
2022-01-11 20:27:44 -06:00
|
|
|
|
|
|
|
// Open the sidebar menu.
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-06 18:48:24 -06:00
|
|
|
click: ".sidebar-menu-toggle"
|
|
|
|
assert-css: (".sidebar", {"left": "0px"})
|
2022-01-11 20:27:44 -06:00
|
|
|
|
2022-10-18 13:14:01 -05:00
|
|
|
// Make sure the "struct Foo" header is hidden, since the mobile topbar already does it.
|
|
|
|
assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[text()='Foo']/parent::h2", {"display": "none"})
|
|
|
|
// Make sure the global navigation is still here.
|
2023-09-23 14:59:58 -05:00
|
|
|
assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[text()='In crate test_docs']/parent::h2", {"display": "block"})
|
2022-10-18 13:14:01 -05:00
|
|
|
|
2022-01-11 20:27:44 -06:00
|
|
|
// Click elsewhere.
|
|
|
|
click: "body"
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-06 18:48:24 -06:00
|
|
|
assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
|
|
|
|
|
rustdoc: improve popover focus handling JS
This commit fixes a few inconsistencies and erratic behavior from the
notable traits, settings, and sidebar popups:
* It makes it so that pressing Escape closes the mobile sidebar.
This is a bit difficult to do on iPhone, but on other setups like
desktop tiling window managers, it's easy and makes sense.
* It makes sure that pressing escape while a notable trait popover is
open focuses the popover's toggle button, instead of leaving nothing
focused, since that makes more sense with keyboard navigation. Clicking
the settings, help, or sidebar buttons, however, will not focus the
notable trait popover toggle button.
* It ensures that notable trait and settings popovers are exclusive
with the mobile sidebar. Nothing should ever overlap a popover, and
there should never be more than one popover open at once.
2022-11-26 10:52:58 -06:00
|
|
|
// Open the sidebar menu, and make sure pressing Escape closes it.
|
|
|
|
click: ".sidebar-menu-toggle"
|
|
|
|
assert-css: (".sidebar", {"left": "0px"})
|
|
|
|
press-key: "Escape"
|
|
|
|
assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
|
|
|
|
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-06 18:48:24 -06:00
|
|
|
// Check that the topbar is visible
|
|
|
|
assert-property: (".mobile-topbar", {"clientHeight": "45"})
|
2022-01-19 00:05:17 -06:00
|
|
|
|
|
|
|
// Check that clicking an element from the sidebar scrolls to the right place
|
|
|
|
// so the target is not obscured by the topbar.
|
|
|
|
click: ".sidebar-menu-toggle"
|
2022-02-08 10:05:00 -06:00
|
|
|
click: ".sidebar-elems section .block li > a"
|
2023-02-12 13:27:40 -06:00
|
|
|
assert-position: ("#method\.must_use", {"y": 46})
|
2022-01-21 19:44:54 -06:00
|
|
|
|
|
|
|
// Check that the bottom-most item on the sidebar menu can be scrolled fully into view.
|
|
|
|
click: ".sidebar-menu-toggle"
|
|
|
|
scroll-to: ".block.keyword li:nth-child(1)"
|
rustdoc: show crate name beside small logo
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-18 13:59:49 -05:00
|
|
|
compare-elements-position-near: (".block.keyword li:nth-child(1)", ".mobile-topbar", {"y": 544})
|
2022-07-25 07:35:06 -05:00
|
|
|
|
|
|
|
// Now checking the background color of the sidebar.
|
2022-10-05 04:20:14 -05:00
|
|
|
show-text: true
|
2022-07-25 07:35:06 -05:00
|
|
|
|
2022-11-26 15:35:05 -06:00
|
|
|
define-function: (
|
|
|
|
"check-colors",
|
|
|
|
(theme, color, background),
|
2023-01-06 08:18:51 -06:00
|
|
|
block {
|
2023-04-11 12:11:34 -05:00
|
|
|
set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|}
|
2023-01-06 08:18:51 -06:00
|
|
|
reload:
|
2022-07-25 07:35:06 -05:00
|
|
|
|
2022-11-26 15:35:05 -06:00
|
|
|
// Open the sidebar menu.
|
2023-01-06 08:18:51 -06:00
|
|
|
click: ".sidebar-menu-toggle"
|
|
|
|
assert-css: (".sidebar", {
|
2022-11-26 15:35:05 -06:00
|
|
|
"background-color": |background|,
|
|
|
|
"color": |color|,
|
2023-01-06 08:18:51 -06:00
|
|
|
})
|
|
|
|
},
|
2022-11-26 15:35:05 -06:00
|
|
|
)
|
2022-07-25 07:35:06 -05:00
|
|
|
|
2022-11-26 15:35:05 -06:00
|
|
|
call-function: ("check-colors", {
|
|
|
|
"theme": "ayu",
|
2023-06-04 08:55:30 -05:00
|
|
|
"color": "#c5c5c5",
|
|
|
|
"background": "#14191f",
|
2022-11-26 15:35:05 -06:00
|
|
|
})
|
|
|
|
call-function: ("check-colors", {
|
|
|
|
"theme": "dark",
|
2023-06-04 08:55:30 -05:00
|
|
|
"color": "#ddd",
|
|
|
|
"background": "#505050",
|
2022-11-26 15:35:05 -06:00
|
|
|
})
|
|
|
|
call-function: ("check-colors", {
|
|
|
|
"theme": "light",
|
2023-06-04 08:55:30 -05:00
|
|
|
"color": "black",
|
|
|
|
"background": "#F5F5F5",
|
2022-11-26 15:35:05 -06:00
|
|
|
})
|