Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pick themes on settings page, not every page #92629

Merged
merged 2 commits into from
Jan 18, 2022

Conversation

jsha
Copy link
Contributor

@jsha jsha commented Jan 6, 2022

This hides the paintbrush icon on most pages by default, in preference for the settings on the settings page. When loading from a local file, and not in mobile view, continue to show the theme picker. That's because some browsers limit access to localStorage from file:/// URLs, so choosing a theme from settings.html doesn't take effect.

Fixes #84539
Part of #59840

r? @GuillaumeGomez

Demo: https://rustdoc.crud.net/jsha/theme-picker-local-only-2/std/io/trait.Read.html

@jsha jsha added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-rustdoc-ui Area: Rustdoc UI (generated HTML) labels Jan 6, 2022
@rust-highfive
Copy link
Collaborator

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez,@Folyd

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 6, 2022
@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member

GuillaumeGomez commented Jan 7, 2022

It's not appearing on the settings page either:

Screenshot from 2022-01-07 21-51-47

Also, on the settings page I would not put it alongside the sidebar but above all other parameters so it has more space. What do you think?

@jsha
Copy link
Contributor Author

jsha commented Jan 7, 2022

My thought was that people would use the "preferred dark theme" / "preferred light theme". But we also need something on the settings page for when "Use system theme" is off. I'll work on that.

@jsha jsha force-pushed the theme-picker-local-only-2 branch from 1e1b20a to 9bbf017 Compare January 7, 2022 23:21
@jsha
Copy link
Contributor Author

jsha commented Jan 7, 2022

Ok, updated the settings page too.

@rust-log-analyzer

This comment has been minimized.

@notriddle
Copy link
Contributor

and I discussed via PM on Zulip, and came to a compromise solution: We'll show the theme picker icon only when visiting a file:/// URL. That way we get a nice uncluttered UI on doc.rust-lang.org and docs.rs, but we don't lose the theme-picking functionality on local files.

Showing the paintbrush icon on file URLs, while not showing it on http URLs, is definitely a compromise, but it doesn't sound like a very good idea.

  • You're making the theming functionality more prominent in exactly the situations where it's less useful. This is the opposite of good design: since the functionality is broken, rustdoc should hide it.
  • The code for rendering that drop down menu is getting served to people who won't actually be running it, on the WWW, the situation where avoiding bloat is the most important.
  • If someone looks at the docs on their local machine, and sees that button, then uploads the docs to a web server and the button goes away, they're going to think it's a bug. Self-served docs aren't exceptionally common, but bigger projects like gtk and rocket, as well as many proprietary software shops, do self-host their own rustdocs.

@GuillaumeGomez
Copy link
Member

GuillaumeGomez commented Jan 8, 2022

"preferred theme" seems weirdly worded to me. Also, when changing its value, it doesn't change the current theme.

@notriddle: Interestingly enough, you have the exact opposite logic that we used. When on a website, you only need to change it once to get it applied correctly on all the pages whereas it's not the case for local docs (hence why we keep it there).

The code for rendering that drop down menu is getting served to people who won't actually be running it, on the WWW, the situation where avoiding bloat is the most important.

I'm not sure to see how much of an issue it is. Could you elaborate a bit more?

If someone looks at the docs on their local machine, and sees that button, then uploads the docs to a web server and the button goes away, they're going to think it's a bug. Self-served docs aren't exceptionally common, but bigger projects like gtk and rocket, as well as many proprietary software shops, do self-host their own rustdocs.

I agree that it's not the best. The idea is to reduce the number of buttons we have because they're distracting (@jsha received complains about it iirc) when it's not really necessary (because again, on a website you only need to change it once).

An alternative would be for the settings to be 100% JS and therefore to have access to it on all pages, allowing us to remove tje theme button on all pages. But that bring other issues.

@notriddle
Copy link
Contributor

When on a website, you only need to change it once to get it applied correctly on all the pages whereas it's not the case for local docs (hence why we keep it there).

If the theme gets “randomly” reverted when you switch pages, is the functionality really useful? Blinding white flashes in dark mode can be pretty uncomfortable.

Personally, I stopped setting rustdoc themes, exactly because it doesn’t really work.

I'm not sure to see how much of an issue it is. Could you elaborate a bit more?

Since the image is only hidden by CSS, the SVG file still gets downloaded. There’s also quite a bit of CSS and JavaScript used to implement that control, since it’s currently the only JavaScript-based drop-down in all of rustdoc. If it was removed, all that code could go away, or be migrated to settings.js and not get loaded by default.

@bors
Copy link
Contributor

bors commented Jan 13, 2022

☔ The latest upstream changes (presumably #92526) made this pull request unmergeable. Please resolve the merge conflicts.

@jsha jsha force-pushed the theme-picker-local-only-2 branch from 9bbf017 to 31e7f23 Compare January 13, 2022 17:25
@rust-log-analyzer

This comment has been minimized.

This hides the paintbrush icon on most pages by default, in preference
for the settings on the settings page.  When loading from a local file,
and not in mobile view, continue to show the theme picker. That's
because some browsers limit access to localStorage from file:/// URLs,
so choosing a theme from settings.html doesn't take effect.
@jsha jsha force-pushed the theme-picker-local-only-2 branch from 31e7f23 to 692f9b6 Compare January 15, 2022 02:36
@rust-log-analyzer

This comment has been minimized.

@jsha jsha force-pushed the theme-picker-local-only-2 branch from 692f9b6 to 04f0402 Compare January 15, 2022 03:33
@GuillaumeGomez
Copy link
Member

The display of the setting of the theme selection is still not great. Do you have an idea on how improve it? (If you have ideas for the whole setting page, go ahead! :D )

@jsha
Copy link
Contributor Author

jsha commented Jan 17, 2022

The display of the setting of the theme selection is still not great. Do you have an idea on how improve it? (If you have ideas for the whole setting page, go ahead! :D )

I have some ideas about improving the design of the settings page in general, but I don't think they should block progress on this issue. The goal of the settings change in this PR is to make sure the settings page has the same features as the paintbrush, so we can remove the paintbrush in most cases. The design is the same as it is on https://doc.rust-lang.org/nightly/settings.html.

@GuillaumeGomez
Copy link
Member

As discussed on zulip, since settings are only useful for users with JS enabled, I'll move the settings into full JS. Thanks @jsha!

@bors: r+ rollup

@bors
Copy link
Contributor

bors commented Jan 17, 2022

📌 Commit 04f0402 has been approved by GuillaumeGomez

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 17, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 18, 2022
…askrgr

Rollup of 14 pull requests

Successful merges:

 - rust-lang#92629 (Pick themes on settings page, not every page)
 - rust-lang#92640 (Fix ICEs related to `Deref<Target=[T; N]>` on newtypes)
 - rust-lang#92701 (Add some more attribute validation)
 - rust-lang#92803 (Hide mobile sidebar on some clicks)
 - rust-lang#92830 (Rustdoc style cleanups)
 - rust-lang#92866 ("Does exists" typos fix)
 - rust-lang#92870 (add `rustc_diagnostic_item` attribute to `AtomicBool` type)
 - rust-lang#92914 (htmldocck: Add support for `/text()` in ``@snapshot`)`
 - rust-lang#92923 (Abstract the pretty printer's ringbuffer to be infinitely sized)
 - rust-lang#92946 (Exclude llvm-libunwind from the self-contained set on s390x-musl targets)
 - rust-lang#92947 (rustdoc: Use `intersperse` in a `visit_path` function)
 - rust-lang#92997 (Add `~const` bound test for negative impls)
 - rust-lang#93004 (update codegen test for LLVM 14)
 - rust-lang#93016 (Stabilize vec_spare_capacity)

Failed merges:

 - rust-lang#92924 (Delete pretty printer tracing)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit d501ead into rust-lang:master Jan 18, 2022
@rustbot rustbot added this to the 1.60.0 milestone Jan 18, 2022
@jsha jsha deleted the theme-picker-local-only-2 branch January 18, 2022 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rustdoc: clarify theme settings
7 participants