Skip to content

Commit

Permalink
Rollup merge of rust-lang#104065 - GuillaumeGomez:css-migrate-logo-fi…
Browse files Browse the repository at this point in the history
…lter, r=notriddle

Migrate rust logo filter to CSS variables
  • Loading branch information
Yuki Okushi committed Nov 6, 2022
2 parents 4d5860c + 0e23d90 commit 94334d3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 20 deletions.
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

0 comments on commit 94334d3

Please sign in to comment.