-
Notifications
You must be signed in to change notification settings - Fork 201
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
Add templates theming to docs.rs #1116
Conversation
5479a29
to
3ac82f3
Compare
Good catch! Fixed.
Not sure what the result should look like. It just seemed nice as is so I kept it this way.
Which page are you referring to? (Not sure I went through this one...)
Yes, it's unfortunate but we'll need to deal with highlight.js theming system too. |
👍 yeah, looks good enough
|
Oh I see. Hum... Seems like we have to go through Highchart.js API there too (or maybe someone knows another way?). |
This looks fantastic! I made a few tweaks over at Cldfire@7804bbc. Feel free to cherry-pick the commit / apply the changes: diff --git a/templates/style/_themes.scss b/templates/style/_themes.scss
index 41d3ae8..660c07f 100644
--- a/templates/style/_themes.scss
+++ b/templates/style/_themes.scss
@@ -13,6 +13,7 @@ html {
--color-menu-header-background: #e0e0e0;
--color-navbar-standard: #777;
--color-standard: #000;
+ --color-brand: #000;
--color-struct: #df3600;
--color-type: #e57300;
--color-url: #4d76ae;
@@ -20,6 +21,8 @@ html {
--color-warn-hover: #b25900;
--color-warn: #e57300;
--color-background-input: #fff;
+ --color-table-header-background: #e0e0e0;
+ --color-table-header: #000;
}
// To add a new theme, copy the above theme into a new `html[data-theme="name"]`
@@ -39,6 +42,7 @@ html[data-theme="dark"] {
--color-menu-header-background: #e0e0e0;
--color-navbar-standard: #ddd;
--color-standard: #c0c0c0;
+ --color-brand: #fff;
--color-struct: #df3600;
--color-type: #e57300;
--color-url: #d2991d;
@@ -46,6 +50,8 @@ html[data-theme="dark"] {
--color-warn-hover: #b25900;
--color-warn: #e57300;
--color-background-input: #f0f0f0;
+ --color-table-header-background: #e0e0e0;
+ --color-table-header: #000;
}
html[data-theme="ayu"] {
@@ -62,6 +68,7 @@ html[data-theme="ayu"] {
--color-menu-header-background: #e0e0e0;
--color-navbar-standard: #ddd;
--color-standard: #c5c5c5;
+ --color-brand: #fff;
--color-struct: #df3600;
--color-type: #e57300;
--color-url: #39afd7;
@@ -69,4 +76,6 @@ html[data-theme="ayu"] {
--color-warn-hover: #b25900;
--color-warn: #e57300;
--color-background-input: #141920;
+ --color-table-header-background: #364759;
+ --color-table-header: #eee;
}
diff --git a/templates/style/base.scss b/templates/style/base.scss
index 546ff54..ac2a9f0 100644
--- a/templates/style/base.scss
+++ b/templates/style/base.scss
@@ -27,10 +27,16 @@ body {
input, #search {
background-color: var(--color-background-input);
+ color: var(--color-standard);
}
#search {
- box-shadow: 0 0 0 1px var(--color-border), 0 0 0 2px transparent;
+ box-shadow: 0 0 0 1px var(--color-border), 0 0 0 1px var(--color-border);
+ transition: box-shadow 150ms ease-in-out;
+ }
+
+ #search:focus {
+ box-shadow: 0 0 0 1px #148099, 0 0 0 1px #148099;
}
// rustdocs have 200px sidebar and
@@ -99,7 +105,7 @@ div.landing {
h1.brand {
font-size: 3em;
margin-bottom: 10px;
- color: var(--color-standard);
+ color: var(--color-brand);
}
form.landing-search-form {
@@ -612,6 +618,11 @@ div.search-page-search-form {
margin-bottom: 10px;
}
+ thead {
+ background-color: var(--color-table-header-background);
+ color: var(--color-table-header);
+ }
+
thead tr th {
font-family: $font-family-sans;
font-weight: 500; This makes table headers look better for the ayu theme (feel free to change them for dark if you'd like): it also improves the look of the front page a bit: And gives the search bar a focus highlight like rustdoc's (feel free to improve this for the dark / light theme if you see a good way to do so): This particular change: #search {
- box-shadow: 0 0 0 1px var(--color-border), 0 0 0 2px transparent;
+ box-shadow: 0 0 0 1px var(--color-border), 0 0 0 1px var(--color-border);
+ transition: box-shadow 150ms ease-in-out;
+ } Makes the border color / thickness uniform around the entire input for me in Firefox (the current rule resulted in a border that seemed dimmer on the bottom). Everything else looks great to me. I don't personally think it's worth fixing the highchart in this PR (very few people ever look at that?) and the code block styling could be a follow up too imo. Thanks so much for working on this everyone 🎉 |
And one other thought: I've had a simple solution to the highcharts style for years now in my userstyle: rect.highcharts-background {
fill: #0f1419;
}
text.highcharts-title, g.highcharts-axis-labels > text {
fill: #e6e6e6 !important;
}
g.highcharts-legend-item > text {
fill: #5c6773 !important;
}
g.highcharts-grid > path {
stroke: #5c6773 !important;
} This is what it looks like: Maybe worth using, maybe not, depends on how hard it is to customize the chart itself I guess. |
I'm planning on removing our highcharts dependency eventually, we can generate graphs with tera |
Oh damn.You really did a great job @Cldfire ! I'll cherry-pick your commit and use your css for the graph then. :) |
3ac82f3
to
9196477
Compare
And here we are! I improved the input, fixed a few small things and also included improvements for the graphs. |
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.
Looks like a rustdoc bug, it doesn't update local storage if switching to the light theme since that's already the theme displayed, even though it's not stored. |
But, using |
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.
Looks great, now we just need to make sure that rustdoc issue gets fixed :)
Is this an accurate summary of the current behavior?
I had trouble testing this - once I changed the theme the first time I can't replicate the original issue, even with a new private window. How does this behave for docs built before the rustdoc changes? Will they still have the theme switched appropriately? |
I think this will break if we use it for docs built before rust-lang/rust#77809, so I'd rather not go with that solution. |
Based on the script written by @Nemo157, they should get updated as long as the docs has been generated using a rustdoc version than supported themes (so a very old one). |
I wonder if we could reset the colors for the |
If it's on the docs.rs pages, then not directly since it depends on highlight.js and not HTML/CSS only. We discussed about it a few comments ago. ;)
Nice catch! Taking a look. |
Specifically only docs built between rust-lang/rust#77809 and rust-lang/rust#78293, which is about 8 days worth of docs. |
Fixed the input issue. |
I think we can do this in a follow-up, the current behavior seems 'good enough' to me if only a week of docs are affected only briefly. |
Follow-up of #1100.
Considering the huge amount of screenshots needed, I think the best would be to just let you test out. But just for your eyes:
cc @Cldfire (for the ayu theme)