-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Improve doc theme logo display #74361
Conversation
@@ -61,6 +61,10 @@ pre { | |||
background-color: #14191f; | |||
} | |||
|
|||
.logo-container > img { | |||
filter: drop-shadow(0 0 5px #fff); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have license agreement from @UtherII ? (Is he/she the same person here: https://www.reddit.com/r/rust/comments/hrfi8k/ayu_theme_is_now_available_on_nightly_rustdoc/fy4dzum/ ?).
The POC doesn't have any license files: /~https://github.com/UtherII/poc_rustdoc .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I am. Do you want me to add a comment? It seems a bit too much for just a line of CSS but I can add it... Also, they posted it in a reddit channel, I tested it. So not sure what are the rules in this case too...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a lawyer too. I'm just afraid legal issues when UtherII doesn't explicitly grant us the permissions to copy the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems to be a bit of long stretch considering the code was provided in an open discussion but if someone knows about it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem. You can use it.
I will put a license on my POC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot! Still very interested in what you'll come up with, with your own POC. :)
Also, is |
I think this works great 👍 |
I don't have much experience with front-end things so r? @ollie27 |
https://caniuse.com/#search=drop-shadow So not a bad support, but not the best. However, there doesn't seem to be an older equivalent unfortunately... |
r? @kinnison |
@GuillaumeGomez Is our plan incorporate all the themes from mdbook (light, rust, coal, ayu, navy) here? I personally quite like the themes from mdbook. I personally use rust and coal theme. But still, I do prefer that the browser detects my current theme |
No, it's not scheduled or anything, and I'd prefer to keep the count low if possible. It's quite a lot of maintenance after all... Any change would has to be done in all themes so I'm not too favourable to grow the default rustdoc themes much more than this. However, it can be added either locally or on docs.rs (if they allow it of course, same issue as here). |
An alternative to this would be to provide a white version of the logo in dark color schemes. The SVG for the website's favicon already has CSS embedded inside it to do this, so it should be as simple as using this one instead. You can read rust-lang/www.rust-lang.org#1185 for more info. |
@XAMPPRocky This can't be a solution because crates can provide their own images. You can't expect crates' owners to provide multiple images for one logo, it's just not viable. Adding a contrast allows to remove this issue. |
@GuillaumeGomez I'm not sure I was clear. It's a single SVG file with CSS embedded inside it. |
I think I understood what you meant. 😄 And for example: https://docs.rs/rocket/0.4.5/rocket/ Crates can provide their own logo, replacing the rust logo. This is why I said that we should not expect to get multiple versions of an image, even if it's only CSS/SVG. :) |
Then I guess I don't understand what you mean. A user can already replace the rust logo with their own SVG/CSS logo that changes based on colour scheme so you should already be expecting that. |
In case they use a PNG image (or more simply, a non-vectorized one), you can't switch the colors in it. Like I said, this is why I added a contrast by using the shadow. Like that, whatever your image color scheme, it'll still be visible. |
I don't think we should add extra styling to user's logos. If you're going out of your way to change the logo you care about how it looks and you are not going to always want a white drop shadow on your logo. We should leave it to the user to decide how to make their logo best contrast with background. |
It's simply not possible. I repeat myself but we can't expect people to provide vectorized images all the time when we can just put a shadow and make it work in all cases. The point is to make it simpler for users, not more complicated. |
@GuillaumeGomez I don't know why you believe I'm saying that all users have to vector images? I'm only talking about changing the rust logo that we ship with. |
@XAMPPRocky But then it doesn't solve the current issue for other crates? |
Sure, though I don't think this PR solves this issue for other crates either. There are plenty of designs that will look worse with a white drop shadow. I don't think there's any single solution around the added complexity of having a logo look good in both light and dark colour schemes. I think it's best to leave it up to users to decide if their logo looks good enough, whether they need make a couple of adjustments, or if they want to have a dynamic logo. |
I agree with @XAMPPRocky here, this would seem to make the most sense. |
I'm strongly opposed to that (because of the complexity added for the users that would have to provide much more than just an image contrary to the current behavior) but at this point, let's just ask what the other rustdoc people think. PS: they already can override the style for the image if they want, just wanted to precise it. cc @rust-lang/rustdoc @Manishearth @jyn514 |
I think dynamic logos are more work than people are going to be willing to put into it, especially if their logos aren't vector graphics. A contrasting border (or shadow) is one of the easiest ways to make arbitrary images not look terrible against a background, and I've seen that technique used elsewhere. Furthermore! The CSS solution only applies to system dark mode, not webpage dark mode. Rustdoc has a builtin dark theme (and there's now a third Ayu theme). I don't think there's a way to communicate the theme being used to an embedded SVG image. This technique does not work here, it's not a favicon that matters here. Now, one option is to make it possible for users to supply multiple logos in Cargo. A problem I see is that this will get less great if we add more themes, though we could stick to a dark/light distinction and expect themes to pick one. But the shadow seems like the easiest way to do things here. Perhaps it should just be a solid border and not a shadow, I don't know: CSS borders can't snap to nontransparent parts of images, but you can kinda emulate that with shadows. |
I might add a bit of context here: I tried using |
Yeah you have to do a blur filter to get a proper shadow on images. But I believe you can write one that creates a solid blur. Idk. |
I wasn't able to without blurring the full image so I'm curious to see if it's possible. That'd be a nice trick. :) |
Ah yeah, good point. That solution wouldn't actually do the trick here. |
I really don't like how the goal posts have moved in this discussion. The original issue (#74350) was about the Rust logo being difficult to see in dark color schemes, no one has asked for a solution for all logos. I really don't think we should try to guess what will look best for someone else's design or try to solve a problem no one actually has. |
If the issue exists for the rust logo, it exists for all logo. The only available solution is to add a contrast around the image (like you do for subtitles for example) to make it visible, whatever the logo's colors. So no, it's just that we're trying to have a broader vision of the problem. At least I don't see it as moving away from the original issue. |
This is just one example. And what if we decide to add a redshift-like theme? Then you'll come up with a green logo and say it's not worth it? I'm not saying your solution is bad, I'm saying it'd require too much efforts from people who use rustdoc. They very likely won't want to provide as many images as there are themes, which makes perfect sense. The solution I offer may not be the best but I think it offers the best ratio of advantages vs shortcomings. |
Ah. I'm okay with applying a special CSS class to the rust logo only so that the problem is solved for the Rust logo. |
☔ The latest upstream changes (presumably #74422) made this pull request unmergeable. Please resolve the merge conflicts. |
0d8600b
to
839216a
Compare
Rebased. |
I *think* the global opinion seems ok with this change. Should we move forward then? cc @rust-lang/rustdoc |
I would prefer to special case the rust logo for now but I don't feel strongly. I'm okay with the approach in this PR, but it might be worth opening an internals topic to ask if people are having problems. |
Ok, so here is what I propose: we merge this PR as is to fix the current issue and we open a topic so we can get people feedback on this and then update if needed. What do you think? |
Seems fine |
Great! I let you handle the topic? (never know if I should open it on internals or users...) @bors: r=Manishearth |
📌 Commit 839216a has been approved by |
🌲 The tree is currently closed for pull requests below priority 100, this pull request will be tested once the tree is reopened |
@bors: rollup |
@GuillaumeGomez I don't have time to organize that. Please do so, on internals. |
Ok! Will do as soon as this PR is merged then. |
Rollup of 12 pull requests Successful merges: - rust-lang#74361 (Improve doc theme logo display) - rust-lang#74504 (Add right border bar to Dark and Light theme) - rust-lang#74572 (Internally unify rustc_deprecated and deprecated) - rust-lang#74601 (Clean up E0724 explanation) - rust-lang#74623 (polymorphize GlobalAlloc::Function) - rust-lang#74665 (Don't ICE on unconstrained anonymous lifetimes inside associated types.) - rust-lang#74666 (More BTreeMap test cases, some exposing undefined behaviour) - rust-lang#74669 (Fix typo) - rust-lang#74677 (Remove needless unsafety from BTreeMap::drain_filter) - rust-lang#74680 (Add missing backticks in diagnostics note) - rust-lang#74694 (Clean up E0727 explanation) - rust-lang#74703 (Fix ICE while building MIR with type errors) Failed merges: r? @ghost
Fixes #74350.
The first commit cleans up the whitespaces and converts them to tabs. We should definitely write a tidy check for this (will do it in another PR).
Screenshots:
r? @lzutao
cc @Cldfire