@@ -67,6 +67,8 @@ const PRESETS: Preset[] = [
6767 } ,
6868] ;
6969
70+ const PRESET_ICONS = [ "◎" , "⊟" , "◤" , "◈" , "◢" ] ;
71+
7072function StateBadge ( ) {
7173 return useTransformComponent ( ( { state } ) => (
7274 < div
@@ -105,60 +107,120 @@ function StateBadge() {
105107 ) ) ;
106108}
107109
110+ function PresetButton ( {
111+ preset,
112+ icon,
113+ active,
114+ onClick,
115+ } : {
116+ preset : Preset ;
117+ icon : string ;
118+ active : boolean ;
119+ onClick : ( ) => void ;
120+ } ) {
121+ const [ hovered , setHovered ] = useState ( false ) ;
122+ const lit = active || hovered ;
123+
124+ return (
125+ < button
126+ type = "button"
127+ onClick = { onClick }
128+ onMouseEnter = { ( ) => setHovered ( true ) }
129+ onMouseLeave = { ( ) => setHovered ( false ) }
130+ style = { {
131+ position : "relative" ,
132+ display : "flex" ,
133+ alignItems : "center" ,
134+ gap : 7 ,
135+ padding : "7px 13px 7px 10px" ,
136+ borderRadius : 10 ,
137+ border : active
138+ ? "1px solid rgba(129, 140, 248, 0.45)"
139+ : "1px solid rgba(255,255,255,0.07)" ,
140+ background : active
141+ ? "linear-gradient(135deg, rgba(99,102,241,0.22), rgba(129,140,248,0.10))"
142+ : lit
143+ ? "rgba(255,255,255,0.06)"
144+ : "transparent" ,
145+ color : active ? "#c7d2fe" : lit ? "#d4d4d8" : "rgba(255,255,255,0.50)" ,
146+ fontSize : 12 ,
147+ fontWeight : 600 ,
148+ fontFamily : "inherit" ,
149+ cursor : "pointer" ,
150+ transition :
151+ "all 0.2s cubic-bezier(.4,0,.2,1)" ,
152+ boxShadow : active
153+ ? "0 0 12px rgba(99,102,241,0.15), 0 0 0 0.5px rgba(129,140,248,0.12) inset"
154+ : "none" ,
155+ } }
156+ >
157+ < span
158+ style = { {
159+ fontSize : 13 ,
160+ opacity : active ? 1 : 0.5 ,
161+ transition : "opacity 0.2s ease" ,
162+ } }
163+ >
164+ { icon }
165+ </ span >
166+ { preset . label }
167+ </ button >
168+ ) ;
169+ }
170+
108171export const Example : React . FC < Record < string , unknown > > = ( args ) => {
109172 const normalized = normalizeArgs ( args ) ;
110173 const [ presetIdx , setPresetIdx ] = useState ( 0 ) ;
111174 const preset = PRESETS [ presetIdx ] ;
112175
113176 return (
114- < div style = { { fontFamily : font } } >
177+ < div
178+ style = { {
179+ fontFamily : font ,
180+ padding : 20 ,
181+ borderRadius : 16 ,
182+ background :
183+ "linear-gradient(160deg, #0c0c18 0%, #101020 40%, #0e0e1c 100%)" ,
184+ border : "1px solid rgba(255,255,255,0.06)" ,
185+ maxWidth : 660 ,
186+ } }
187+ >
115188 { /* Preset selector */ }
116189 < div
117190 style = { {
118191 display : "flex" ,
119- flexWrap : "wrap " ,
192+ alignItems : "center " ,
120193 gap : 6 ,
121- marginBottom : 14 ,
194+ marginBottom : 12 ,
195+ padding : "6px 6px" ,
196+ borderRadius : 14 ,
197+ background : "rgba(255,255,255,0.02)" ,
198+ border : "1px solid rgba(255,255,255,0.05)" ,
199+ flexWrap : "wrap" ,
122200 } }
123201 >
124- { PRESETS . map ( ( p , i ) => {
125- const on = presetIdx === i ;
126- return (
127- < button
128- key = { p . label }
129- type = "button"
130- onClick = { ( ) => setPresetIdx ( i ) }
131- style = { {
132- padding : "8px 14px" ,
133- borderRadius : 10 ,
134- border : on
135- ? "1px solid rgba(129, 140, 248, 0.5)"
136- : "1px solid rgba(255,255,255,0.1)" ,
137- background : on
138- ? "rgba(99, 102, 241, 0.18)"
139- : "rgba(255,255,255,0.04)" ,
140- color : on ? "#c7d2fe" : "rgba(255,255,255,0.55)" ,
141- fontSize : 12 ,
142- fontWeight : 600 ,
143- fontFamily : "inherit" ,
144- cursor : "pointer" ,
145- transition : "background 0.15s ease, border-color 0.15s ease" ,
146- } }
147- >
148- { p . label }
149- </ button >
150- ) ;
151- } ) }
202+ { PRESETS . map ( ( p , i ) => (
203+ < PresetButton
204+ key = { p . label }
205+ preset = { p }
206+ icon = { PRESET_ICONS [ i ] }
207+ active = { presetIdx === i }
208+ onClick = { ( ) => setPresetIdx ( i ) }
209+ />
210+ ) ) }
152211 </ div >
153212
154213 { /* Config display */ }
155214 < div
156215 style = { {
157216 marginBottom : 14 ,
158- padding : "10px 14px" ,
159- borderRadius : 10 ,
160- background : "rgba(15, 15, 20, 0.6)" ,
217+ padding : "10px 16px" ,
218+ borderRadius : 12 ,
219+ background :
220+ "linear-gradient(135deg, rgba(15,15,25,0.85), rgba(20,20,35,0.65))" ,
161221 border : "1px solid rgba(255,255,255,0.06)" ,
222+ backdropFilter : "blur(8px)" ,
223+ WebkitBackdropFilter : "blur(8px)" ,
162224 display : "flex" ,
163225 flexWrap : "wrap" ,
164226 gap : "6px 20px" ,
@@ -168,22 +230,52 @@ export const Example: React.FC<Record<string, unknown>> = (args) => {
168230 < span
169231 style = { {
170232 fontSize : 12 ,
171- color : "rgba(255,255,255,0.4)" ,
172- fontFamily : "ui-monospace, monospace" ,
233+ color : "rgba(255,255,255,0.45)" ,
234+ fontFamily : "'SF Mono', 'Fira Code', ui-monospace, monospace" ,
235+ letterSpacing : "0.01em" ,
173236 } }
174237 >
175238 { preset . description }
176239 </ span >
177240 < span style = { { flex : 1 } } />
178- < code
241+ < span
179242 style = { {
180- fontSize : 11 ,
181- color : preset . centerOnInit ? "#34d399" : "#f87171" ,
182- fontFamily : "ui-monospace, monospace" ,
243+ display : "inline-flex" ,
244+ alignItems : "center" ,
245+ gap : 6 ,
246+ padding : "3px 10px" ,
247+ borderRadius : 6 ,
248+ background : preset . centerOnInit
249+ ? "rgba(52,211,153,0.08)"
250+ : "rgba(248,113,113,0.08)" ,
251+ border : preset . centerOnInit
252+ ? "1px solid rgba(52,211,153,0.18)"
253+ : "1px solid rgba(248,113,113,0.18)" ,
183254 } }
184255 >
185- centerOnInit: { preset . centerOnInit ? "true" : "false" }
186- </ code >
256+ < span
257+ style = { {
258+ width : 6 ,
259+ height : 6 ,
260+ borderRadius : "50%" ,
261+ background : preset . centerOnInit ? "#34d399" : "#f87171" ,
262+ boxShadow : preset . centerOnInit
263+ ? "0 0 6px rgba(52,211,153,0.5)"
264+ : "0 0 6px rgba(248,113,113,0.5)" ,
265+ } }
266+ />
267+ < code
268+ style = { {
269+ fontSize : 11 ,
270+ color : preset . centerOnInit
271+ ? "rgba(52,211,153,0.9)"
272+ : "rgba(248,113,113,0.9)" ,
273+ fontFamily : "'SF Mono', 'Fira Code', ui-monospace, monospace" ,
274+ } }
275+ >
276+ centerOnInit: { preset . centerOnInit ? "true" : "false" }
277+ </ code >
278+ </ span >
187279 </ div >
188280
189281 { /* Viewer — key forces remount on preset change */ }
@@ -214,19 +306,41 @@ export const Example: React.FC<Record<string, unknown>> = (args) => {
214306
215307 < p
216308 style = { {
217- margin : "14px 0 0" ,
309+ margin : "16px 0 0" ,
218310 fontSize : 12 ,
219- color : "rgba(148, 163, 184, 0.8 )" ,
220- lineHeight : 1.6 ,
311+ color : "rgba(148, 163, 184, 0.6 )" ,
312+ lineHeight : 1.7 ,
221313 maxWidth : 600 ,
314+ letterSpacing : "0.01em" ,
222315 } }
223316 >
224317 Switch presets above to remount the wrapper with different{ " " }
225- < code style = { { color : "#c7d2fe" } } > initialScale</ code > and{ " " }
226- < code style = { { color : "#c7d2fe" } } > initialPositionX/Y</ code > values. The
227- state badge shows live transform values. Use{ " " }
228- < strong style = { { color : "#d4d4d8" } } > Reset</ strong > to return to the
229- initial configuration.
318+ < code
319+ style = { {
320+ color : "#a5b4fc" ,
321+ padding : "1px 5px" ,
322+ borderRadius : 4 ,
323+ background : "rgba(99,102,241,0.1)" ,
324+ fontSize : 11 ,
325+ } }
326+ >
327+ initialScale
328+ </ code > { " " }
329+ and{ " " }
330+ < code
331+ style = { {
332+ color : "#a5b4fc" ,
333+ padding : "1px 5px" ,
334+ borderRadius : 4 ,
335+ background : "rgba(99,102,241,0.1)" ,
336+ fontSize : 11 ,
337+ } }
338+ >
339+ initialPositionX/Y
340+ </ code > { " " }
341+ values. The state badge shows live transform values. Use{ " " }
342+ < strong style = { { color : "#d4d4d8" , fontWeight : 600 } } > Reset</ strong > to
343+ return to the initial configuration.
230344 </ p >
231345 </ div >
232346 ) ;
0 commit comments