Skip to content

Commit 5cb3294

Browse files
committed
cli: refactor to use the new theme creator and added tests
1 parent aa53f2e commit 5cb3294

25 files changed

+930
-506
lines changed

apps/website/src/_state/make-it-yours.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ export const styleOptions: ThemeStyle[] = [
1616

1717
export const borderRadiusOptions: BorderRadius[] = [
1818
'border-radius-0',
19-
'border-radius-025',
20-
'border-radius-050',
21-
'border-radius-075',
19+
'border-radius-dot-25',
20+
'border-radius-dot-50',
21+
'border-radius-dot-75',
2222
'border-radius-1',
2323
];
2424

apps/website/src/components/make-it-yours/make-it-yours.tsx

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default component$(() => {
7575

7676
const { theme, setTheme } = useTheme();
7777

78-
const themeComputedObject = useComputed$(() => {
78+
const themeComputedObjectSig = useComputed$(() => {
7979
const themeArray = Array.isArray(theme) ? theme : theme?.split(' ');
8080
return {
8181
mode: themeArray?.[0] || 'light',
@@ -86,8 +86,8 @@ export default component$(() => {
8686
};
8787
});
8888

89-
const themeStoreToThemeClasses = $(() => {
90-
const { mode, style, base, primary, borderRadius } = themeComputedObject.value;
89+
const themeStoreToThemeClasses$ = $(() => {
90+
const { mode, style, base, primary, borderRadius } = themeComputedObjectSig.value;
9191
return [mode, style, base, primary, borderRadius];
9292
});
9393
return (
@@ -117,11 +117,11 @@ export default component$(() => {
117117
<label class="mb-1 block font-medium">Preset</label>
118118
<select
119119
class="bg-background rounded-base h-12 min-w-80 border p-2"
120-
value={themeComputedObject.value.style}
120+
value={themeComputedObjectSig.value.style}
121121
onChange$={async (e, el) => {
122-
themeComputedObject.value.style = el.value;
123-
console.log('themeComputedObject.value', themeComputedObject.value);
124-
setTheme(await themeStoreToThemeClasses());
122+
themeComputedObjectSig.value.style = el.value;
123+
console.log('themeComputedObject.value', themeComputedObjectSig.value);
124+
setTheme(await themeStoreToThemeClasses$());
125125
}}
126126
>
127127
<option value={'simple'}>Simple</option>
@@ -132,17 +132,17 @@ export default component$(() => {
132132
<label class="mb-1 mt-8 block font-medium">Base</label>
133133
<div class="flex">
134134
{baseOptions.map((base) => {
135-
const isActive = themeComputedObject.value.base === base;
135+
const isActive = themeComputedObjectSig.value.base === base;
136136

137137
return (
138138
<Button
139139
key={base}
140140
look="ghost"
141141
size="icon"
142142
onClick$={async () => {
143-
themeComputedObject.value.base = base;
143+
themeComputedObjectSig.value.base = base;
144144

145-
setTheme(await themeStoreToThemeClasses());
145+
setTheme(await themeStoreToThemeClasses$());
146146
}}
147147
class={cn(
148148
'flex h-4 w-4 items-center justify-center rounded-none',
@@ -167,7 +167,7 @@ export default component$(() => {
167167
<label class="mb-1 mt-8 block font-medium">Primary</label>
168168
<div class="grid grid-cols-[repeat(22,1fr)]">
169169
{primaryOptions.map((primary) => {
170-
const isActive = themeComputedObject.value.primary === primary;
170+
const isActive = themeComputedObjectSig.value.primary === primary;
171171

172172
if (
173173
primary.includes('slate-100') ||
@@ -189,8 +189,8 @@ export default component$(() => {
189189
look="ghost"
190190
size="icon"
191191
onClick$={async () => {
192-
themeComputedObject.value.primary = primary;
193-
setTheme(await themeStoreToThemeClasses());
192+
themeComputedObjectSig.value.primary = primary;
193+
setTheme(await themeStoreToThemeClasses$());
194194
}}
195195
class={cn(
196196
'flex h-4 w-4 items-center justify-center rounded-none',
@@ -437,14 +437,14 @@ export default component$(() => {
437437
<div class="flex flex-col space-y-2">
438438
{borderRadiusOptions.map((borderRadius) => {
439439
const isActive =
440-
themeComputedObject.value.borderRadius === borderRadius;
440+
themeComputedObjectSig.value.borderRadius === borderRadius;
441441
return (
442442
<Button
443443
key={borderRadius}
444444
look="outline"
445445
onClick$={async () => {
446-
themeComputedObject.value.borderRadius = borderRadius;
447-
setTheme(await themeStoreToThemeClasses());
446+
themeComputedObjectSig.value.borderRadius = borderRadius;
447+
setTheme(await themeStoreToThemeClasses$());
448448
}}
449449
class={cn(isActive && 'border-ring mb-2')}
450450
>
@@ -458,13 +458,15 @@ export default component$(() => {
458458
Dark Mode{' '}
459459
<input
460460
type="checkbox"
461-
checked={themeComputedObject.value.mode === 'dark'}
461+
checked={themeComputedObjectSig.value.mode === 'dark'}
462462
onClick$={async () => {
463-
themeComputedObject.value.mode =
464-
themeComputedObject.value.mode.includes('light') ? 'dark' : 'light';
463+
themeComputedObjectSig.value.mode =
464+
themeComputedObjectSig.value.mode.includes('light')
465+
? 'dark'
466+
: 'light';
465467

466-
console.log(themeComputedObject.value.mode);
467-
setTheme(await themeStoreToThemeClasses());
468+
console.log(themeComputedObjectSig.value.mode);
469+
setTheme(await themeStoreToThemeClasses$());
468470
}}
469471
/>
470472
</div>

apps/website/src/global.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,15 @@
162162
--border-radius: 0;
163163
}
164164

165-
.border-radius-025 {
165+
.border-radius-dot-25 {
166166
--border-radius: 0.25rem;
167167
}
168168

169-
.border-radius-050 {
169+
.border-radius-dot-50 {
170170
--border-radius: 0.5rem;
171171
}
172172

173-
.border-radius-075 {
173+
.border-radius-dot-75 {
174174
--border-radius: 0.75rem;
175175
}
176176

packages/cli-e2e/src/cli.smoke.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('Qwik UI CLI Smoke test', () => {
2323

2424
it('should be installed and add the button file', () => {
2525
execSync(
26-
'npx -y [email protected] init --e2e --projectRoot / --styledTheme "fluffy" --uiComponentsPath "src/components/ui" --rootCssPath "src/global.css" --installTailwind --components=button',
26+
'npx -y [email protected] init --e2e --projectRoot / --uiComponentsPath "src/components/ui" --rootCssPath "src/global.css" --installTailwind --style "simple" --borderRadius "0" --primaryColor "cyan-600" --components=button',
2727
{
2828
cwd: projectDirectory,
2929
stdio: 'inherit',

0 commit comments

Comments
 (0)