rustdoc: support separate dark theme logo in html_logo_url - #160352
rustdoc: support separate dark theme logo in html_logo_url#160352im-lunex wants to merge 5 commits into
html_logo_url#160352Conversation
|
Some changes occurred in compiler/rustc_attr_parsing cc @jdonszelmann, @JonathanBrouwer Some changes occurred in HTML/CSS/JS. cc @GuillaumeGomez, @lolbinarycat Some changes occurred in GUI tests. Some changes occurred in compiler/rustc_hir/src/attrs |
|
Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @JonathanBrouwer (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
Why was this reviewer chosen?The reviewer was selected based on:
|
|
I used a |
|
r? rustdoc |
This comment has been minimized.
This comment has been minimized.
| @@ -0,0 +1,7 @@ | |||
| # This file is automatically @generated by Cargo. | |||
There was a problem hiding this comment.
You can remove this file.
There was a problem hiding this comment.
removing this file make it fail the tests.. soo keeping it for now.
|
Overall, not too sure what to think about this feature... You can tweak the logo display with CSS so not sure having an attribute option for it is a good idea. Anyway, what do you think @rust-lang/rustdoc-frontend ? |
i think having an attribute will be helpful cause here everything lives in one single file. still will love you hear what do you think ? |
This comment has been minimized.
This comment has been minimized.
|
The ideal way to do this is SVG logo using the Rustdoc doesn't currently support this, because it doesn't work in all of our supported browsers. It works now, in Chrome and Firefox, but SVG's don't inherit their preferred color scheme from the containing page's used color scheme in Safari, so our JS-based theme switcher can't control the color scheme of an SVG logo. Sigh. You can test this out in your own browser by visiting https://notriddle.com/test-color-scheme-code/. The actual code is at https://github.com/notriddle/test-color-scheme-code/. |
|
Thanks for the context. but the problem with using a single SVG plus Because embedded SVGs with So beyond Safari’s bug relying on one SVG with so what do you think should we keep moving forward with this? |
The fix for that would be three lines of code, not including tests.
We should move forward with this CSS-based fix. |
|
that color-scheme fix makes sense and it covers crates with SVG logos that already handle prefers-color-scheme on chrome and firefox. before we settle on it though, a couple quick things to point out:
basically, this fix only solves SVG logos on chrome and firefox, not logos overall. are we okay with leaving raster logos without a fix, i think for that the attribute fix could be better. |
|
@notriddle has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
|
I won't raise a formal concern since I don't feel strongly enough to block, but as mentioned above, I'm opposed to having theme-related settings (like light and dark variants) embedded into source code via attributes. It just feels like a mixing of concerns. @notriddle I'm also confused since you said we should go ahead with the CSS-based approach but then also started FCP for this attribute approach. Could you explain a bit more? |
|
This attribute-based approach is CSS-based. Sorry if I was confusing everyone. I am in favor of the approach taken by this PR, because it works in Safari, unlike the SVG-based approach. |
|
A full CSS approach is also possible, without requiring a change in the attribute. You use |
|
@GuillaumeGomez good call on the pure css swap. that definitely solves the safari and raster image issues. but there are the gaps:
how do you wanna handle the url passing and a11y stuff here? |
Just like how we handle the theme: :root[data-theme="dark"] .sidebar .logo-container {
background-image: ...;
}
:root[data-theme="dark"] .sidebar .logo-container > img {
/* Hide the original/light theme image eventually so we can put the background-image instead?
If you do that, don't forget to give a height and width to the logo-container element. */
display: none;
}You can add custom CSS with Fair. We could move/duplicate the |
|
@GuillaumeGomez the
|
|
Oh apparently you can use :root[data-theme="dark"] .sidebar .logo-container > img {
content: url("<path to image>");
}Wouldn't that solve all listed issues? |
|
There are a list of alternatives listed here. I like the one about the border too: .myClass {
border: solid;
border-width: 0 480px 320px 0;
border-image: url("http://i.imgur.com/uKnMvyp.jpg") 0 100% 100% 0;
} |
|
@GuillaumeGomez Thanks for looking into it
this one is nice and apparently fixes the issue but im not that sure of this one cause this dosnt yet fix the a11y issue. also this i dont know if im being annoying or not but (https://developer.mozilla.org/en-US/docs/Web/Security/Defenses/Mixed_content) this might help see the chart given at the bottom. |
|
Well, the border trick should work for all cases, no? |
not sure, we should test it out in safari(cause according to online things safari always had issues with
plus its a lots of extra works for the authors to write those rare CSS properties... cuz i dont think they will love using those & tuning the size things for ratio conflicts? for context:
some of those maybe fixed not sure |
That's where I'm confused. What a11y issue(s) there would be? The |
|
Also, beyond the potential Safari quirks with (Side note: never mind and let me know if Im missing something obvious or getting details wrong here still learning and not much experienced about it and just trying to make sure the outcome is perfect. and thanks for putting a lot of time on this PR appreciate it) |
soo the thing is that we dont get the
when we use the |
|
That's not a11y though, that's UX. |
sorry my bad... |
|
So yeah, the usual issue: a11y vs UX vs UI. If CSS was more powerful, we would live in a perfect world I guess. :') |
yeah fr.. hahhh what if we could say 'less rewrite CSS in rust'. dream world |
|
It's done already, called One of the very first "real world" Rust projects. |
in this cursed world a thing like this is soo dymn underrated when i searched |
|
"stylo" means pencil in french. So now guess why this project name was picked. ;) |
the guy who named it knew some random Pakistani best ladies shoes brand gonna replace it.. great thing btw but this one lost to fate.. |
|
The HTML5 |
exactly. could be a good idea, but PreferenceManager is experimental/behind-a-flag, so its not something rustdoc can ship on today across Chrome/Firefox/Safari. also this one will still keep the same fundamental issue that was with the previous SVG approch... |
|
@GuillaumeGomez @notriddle soo any decision ? what we gonna do about it. the attribute approach gives the best outcome till now... |
|
I personally don't think it's worth extending the attribute for that. It's now up to the rest of the team. Also, this kind of decision happens over weeks, not days. So no need to ping this often. |
View all comments
Currently
html_logo_urlonly accepts a single logo, which is shown in allthemes. This adds a new list form so crates can use a different logo for the
dark (and ayu) themes:
#![doc(html_logo_url(light = "logo-light.png", dark = "logo-dark.png"))]The old form still works and is unchanged.
The
lightvalue is required,darkis optional and falls back tolight.A lint is emitted if the list form is missing
light.Changes:
LogoUrlsstruct)has-dark-logoclass and twoimgs, CSS swaps by themenoscript.csscovers the no-JSprefers-color-schemefallbackrustdoc-ui (missing
lighterror)issue: #160316