Skip to content

Commit b3a1ae6

Browse files
authored
fix: add styling for header theme toggle switch button (openedx#26)
1 parent 9c86429 commit b3a1ae6

File tree

4 files changed

+93
-117
lines changed

4 files changed

+93
-117
lines changed

paragon/_extras.scss

Lines changed: 55 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,82 +2,65 @@
22

33
.theme-toggle-button{
44
position: relative;
5-
width: 40px;
6-
height: 40px;
7-
}
5+
display: flex;
6+
align-items: center;
87

9-
#darkmode {
10-
cursor: pointer;
11-
width: 20px;
12-
height: 20px;
13-
position: absolute;
14-
margin: auto !important;
15-
top: 0;
16-
right: 0;
17-
bottom: 0;
18-
left: 0;
19-
display: flex;
20-
align-items: center;
21-
justify-content: center;
22-
transform: scale(1.5);
23-
}
8+
.light-theme-icon > span, .dark-theme-icon > span{
9+
width: 18px;
10+
color: $primary;
11+
}
2412

25-
.darkmode_icon {
26-
position: absolute;
27-
width: 20px;
28-
height: 20px;
29-
border-radius: 10px;
30-
background: $warning-400;
31-
transform-origin: center center;
32-
transition: transform 0.75s ease-in-out, $page-color-transition;
13+
.toggle-switch {
14+
display: flex;
15+
margin: 0 2px;
3316

34-
&::after {
35-
position: absolute;
36-
content: '';
37-
width: 16px;
38-
height: 16px;
39-
left: 6px;
40-
bottom: 4px;
41-
border-radius: 10px;
42-
background: $body-bg;
43-
transform-origin: center center;
44-
transition: transform 0.2s ease, left 0.25s ease, bottom 0.25s ease, $page-color-transition;
45-
}
17+
label {
18+
margin: 0
19+
}
4620

47-
.ray {
48-
position: absolute;
49-
left: 7px;
50-
top: 7px;
51-
width: 6px;
52-
height: 6px;
53-
border-radius: 6px;
54-
background: transparent;
55-
transform-origin: center;
56-
transition: transform 0.5s ease-in-out, $page-color-transition;
21+
/* The switch - the box around the slider */
22+
.switch {
23+
position: relative;
24+
display: inline-block;
25+
width: 45px;
26+
height: 24px;
5727

58-
&:nth-child(1) {
59-
transform: rotate(45deg) translateX(0);
60-
}
61-
&:nth-child(2) {
62-
transform: rotate(90deg) translateX(0);
63-
}
64-
&:nth-child(3) {
65-
transform: rotate(135deg) translateX(0);
66-
}
67-
&:nth-child(4) {
68-
transform: rotate(180deg) translateX(0);
69-
}
70-
&:nth-child(5) {
71-
transform: rotate(225deg) translateX(0);
72-
}
73-
&:nth-child(6) {
74-
transform: rotate(270deg) translateX(0);
75-
}
76-
&:nth-child(7) {
77-
transform: rotate(315deg) translateX(0);
78-
}
79-
&:nth-child(8) {
80-
transform: rotate(360deg) translateX(0);
28+
/* Hide default HTML checkbox */
29+
input {
30+
opacity: 0;
31+
width: 0;
32+
height: 0;
33+
}
34+
35+
/* The slider */
36+
.slider {
37+
position: absolute;
38+
cursor: pointer;
39+
top: 0;
40+
left: 0;
41+
right: 0;
42+
bottom: 0;
43+
background-color: #AEC7F6;
44+
transition: .4s;
45+
46+
&::before{
47+
position: absolute;
48+
content: "";
49+
height: 20px;
50+
width: 20px;
51+
left: 3px;
52+
bottom: 2px;
53+
background-color: white;
54+
transition: .4s;
55+
}
56+
57+
&.round{
58+
border-radius: 34px;
59+
&::before{
60+
border-radius: 50%;
61+
}
62+
}
63+
}
64+
}
8165
}
82-
}
8366
}

themes/dark/_extras.scss

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,4 +1457,23 @@ section[data-testid=sidebar-NOTIFICATIONS], section[data-testid=sidebar-DISCUSSI
14571457

14581458
.donut-chart-text {
14591459
fill: $primary-500;
1460-
}
1460+
}
1461+
1462+
.theme-toggle-button{
1463+
.light-theme-icon > span, .dark-theme-icon > span{
1464+
color: $text-color-primary;
1465+
}
1466+
.toggle-switch {
1467+
.switch {
1468+
/* The slider */
1469+
.slider {
1470+
background-color: #ccc;
1471+
box-shadow: 0 0 1px #ccc;
1472+
&::before{
1473+
transform: translateX(19px);
1474+
background-color: $text-color-primary;
1475+
}
1476+
}
1477+
}
1478+
}
1479+
}

themes/dark/_learning.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
&.complete {
5858
color: $success;
5959
}
60+
&.active::after {
61+
background: $primary;
62+
}
6063
}
6164
}
6265

@@ -93,3 +96,18 @@
9396
}
9497
}
9598

99+
#root {
100+
nav[aria-label=breadcrumb] {
101+
background: $primary-light;
102+
ol {
103+
li {
104+
font-size: 14px;
105+
line-height: 20px;
106+
a {
107+
color: $text-color-primary !important;
108+
font-weight: 500;
109+
}
110+
}
111+
}
112+
}
113+
}

themes/dark/_utilities.scss

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -282,47 +282,3 @@ a.muted-link {
282282
}
283283

284284
@import "./learning";
285-
286-
287-
// toggle theme button for dark mode
288-
289-
.darkmode_icon {
290-
transform: scale(0.6);
291-
background: $warning-400;
292-
293-
&::after {
294-
left: 15px;
295-
bottom: 8px;
296-
transform: scale(0);
297-
transition: transform 1s ease, left 0.25s ease, bottom 0.25s ease, $page-color-transition;
298-
}
299-
300-
.ray {
301-
background: $warning-400;
302-
303-
&:nth-child(1) {
304-
transform: rotate(45deg) translateX(-16px);
305-
}
306-
&:nth-child(2) {
307-
transform: rotate(90deg) translateX(-16px);
308-
}
309-
&:nth-child(3) {
310-
transform: rotate(135deg) translateX(-16px);
311-
}
312-
&:nth-child(4) {
313-
transform: rotate(180deg) translateX(-16px);
314-
}
315-
&:nth-child(5) {
316-
transform: rotate(225deg) translateX(-16px);
317-
}
318-
&:nth-child(6) {
319-
transform: rotate(270deg) translateX(-16px);
320-
}
321-
&:nth-child(7) {
322-
transform: rotate(315deg) translateX(-16px);
323-
}
324-
&:nth-child(8) {
325-
transform: rotate(360deg) translateX(-16px);
326-
}
327-
}
328-
}

0 commit comments

Comments
 (0)