Skip to content

Commit d5dd3b9

Browse files
committed
refactor(ui): redesign theme switcher as compact segmented control
1 parent 72a5d4a commit d5dd3b9

2 files changed

Lines changed: 44 additions & 18 deletions

File tree

_includes/header_custom.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
11
<div id="feast-theme-switcher" class="feast-theme-switcher" role="group" aria-label="Theme mode switcher">
2-
<span class="feast-theme-switcher__label text-small">Theme</span>
32
<button
43
type="button"
5-
class="btn feast-theme-switcher__button js-feast-theme-option"
4+
class="feast-theme-switcher__button js-feast-theme-option"
65
data-theme-option="system"
76
aria-pressed="false"
7+
aria-label="Use system theme setting"
8+
title="System"
89
>
9-
System
10+
Auto
1011
</button>
1112
<button
1213
type="button"
13-
class="btn feast-theme-switcher__button js-feast-theme-option"
14+
class="feast-theme-switcher__button js-feast-theme-option"
1415
data-theme-option="light"
1516
aria-pressed="false"
17+
aria-label="Use light theme"
18+
title="Light"
1619
>
1720
Light
1821
</button>
1922
<button
2023
type="button"
21-
class="btn feast-theme-switcher__button js-feast-theme-option"
24+
class="feast-theme-switcher__button js-feast-theme-option"
2225
data-theme-option="dark"
2326
aria-pressed="false"
27+
aria-label="Use dark theme"
28+
title="Dark"
2429
>
2530
Dark
2631
</button>

_sass/custom/custom.scss

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,57 @@
11
.feast-theme-switcher {
22
display: inline-flex;
33
align-items: center;
4-
gap: 0.25rem;
5-
margin: 0 0.5rem;
4+
gap: 0;
5+
margin: 0 0.35rem;
6+
padding: 0.15rem;
7+
border: 1px solid $border-color;
8+
border-radius: 999px;
9+
background-color: $body-background-color;
10+
box-shadow: 0 1px 2px rgba($black, 0.05);
611
white-space: nowrap;
712
}
813

9-
.feast-theme-switcher__label {
14+
.feast-theme-switcher__button {
15+
border: 0;
16+
border-radius: 999px;
17+
background: transparent;
1018
color: $search-result-preview-color;
19+
font-size: 0.75rem;
20+
font-weight: 600;
21+
line-height: 1;
22+
padding: 0.38rem 0.58rem;
23+
min-width: 3.1rem;
24+
cursor: pointer;
25+
transition:
26+
background-color 140ms ease,
27+
color 140ms ease,
28+
box-shadow 140ms ease;
1129
}
1230

13-
.feast-theme-switcher__button {
14-
min-width: 3.75rem;
15-
padding: 0.25rem 0.45rem;
31+
.feast-theme-switcher__button:hover {
32+
color: $body-text-color;
33+
background-color: rgba($btn-primary-color, 0.12);
34+
}
35+
36+
.feast-theme-switcher__button:focus-visible {
37+
outline: 0;
38+
box-shadow: 0 0 0 2px rgba($link-color, 0.35);
1639
}
1740

1841
.feast-theme-switcher__button.is-active {
1942
color: $white;
2043
background-color: $btn-primary-color;
21-
border-color: $btn-primary-color;
44+
box-shadow: 0 1px 2px rgba($black, 0.2);
2245
}
2346

2447
@media (max-width: 50rem) {
2548
.feast-theme-switcher {
26-
margin: 0 0.25rem;
27-
}
28-
29-
.feast-theme-switcher__label {
30-
display: none;
49+
margin: 0 0.2rem;
3150
}
3251

3352
.feast-theme-switcher__button {
34-
min-width: 3.2rem;
53+
min-width: 2.75rem;
54+
padding: 0.34rem 0.45rem;
55+
font-size: 0.7rem;
3556
}
3657
}

0 commit comments

Comments
 (0)