Skip to content

Commit 1ebf0d9

Browse files
Allow to click on toggle text to update it
1 parent 7f997f5 commit 1ebf0d9

File tree

3 files changed

+39
-36
lines changed

3 files changed

+39
-36
lines changed

src/librustdoc/html/static/css/rustdoc.css

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,30 +1415,6 @@ pre.rust {
14151415
#settings-menu.rotate > a img {
14161416
animation: rotating 2s linear infinite;
14171417
}
1418-
#settings-menu #settings {
1419-
position: absolute;
1420-
right: 0;
1421-
z-index: 1;
1422-
display: block;
1423-
margin-top: 7px;
1424-
border-radius: 3px;
1425-
border: 1px solid;
1426-
}
1427-
#settings-menu #settings .setting-line {
1428-
margin: 0.6em;
1429-
}
1430-
/* This rule is to draw the little arrow connecting the settings menu to the gear icon. */
1431-
#settings-menu #settings::before {
1432-
content: '';
1433-
position: absolute;
1434-
right: 11px;
1435-
border: solid;
1436-
border-width: 1px 1px 0 0;
1437-
display: inline-block;
1438-
padding: 4px;
1439-
transform: rotate(-45deg);
1440-
top: -5px;
1441-
}
14421418

14431419
#help-button {
14441420
font-family: "Fira Sans", Arial, sans-serif;

src/librustdoc/html/static/css/settings.css

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@
4646
.toggle {
4747
position: relative;
4848
display: inline-block;
49-
width: 45px;
49+
width: 100%;
5050
height: 27px;
5151
margin-right: 20px;
52+
display: flex;
53+
align-items: center;
54+
cursor: pointer;
5255
}
5356

5457
.toggle input {
@@ -57,12 +60,12 @@
5760
}
5861

5962
.slider {
60-
position: absolute;
63+
position: relative;
64+
width: 45px;
65+
display: block;
66+
height: 28px;
67+
margin-right: 20px;
6168
cursor: pointer;
62-
top: 0;
63-
left: 0;
64-
right: 0;
65-
bottom: 0;
6669
background-color: #ccc;
6770
transition: .3s;
6871
}
@@ -95,3 +98,28 @@ input:checked + .slider:before {
9598
width: 100%;
9699
display: block;
97100
}
101+
102+
div#settings {
103+
position: absolute;
104+
right: 0;
105+
z-index: 1;
106+
display: block;
107+
margin-top: 7px;
108+
border-radius: 3px;
109+
border: 1px solid;
110+
}
111+
#settings .setting-line {
112+
margin: 1.2em 0.6em;
113+
}
114+
/* This rule is to draw the little arrow connecting the settings menu to the gear icon. */
115+
div#settings::before {
116+
content: '';
117+
position: absolute;
118+
right: 11px;
119+
border: solid;
120+
border-width: 1px 1px 0 0;
121+
display: inline-block;
122+
padding: 4px;
123+
transform: rotate(-45deg);
124+
top: -5px;
125+
}

src/librustdoc/html/static/js/settings.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,11 @@
130130
} else {
131131
// This is a toggle.
132132
const checked = setting["default"] === true ? " checked" : "";
133-
output += `
134-
<label class="toggle">
135-
<input type="checkbox" id="${js_data_name}"${checked}>
136-
<span class="slider"></span>
137-
</label>
138-
<div>${setting_name}</div>`;
133+
output += `<label class="toggle">\
134+
<input type="checkbox" id="${js_data_name}"${checked}>\
135+
<span class="slider"></span>\
136+
<span class="label">${setting_name}</span>\
137+
</label>`;
139138
}
140139
output += "</div>";
141140
}

0 commit comments

Comments
 (0)