1- import { useThemeStore } from '@/lib/theme/store' ;
2- import { tokenValueToCss } from '@/lib/theme/color' ;
3- import { Badge } from '@/components/ui/badge' ;
4- import { Button } from '@/components/ui/button' ;
5- import { Card , CardContent , CardFooter , CardHeader , CardTitle } from '@/components/ui/card' ;
6- import { Input } from '@/components/ui/input' ;
7- import { Label } from '@/components/ui/label' ;
81import { Sun , Moon } from 'lucide-react' ;
92import { useMemo , useState } from 'react' ;
3+ import CardsPreview from '@/components/preview/cards-preview' ;
4+ import { Button } from '@/components/ui/button' ;
5+ import { tokenValueToCss } from '@/lib/theme/color' ;
6+ import { useThemeStore } from '@/lib/theme/store' ;
107
118const COLOR_TOKENS = [
129 'background' , 'foreground' ,
@@ -30,6 +27,7 @@ function buildVars(
3027
3128 for ( const token of COLOR_TOKENS ) {
3229 const val = colors [ token ] ;
30+
3331 if ( val ) {
3432 const css = tokenValueToCss ( val ) ;
3533 vars [ `--${ token } ` ] = css ;
@@ -68,93 +66,38 @@ export function ThemePreview() {
6866
6967 return (
7068 < div className = "flex h-full flex-col" >
71- < div className = "flex items-center justify-between border-b px-4 py-2" style = { { borderColor : 'var(--color-border)' } } >
72- < span className = "text-sm font-medium text-muted-foreground" > Preview</ span >
69+ < div
70+ className = "flex items-center justify-between border-b px-4 py-2"
71+ style = { { borderColor : 'var(--color-border)' } }
72+ >
73+ < span className = "text-sm font-medium text-muted-foreground" >
74+ Preview
75+ </ span >
7376 < Button variant = "outline" size = "sm" onClick = { toggleMode } >
7477 { previewMode === 'light' ? (
75- < > < Moon className = "mr-1 size-3.5" /> Dark</ >
78+ < >
79+ < Moon className = "mr-1 size-3.5" /> Dark
80+ </ >
7681 ) : (
77- < > < Sun className = "mr-1 size-3.5" /> Light</ >
82+ < >
83+ < Sun className = "mr-1 size-3.5" /> Light
84+ </ >
7885 ) }
7986 </ Button >
8087 </ div >
8188
8289 < div
8390 className = "flex-1 overflow-y-auto"
84- style = { { background : bgCss , color : fgCss } as React . CSSProperties }
91+ style = {
92+ {
93+ background : bgCss ,
94+ color : fgCss ,
95+ ...cssVars ,
96+ } as React . CSSProperties
97+ }
8598 >
86- < div className = "min-h-full p-6" style = { cssVars as React . CSSProperties } >
87- < p
88- className = "text-2xl font-bold"
89- style = { { fontFamily : `"${ fonts . serif } "` } }
90- >
91- Theme Preview
92- </ p >
93- < p className = "mt-1 mb-6 text-sm" style = { { color : 'var(--color-muted-foreground)' } } >
94- Sample UI components using your current palette.
95- </ p >
96-
97- < div className = "flex flex-wrap gap-2" >
98- < Button > Primary</ Button >
99- < Button variant = "secondary" > Secondary</ Button >
100- < Button variant = "outline" > Outline</ Button >
101- < Button variant = "ghost" > Ghost</ Button >
102- < Button variant = "destructive" > Destructive</ Button >
103- </ div >
104-
105- < Card className = "mt-6 max-w-sm" >
106- < CardHeader >
107- < CardTitle > Example Card</ CardTitle >
108- </ CardHeader >
109- < CardContent >
110- < p className = "text-sm" style = { { color : 'var(--color-muted-foreground)' } } >
111- This card demonstrates how your theme appears on standard
112- shadcn/ui components.
113- </ p >
114- </ CardContent >
115- < CardFooter className = "flex justify-between" >
116- < Button variant = "outline" > Cancel</ Button >
117- < Button > Save</ Button >
118- </ CardFooter >
119- </ Card >
120-
121- < Card className = "mt-4 max-w-sm" >
122- < CardHeader >
123- < CardTitle > Form Example</ CardTitle >
124- </ CardHeader >
125- < CardContent className = "space-y-3" >
126- < div className = "space-y-1" >
127- < Label htmlFor = "pv-email" > Email</ Label >
128- < Input id = "pv-email" placeholder = "you@example.com" />
129- </ div >
130- < div className = "space-y-1" >
131- < Label htmlFor = "pv-pw" > Password</ Label >
132- < Input id = "pv-pw" type = "password" placeholder = "••••••••" />
133- </ div >
134- </ CardContent >
135- </ Card >
136-
137- < div className = "mt-6 flex flex-wrap gap-2" >
138- < Badge > Default</ Badge >
139- < Badge variant = "secondary" > Secondary</ Badge >
140- < Badge variant = "outline" > Outline</ Badge >
141- < Badge variant = "destructive" > Destructive</ Badge >
142- </ div >
143-
144- < div
145- className = "mt-6 rounded-lg border p-4 space-y-1"
146- style = { { borderColor : 'var(--color-border)' } }
147- >
148- < p className = "font-mono text-xs" style = { { color : 'var(--color-muted-foreground)' } } >
149- SYSTEM — font-mono ({ fonts . mono } )
150- </ p >
151- < p style = { { fontFamily : `"${ fonts . serif } "` } } >
152- The quick brown fox jumps over the lazy dog — serif
153- </ p >
154- < p style = { { fontFamily : `"${ fonts . sans } "` } } >
155- The quick brown fox jumps over the lazy dog — sans
156- </ p >
157- </ div >
99+ < div className = "min-h-full p-6" >
100+ < CardsPreview />
158101 </ div >
159102 </ div >
160103 </ div >
0 commit comments