Skip to content
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

Few fixes for multiple themes support feature #47686

Merged
merged 1 commit into from
Jan 25, 2018
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
8 changes: 5 additions & 3 deletions src/librustdoc/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ r##"<!DOCTYPE html>
{sidebar}
</nav>

<button id="theme-picker">
<img src="{root_path}brush.svg" width="18" alt="Pick another theme!">
<div class="theme-picker">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we know why this change makes it work? semantically, this should be a <button>.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it's a <button> inside this <div> so i would assume that there's some layout trickery going on.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just like @QuietMisdreavus said. :) Before it was buttons inside a button, now it's buttons inside a div. More logical for everyone (browsers included).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, i was missing the other <button>s being put inside this one. I like this version more.

<button id="theme-picker" aria-label="Pick another theme!">
<img src="{root_path}brush.svg" width="18" alt="Pick another theme!">
</button>
<div id="theme-choices"></div>
</button>
</div>
<script src="{root_path}theme.js"></script>
<nav class="sub">
<form class="search-form js-only">
Expand Down
8 changes: 4 additions & 4 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,12 +918,12 @@ themePicker.onclick = function() {{
}}
}};
[{}].forEach(function(item) {{
var div = document.createElement('div');
div.innerHTML = item;
div.onclick = function(el) {{
var but = document.createElement('button');
but.innerHTML = item;
but.onclick = function(el) {{
switchTheme(currentTheme, mainTheme, item);
}};
themes.appendChild(div);
themes.appendChild(but);
}});
"#, themes.iter()
.map(|s| format!("\"{}\"", s))
Expand Down
27 changes: 20 additions & 7 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1141,13 +1141,19 @@ kbd {
border: solid 1px;
border-radius: 3px;
box-shadow: inset 0 -1px 0;
cursor: default;
}

#theme-picker {
.theme-picker {
position: absolute;
left: 211px;
top: 17px;
top: 19px;
}

#theme-picker {
padding: 4px;
width: 27px;
height: 29px;
border: 1px solid;
border-radius: 3px;
cursor: pointer;
Expand All @@ -1156,21 +1162,28 @@ kbd {
#theme-choices {
display: none;
position: absolute;
left: -1px;
top: 30px;
left: 0;
top: 28px;
border: 1px solid;
border-radius: 3px;
z-index: 1;
cursor: pointer;
}

#theme-choices > div {
border-top: 1px solid;
#theme-choices > button {
border: none;
width: 100%;
padding: 4px;
text-align: center;
background: rgba(0,0,0,0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure there's a conversation somewhere about where the colors need to go, since you recently made sure every color directive went into the theme css. Or did you want the theme-picker button to look the same in every theme? >_>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to the background of the button to be invisible so that the buttons background is consistent to its parent. It's the only case where I'll put colors in this file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhhh, no alpha, now i get it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hehe.

}

#theme-choices > button:not(:first-child) {
border-top: 1px solid;
}

@media (max-width: 700px) {
#theme-picker {
.theme-picker {
left: 109px;
top: 7px;
z-index: 1;
Expand Down
14 changes: 9 additions & 5 deletions src/librustdoc/html/static/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ a.test-arrow {

#help dt {
border-color: #bfbfbf;
background: #fff;
background: rgba(0,0,0,0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This creates black-on-black text for the keyboard shortcut keys on the help window.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, i didn't realize that the help window keys got switched over to <kbd> tags. This is fine.

color: black;
}

Expand Down Expand Up @@ -352,7 +352,7 @@ pre.ignore:hover, .information:hover + pre.ignore {
}

kbd {
color: #444d56;
color: #000;
background-color: #fafbfc;
border-color: #d1d5da;
border-bottom-color: #c6cbd1;
Expand All @@ -364,16 +364,20 @@ kbd {
background: #f0f0f0;
}

#theme-picker:hover, #theme-picker:focus {
border-color: #ffb900;
}

#theme-choices {
border-color: #e0e0e0;
background-color: #353535;
}

#theme-choices > div {
border-top: #e0e0e0;
#theme-choices > button:not(:first-child) {
border-top-color: #e0e0e0;
}

#theme-choices > div:hover {
#theme-choices > button:hover, #theme-choices > button:focus {
background-color: #444;
}

Expand Down
13 changes: 9 additions & 4 deletions src/librustdoc/html/static/themes/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ pre.ignore:hover, .information:hover + pre.ignore {
}

kbd {
color: #444d56;
color: #000;
background-color: #fafbfc;
border-color: #d1d5da;
border-bottom-color: #c6cbd1;
Expand All @@ -354,18 +354,23 @@ kbd {

#theme-picker {
border-color: #e0e0e0;
background-color: #fff;
}

#theme-picker:hover, #theme-picker:focus {
border-color: #717171;
}

#theme-choices {
border-color: #ccc;
background-color: #fff;
}

#theme-choices > div {
border-top: #e0e0e0;
#theme-choices > button:not(:first-child) {
border-top-color: #e0e0e0;
}

#theme-choices > div:hover {
#theme-choices > button:hover, #theme-choices > button:focus {
background-color: #eee;
}

Expand Down