@@ -10,7 +10,8 @@ import {
10
10
cn ,
11
11
} from '@qwik-ui/utils' ;
12
12
import { LuSlidersHorizontal , LuX } from '@qwikest/icons/lucide' ;
13
- import { useTheme } from 'qwik-themes' ;
13
+ import { useTheme } from '@qwik-ui/themes' ;
14
+
14
15
import { Button , Modal , buttonVariants } from '~/components/ui' ;
15
16
16
17
import { useAppState } from '~/_state/use-app-state' ;
@@ -19,10 +20,10 @@ import CopyCssConfig from '../copy-css-config/copy-css-config';
19
20
export default component$ < PropsOf < typeof Button > > ( ( ) => {
20
21
const rootStore = useAppState ( ) ;
21
22
22
- const { theme , setTheme } = useTheme ( ) ;
23
+ const { themeSig } = useTheme ( ) ;
23
24
24
25
const themeComputedObjectSig = useComputed$ ( ( ) : ThemeConfig => {
25
- if ( ! theme || theme === 'light' ) {
26
+ if ( ! themeSig . value || themeSig . value === 'light' ) {
26
27
return {
27
28
font : ThemeFonts . SANS ,
28
29
mode : ThemeModes . LIGHT ,
@@ -33,7 +34,7 @@ export default component$<PropsOf<typeof Button>>(() => {
33
34
} ;
34
35
}
35
36
36
- if ( theme === 'dark' ) {
37
+ if ( themeSig . value === 'dark' ) {
37
38
return {
38
39
font : ThemeFonts . SANS ,
39
40
mode : ThemeModes . DARK ,
@@ -44,7 +45,9 @@ export default component$<PropsOf<typeof Button>>(() => {
44
45
} ;
45
46
}
46
47
47
- const themeArray = Array . isArray ( theme ) ? theme : theme . split ( ' ' ) ;
48
+ const themeArray = Array . isArray ( themeSig . value )
49
+ ? themeSig . value
50
+ : themeSig . value . split ( ' ' ) ;
48
51
return {
49
52
font : themeArray [ 0 ] ,
50
53
mode : themeArray [ 1 ] ,
@@ -91,7 +94,7 @@ export default component$<PropsOf<typeof Button>>(() => {
91
94
themeComputedObjectSig . value . font = ThemeFonts . SANS ;
92
95
}
93
96
themeComputedObjectSig . value . style = el . value ;
94
- setTheme ( await themeStoreToThemeClasses$ ( ) ) ;
97
+ themeSig . value = await themeStoreToThemeClasses$ ( ) ;
95
98
} }
96
99
>
97
100
< option value = { 'simple' } > Simple</ option >
@@ -114,7 +117,7 @@ export default component$<PropsOf<typeof Button>>(() => {
114
117
onClick$ = { async ( ) => {
115
118
themeComputedObjectSig . value . baseColor = baseColor ;
116
119
117
- setTheme ( await themeStoreToThemeClasses$ ( ) ) ;
120
+ themeSig . value = await themeStoreToThemeClasses$ ( ) ;
118
121
} }
119
122
class = { cn (
120
123
'flex h-3 w-3 items-center justify-center rounded-none' ,
@@ -165,7 +168,7 @@ export default component$<PropsOf<typeof Button>>(() => {
165
168
size = "icon"
166
169
onClick$ = { async ( ) => {
167
170
themeComputedObjectSig . value . primaryColor = primaryColor ;
168
- setTheme ( await themeStoreToThemeClasses$ ( ) ) ;
171
+ themeSig . value = await themeStoreToThemeClasses$ ( ) ;
169
172
} }
170
173
class = { cn (
171
174
'h-3 w-3 rounded-none' ,
@@ -182,7 +185,7 @@ export default component$<PropsOf<typeof Button>>(() => {
182
185
primaryColor === 'primary-zinc-900' ||
183
186
primaryColor === 'primary-neutral-900' ||
184
187
primaryColor === 'primary-stone-900' ) &&
185
- theme ?. includes ( 'dark' ) ? (
188
+ themeSig . value ?. includes ( 'dark' ) ? (
186
189
< span
187
190
class = { cn (
188
191
'flex h-[10px] w-[10px] shrink-0 rounded-none' ,
@@ -439,7 +442,7 @@ export default component$<PropsOf<typeof Button>>(() => {
439
442
look = "outline"
440
443
onClick$ = { async ( ) => {
441
444
themeComputedObjectSig . value . borderRadius = borderRadius ;
442
- setTheme ( await themeStoreToThemeClasses$ ( ) ) ;
445
+ themeSig . value = await themeStoreToThemeClasses$ ( ) ;
443
446
} }
444
447
class = { cn ( 'w-12' , isActive && 'mb-2 border-ring' ) }
445
448
>
@@ -462,7 +465,7 @@ export default component$<PropsOf<typeof Button>>(() => {
462
465
themeComputedObjectSig . value . mode =
463
466
themeComputedObjectSig . value . mode ?. includes ( 'light' ) ? 'dark' : 'light' ;
464
467
465
- setTheme ( await themeStoreToThemeClasses$ ( ) ) ;
468
+ themeSig . value = await themeStoreToThemeClasses$ ( ) ;
466
469
} }
467
470
/>
468
471
</ div >
@@ -471,7 +474,9 @@ export default component$<PropsOf<typeof Button>>(() => {
471
474
< footer class = " flex w-full justify-between gap-4" >
472
475
< Button
473
476
look = "ghost"
474
- onClick$ = { ( ) => setTheme ( theme ?. includes ( 'dark' ) ? 'dark' : 'light' ) }
477
+ onClick$ = { ( ) => {
478
+ themeSig . value = themeSig . value ?. includes ( 'dark' ) ? 'dark' : 'light' ;
479
+ } }
475
480
>
476
481
Reset
477
482
</ Button >
0 commit comments