Skip to content

Migrate rust logo filter to CSS variables #104065

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

Merged
merged 2 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ img {
object-fit: contain;
}

.rust-logo {
filter: var(--rust-logo-filter);
}

.sidebar, .mobile-topbar, .sidebar-menu-toggle {
background-color: var(--sidebar-background-color);
}
Expand Down
11 changes: 4 additions & 7 deletions src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ Original by Dempfi (https://github.com/dempfi/ayu)
--test-arrow-background-color: rgba(57, 175, 215, 0.09);
--test-arrow-hover-color: #c5c5c5;
--test-arrow-hover-background-color: rgba(57, 175, 215, 0.368);
--rust-logo-filter: drop-shadow(1px 0 0px #fff)
drop-shadow(0 1px 0 #fff)
drop-shadow(-1px 0 0 #fff)
drop-shadow(0 -1px 0 #fff);
}

.slider {
Expand Down Expand Up @@ -104,13 +108,6 @@ pre, .rustdoc.source .example-wrap {
color: #e6e1cf;
}

.rust-logo {
filter: drop-shadow(1px 0 0px #fff)
drop-shadow(0 1px 0 #fff)
drop-shadow(-1px 0 0 #fff)
drop-shadow(0 -1px 0 #fff);
}

.sidebar .current,
.sidebar a:hover {
color: #ffb44c;
Expand Down
11 changes: 4 additions & 7 deletions src/librustdoc/html/static/css/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
--test-arrow-background-color: rgba(78, 139, 202, 0.2);
--test-arrow-hover-color: #dedede;
--test-arrow-hover-background-color: #4e8bca;
--rust-logo-filter: drop-shadow(1px 0 0px #fff)
drop-shadow(0 1px 0 #fff)
drop-shadow(-1px 0 0 #fff)
drop-shadow(0 -1px 0 #fff);
}

.slider {
Expand All @@ -70,13 +74,6 @@ input:focus + .slider {
box-shadow: 0 0 0 2px #0a84ff, 0 0 0 6px rgba(10, 132, 255, 0.3);
}

.rust-logo {
filter: drop-shadow(1px 0 0px #fff)
drop-shadow(0 1px 0 #fff)
drop-shadow(-1px 0 0 #fff)
drop-shadow(0 -1px 0 #fff)
}

.content .item-info::before { color: #ccc; }

body.source .example-wrap pre.rust a {
Expand Down
7 changes: 1 addition & 6 deletions src/librustdoc/html/static/css/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
--test-arrow-background-color: rgba(78, 139, 202, 0.2);
--test-arrow-hover-color: #f5f5f5;
--test-arrow-hover-background-color: #4e8bca;
--rust-logo-filter: initial;
}

.slider {
Expand All @@ -70,12 +71,6 @@ input:focus + .slider {
box-shadow: 0 0 0 2px #0a84ff, 0 0 0 6px rgba(10, 132, 255, 0.3);
}

.rust-logo {
/* This rule exists to force other themes to explicitly style the logo.
* Rustdoc has a custom linter for this purpose.
*/
}

.content .item-info::before { color: #ccc; }

body.source .example-wrap pre.rust a {
Expand Down
9 changes: 9 additions & 0 deletions src/test/rustdoc-gui/rust-logo.goml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ define-function: (
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
("reload"),
("assert-css", (".rust-logo", {"filter": |filter|})),
// Now we check that the non-rust logos don't have a CSS filter set.
("goto", "file://" + |DOC_PATH| + "/huge_logo/index.html"),
// Changing theme on the new page (again...).
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
("reload"),
// Check there is no rust logo
("assert-false", ".rust-logo"),
// Check there is no filter.
("assert-css", (".sidebar .logo-container img", {"filter": "none"})),
],
)

Expand Down