Skip to content

Improve settings theme display #97089

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 3 commits into from
May 31, 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
53 changes: 20 additions & 33 deletions src/librustdoc/html/static/css/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,40 @@
position: relative;
}

.setting-line > div {
display: inline-block;
vertical-align: top;
font-size: 17px;
padding-top: 2px;
}

.setting-line > .title {
font-size: 19px;
width: 100%;
max-width: none;
border-bottom: 1px solid;
}

.setting-line .radio-line,
.setting-line .choices {
display: flex;
flex-wrap: wrap;
}

.setting-line .radio-line .setting-name {
flex-grow: 1;
margin-top: auto;
margin-bottom: auto;
}

.setting-line .radio-line input {
margin-right: 0.3em;
height: 1.2rem;
width: 1.2rem;
border: 1px solid;
outline: none;
-webkit-appearance: none;
cursor: pointer;
border-radius: 50%;
}
.setting-line .radio-line input + span {
padding-bottom: 1px;
}

.radio-line .setting-name {
width: 100%;
}

.radio-line .choice {
border-radius: 0.1em;
border: 1px solid;
margin-left: 0.5em;
margin-top: 0.1em;
margin-bottom: 0.1em;
min-width: 3.8em;
padding: 0.3em;
display: flex;
align-items: center;
cursor: pointer;
}
.radio-line .choice + .choice {
margin-left: 0.5em;
}

.toggle {
Expand Down Expand Up @@ -77,18 +73,9 @@
width: 19px;
left: 4px;
bottom: 4px;
background-color: white;
transition: .3s;
}

input:checked + .slider {
background-color: #2196F3;
}

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

input:checked + .slider:before {
transform: translateX(19px);
}
Expand Down
39 changes: 32 additions & 7 deletions src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,38 @@ body, #settings-menu #settings, #settings-menu #settings::before {
color: #c5c5c5;
}

.setting-line .radio-line input {
border-color: #c5c5c5;
}
.setting-line .radio-line input:checked {
box-shadow: inset 0 0 0 3px #0f1419;
background-color: #ffb454;
}
.setting-line .radio-line input:focus {
box-shadow: 0 0 1px 1px #ffb454;
}
/* In here we combine both `:focus` and `:checked` properties. */
.setting-line .radio-line input:checked:focus {
box-shadow: inset 0 0 0 3px 0f1419,
0 0 2px 2px #ffb454;
}
.setting-line .radio-line input:hover {
border-color: #ffb454 !important;
}

.slider {
background-color: #ccc;
}
.slider:before {
background-color: white;
}
input:checked + .slider {
background-color: #ffb454;
}
input:focus + .slider {
box-shadow: 0 0 0 2px #0a84ff, 0 0 0 6px rgba(10, 132, 255, 0.3);
}

h1, h2, h3, h4 {
color: white;
}
Expand Down Expand Up @@ -601,13 +633,6 @@ div.files > .selected {
background-color: #14191f;
color: #ffb44c;
}
.setting-line > .title {
border-bottom-color: #5c6773;
}
input:checked + .slider {
background-color: #ffb454 !important;
}


.scraped-example-list .scrape-help {
border-color: #aaa;
Expand Down
35 changes: 32 additions & 3 deletions src/librustdoc/html/static/css/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,38 @@ body, #settings-menu #settings, #settings-menu #settings::before {
color: #ddd;
}

.setting-line .radio-line input {
border-color: #ddd;
}
.setting-line .radio-line input:checked {
box-shadow: inset 0 0 0 3px #353535;
background-color: #2196f3;
}
.setting-line .radio-line input:focus {
box-shadow: 0 0 1px 1px #2196f3;
}
/* In here we combine both `:focus` and `:checked` properties. */
.setting-line .radio-line input:checked:focus {
box-shadow: inset 0 0 0 3px #353535,
0 0 2px 2px #2196f3;
}
.setting-line .radio-line input:hover {
border-color: #2196f3 !important;
}

.slider {
background-color: #ccc;
}
.slider:before {
background-color: white;
}
input:checked + .slider {
background-color: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 0 2px #0a84ff, 0 0 0 6px rgba(10, 132, 255, 0.3);
}

h1, h2, h3, h4 {
color: #ddd;
}
Expand Down Expand Up @@ -472,9 +504,6 @@ div.files > a:hover, div.name:hover {
div.files > .selected {
background-color: #333;
}
.setting-line > .title {
border-bottom-color: #ddd;
}

.scraped-example-list .scrape-help {
border-color: #aaa;
Expand Down
35 changes: 32 additions & 3 deletions src/librustdoc/html/static/css/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,38 @@ body, #settings-menu #settings, #settings-menu #settings::before {
color: black;
}

.setting-line .radio-line input {
border-color: black;
}
.setting-line .radio-line input:checked {
box-shadow: inset 0 0 0 3px white;
background-color: #2196f3;
}
.setting-line .radio-line input:focus {
box-shadow: 0 0 1px 1px #2196f3;
}
/* In here we combine both `:focus` and `:checked` properties. */
.setting-line .radio-line input:checked:focus {
box-shadow: inset 0 0 0 3px white,
0 0 2px 2px #2196f3;
}
.setting-line .radio-line input:hover {
border-color: #2196f3 !important;
}

.slider {
background-color: #ccc;
}
.slider:before {
background-color: white;
}
input:checked + .slider {
background-color: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 0 2px #0a84ff, 0 0 0 6px rgba(10, 132, 255, 0.3);
}

h1, h2, h3, h4 {
color: black;
}
Expand Down Expand Up @@ -456,9 +488,6 @@ div.files > a:hover, div.name:hover {
div.files > .selected {
background-color: #fff;
}
.setting-line > .title {
border-bottom-color: #D5D5D5;
}

.scraped-example-list .scrape-help {
border-color: #555;
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
output += `<label for="${js_data_name}-${option}" class="choice">\
<input type="radio" name="${js_data_name}" \
id="${js_data_name}-${option}" value="${option}"${checked}>\
${option}\
<span>${option}</span>\
</label>`;
});
output += "</div></div>";
Expand Down
60 changes: 60 additions & 0 deletions src/test/rustdoc-gui/settings.goml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// This test ensures that the settings menu display is working as expected.
goto: file://|DOC_PATH|/test_docs/index.html
show-text: true // needed when we check for colors below.
// First, we check that the settings page doesn't exist.
assert-false: "#settings"
// We now click on the settings button.
Expand Down Expand Up @@ -43,6 +44,65 @@ assert: ".setting-line.hidden #preferred-light-theme"
// We check that the correct theme is selected.
assert-property: ("#theme .choices #theme-dark", {"checked": "true"})

// Some style checks...
// First we check the "default" display.
assert-css: (
"#theme-dark",
{
"border-color": "rgb(221, 221, 221)",
"box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset",
},
)
assert-css: ("#theme-light", {"border-color": "rgb(221, 221, 221)", "box-shadow": "none"})
// Let's start with the hover.
move-cursor-to: "#theme-dark"
assert-css: (
"#theme-dark",
{
"border-color": "rgb(33, 150, 243)",
"box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset",
},
)
move-cursor-to: "#theme-light"
assert-css: ("#theme-light", {"border-color": "rgb(33, 150, 243)", "box-shadow": "none"})
move-cursor-to: "#theme-ayu"
// Let's now check with the focus.
focus: "#theme-dark"
assert-css: (
"#theme-dark",
{
"border-color": "rgb(221, 221, 221)",
"box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset, rgb(33, 150, 243) 0px 0px 2px 2px",
},
)
focus: "#theme-light"
assert-css: (
"#theme-light",
{
"border-color": "rgb(221, 221, 221)",
"box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px",
},
)
// Now we check we both focus and hover.
move-cursor-to: "#theme-dark"
focus: "#theme-dark"
assert-css: (
"#theme-dark",
{
"border-color": "rgb(33, 150, 243)",
"box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset, rgb(33, 150, 243) 0px 0px 2px 2px",
},
)
move-cursor-to: "#theme-light"
focus: "#theme-light"
assert-css: (
"#theme-light",
{
"border-color": "rgb(33, 150, 243)",
"box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px",
},
)

// We now switch the display.
click: "#use-system-theme"
// Wait for the hidden element to show up.
Expand Down