Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit 400346a

Browse files
Fixes to Dark Mode slider
Fix accessibility by moving "Dark Mode" text inside label element Cleanup layout - change size and indent to match other elements; add hover color to indicate interactivity
1 parent 0baaf75 commit 400346a

File tree

2 files changed

+35
-41
lines changed

2 files changed

+35
-41
lines changed

runestone/common/css/runestone-custom-sphinx-bootstrap.css

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ div.container {
342342
}
343343

344344
.dropdown-menu > li > span,
345-
.dropdown-menu > li > div {
345+
.dropdown-menu > li > div,
346+
.dropdown-menu > li > label {
346347
display: block;
347348
padding: 3px 20px;
348349
clear: both;
@@ -352,6 +353,12 @@ div.container {
352353
white-space: nowrap;
353354
}
354355

356+
.dropdown-menu > li > label:hover, .dropdown-menu > li > label:focus {
357+
color: #262626;
358+
text-decoration: none;
359+
background-color: #f5f5f5;
360+
}
361+
355362
.dropdown-menu > li > a {
356363
color: var(--grayToWhite);
357364
}
@@ -1093,63 +1100,50 @@ body {
10931100
}
10941101

10951102
/*Theme toggle*/
1096-
.theme-switch-wrapper {
1103+
.dropdown-menu > li > label.theme-switch {
10971104
display: flex;
10981105
align-items: center;
1099-
}
1100-
1101-
.theme-switch-wrapper em {
1102-
margin-left: 10px;
1103-
font-size: 1rem;
1104-
}
1105-
1106-
.theme-switch {
1107-
display: inline-block;
1108-
height: 34px;
1109-
position: relative;
1110-
width: 60px;
1106+
font-weight: normal;
1107+
cursor: pointer;
11111108
}
11121109

11131110
.theme-switch input {
11141111
display: none;
11151112
}
11161113

1117-
.slider {
1118-
background-color: #ccc;
1119-
bottom: 0;
1120-
cursor: pointer;
1121-
left: 0;
1122-
position: absolute;
1123-
right: 0;
1124-
top: 0;
1125-
transition: 0.4s;
1114+
.theme-switch .slider {
1115+
background-color: #ccc;
1116+
height: 1.25em;
1117+
width: 2em;
1118+
transition: 0.4s;
1119+
position: relative;
1120+
margin-right: 3px;
11261121
}
11271122

1128-
.slider:before {
1123+
.theme-switch .slider:before {
11291124
background-color: #fff;
1130-
bottom: 4px;
1125+
bottom: 2px;
11311126
content: "";
1132-
height: 26px;
1133-
left: 4px;
1127+
height: calc(1.25em - 4px);
1128+
left: 2px;
11341129
position: absolute;
11351130
transition: 0.4s;
1136-
width: 26px;
1131+
width: calc(1.25em - 4px);
11371132
}
11381133

1139-
input:checked + .slider {
1134+
.theme-switch input:checked + .slider {
11401135
background-color: #66bb6a;
11411136
}
11421137

1143-
input:checked + .slider:before {
1144-
transform: translateX(26px);
1138+
.theme-switch input:checked + .slider:before {
1139+
transform: translateX( calc(0.75em - 1px) );
11451140
}
11461141

1147-
.slider.round {
1148-
border-radius: 34px;
1142+
.theme-switch .slider.round {
1143+
border-radius: 1.25em;
11491144
}
11501145

1151-
.slider.round:before {
1152-
border-radius: 50%;
1146+
.theme-switch .slider.round:before {
1147+
border-radius: 1.25em;
11531148
}
1154-
11551149
/*End theme toggle*/

runestone/common/project_template/_templates/plugin_layouts/sphinx_bootstrap/layout.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@
165165
<li><a href="/{{appname}}/default/user/register" id="registerlink">Register</a></li>
166166
{% endif %}
167167
<li class='loginout'><a href='#'>Login</a></li> <!-- correct link populated by addNavbarLoginLink() -->
168-
<!-- dark mode toggle -->
169-
<li><label class="theme-switch" for="checkbox">
170-
<input type="checkbox" id="checkbox" onchange="runestoneComponents.switchTheme()" />
171-
<div class="slider round"></div>
172-
</label>Dark Mode</li>
168+
<!-- dark mode toggle -->
169+
<li><label class="theme-switch" for="checkbox">
170+
<input type="checkbox" id="checkbox" onchange="runestoneComponents.switchTheme()" />
171+
<div class="slider round"></div>Dark Mode
172+
</label></li>
173173
</ul>
174174
</li>
175175
<!-- end user account dropdown -->

0 commit comments

Comments
 (0)