Skip to content

Commit c86366c

Browse files
committed
Move theme picker styles into CSS modules. Update colors for nav and theme picker button.
1 parent 26eeff3 commit c86366c

6 files changed

Lines changed: 47 additions & 59 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,4 @@ __pycache__/
7373
*.py[cod]
7474

7575
# Planning docs
76-
CONTENT_PLANNING*.md
76+
CONTENT*.md

src/components/Navigation/NavToggle.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import styles from './navToggle.module.css'
1010
data-testid="nav-toggle"
1111
class:list={[
1212
'nav-toggle-btn',
13-
'lg:hidden inline-flex items-center justify-center rounded-full border-0 bg-primary-offset text-content-inverse transition-colors duration-150 ease-linear hover:bg-spotlight focus:bg-spotlight focus:outline-none',
13+
'lg:hidden inline-flex items-center justify-center rounded-full border-0 bg-primary text-content-inverse transition-colors duration-150 ease-linear hover:bg-spotlight focus:bg-primary-offset focus:outline-none',
1414
styles.button,
1515
]}
1616
type="button"
Lines changed: 20 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,20 @@
11
---
22
// Theme Picker Toggle Button
3+
import styles from './themeButton.module.css'
34
---
45

5-
<style>
6-
/* Theme picker button styles */
7-
.theme-toggle-btn {
8-
background-color: var(--color-primary);
9-
border-radius: 50%;
10-
border-width: 0;
11-
height: var(--header-icon-size);
12-
position: relative;
13-
transition: 0.15s linear;
14-
width: var(--header-icon-size);
15-
z-index: var(--z-content-overlay);
16-
}
17-
18-
.theme-toggle-btn:hover,
19-
.theme-toggle-btn:focus {
20-
background-color: var(--color-primary-offset);
21-
outline-width: 0;
22-
}
23-
24-
.theme-toggle-svg {
25-
height: var(--header-icon-size);
26-
position: relative;
27-
transform: rotate(0deg);
28-
transition: 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
29-
width: var(--header-icon-size);
30-
z-index: inherit;
31-
}
32-
33-
.theme-toggle-path {
34-
fill: var(--color-page-base);
35-
}
36-
37-
.theme-toggle-circle {
38-
fill: none;
39-
stroke-dasharray: var(--circle-stroke);
40-
stroke-dashoffset: var(--circle-stroke);
41-
stroke-linecap: round;
42-
stroke-width: 0.3rem;
43-
transition: stroke-dashoffset 0.3s linear 0.1s;
44-
}
45-
46-
/* Animation for theme picker active state */
47-
.theme-toggle-btn[aria-expanded='true'] .theme-toggle-svg {
48-
fill: var(--color-page-base);
49-
transform: rotate(90deg);
50-
}
51-
52-
.theme-toggle-btn[aria-expanded='true'] .theme-toggle-circle {
53-
stroke-dashoffset: 0;
54-
}
55-
</style>
56-
576
<button
58-
class="theme-toggle-btn themepicker-toggle__toggle-btn"
7+
class:list={[
8+
'theme-toggle-btn themepicker-toggle__toggle-btn',
9+
'relative inline-flex items-center justify-center',
10+
'w-(--header-icon-size) h-(--header-icon-size)',
11+
'rounded-full border-0',
12+
'bg-primary hover:bg-primary-offset',
13+
'focus:bg-primary-offset focus:outline-none focus-visible:bg-primary-offset',
14+
'transition-colors duration-150 ease-linear',
15+
'z-(--z-content-overlay)',
16+
styles.toggleBtn,
17+
]}
5918
type="button"
6019
aria-expanded="false"
6120
aria-controls="theme-picker-panel"
@@ -65,17 +24,22 @@
6524
>
6625
<svg
6726
viewBox="0 0 50 50"
68-
class="theme-toggle-svg"
27+
class:list={[
28+
'w-(--header-icon-size) h-(--header-icon-size)',
29+
'relative',
30+
'transition-transform duration-300 ease-[cubic-bezier(0.165,0.84,0.44,1)]',
31+
styles.toggleSvg,
32+
]}
6933
xmlns="http://www.w3.org/2000/svg"
7034
aria-hidden="true"
7135
focusable="false"
7236
>
7337
<g>
7438
<path
75-
class="theme-toggle-path"
39+
class:list={['fill-page-base']}
7640
d="M 31.6,15.4 V 14.2 C 31.6,13.54 31.06,13 30.4,13 H 16 c -0.66,0 -1.2,0.54 -1.2,1.2 V 19 c 0,0.66 0.54,1.2 1.2,1.2 h 14.4 c 0.66,0 1.2,-0.54 1.2,-1.2 v -1.2 h 1.2 v 4.8 h -12 v 13.2 c 0,0.66 0.54,1.2 1.2,1.2 h 2.4 c 0.66,0 1.2,-0.54 1.2,-1.2 V 25 h 9.6 v -9.6 z"
7741
></path>
78-
<circle class="theme-toggle-circle" r="23" cx="25" cy="25"></circle>
42+
<circle class={styles.toggleCircle} r="23" cx="25" cy="25"></circle>
7943
</g>
8044
</svg>
8145
</button>

src/components/ThemePicker/index.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const { closeComponent = 'close', label = 'Select theme' } = Astro.props
6666
<span class="themepicker__themeName">{theme.name}</span>
6767
{theme.description && (
6868
<span
69-
class="themepicker__tooltip absolute left-full top-full ml-1 mt-1 z-20 max-w-xs whitespace-normal break-words rounded-md border border-trim bg-content-inverse-inverse px-2 py-1 text-xs text-content-inverse opacity-0 pointer-events-none group-hover:opacity-100 group-focus:opacity-100 group-focus-visible:opacity-100"
69+
class="themepicker__tooltip absolute left-full top-full ml-1 mt-1 z-20 max-w-xs whitespace-normal wrap-break-word rounded-md border border-trim bg-content-inverse-inverse px-2 py-1 text-xs text-content-inverse opacity-0 pointer-events-none group-hover:opacity-100 group-focus:opacity-100 group-focus-visible:opacity-100"
7070
data-theme-tooltip
7171
>
7272
{theme.description}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.toggleCircle {
2+
fill: none;
3+
stroke-dasharray: var(--circle-stroke);
4+
stroke-dashoffset: var(--circle-stroke);
5+
stroke-linecap: round;
6+
stroke-width: 0.3rem;
7+
transition: stroke-dashoffset 0.3s linear 0.1s;
8+
}
9+
10+
.toggleBtn[aria-expanded='true'] .toggleSvg {
11+
fill: var(--color-page-base);
12+
transform: rotate(90deg);
13+
}
14+
15+
.toggleBtn[aria-expanded='true'] .toggleCircle {
16+
stroke-dashoffset: 0;
17+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
declare const styles: {
2+
readonly toggleBtn: string
3+
readonly toggleSvg: string
4+
readonly toggleCircle: string
5+
}
6+
7+
export default styles

0 commit comments

Comments
 (0)