22
33import * as React from "react"
44import Script from "next/script"
5- import { DiceFaces05Icon , Undo02Icon } from "@hugeicons/core-free-icons"
5+ import { DiceFaces05Icon } from "@hugeicons/core-free-icons"
66import { HugeiconsIcon } from "@hugeicons/react"
77
8- import { cn } from "@/lib/utils"
98import {
109 BASE_COLORS ,
11- DEFAULT_CONFIG ,
1210 getThemesForBaseColor ,
1311 iconLibraries ,
1412 MENU_ACCENTS ,
@@ -18,6 +16,11 @@ import {
1816} from "@/registry/config"
1917import { Button } from "@/registry/new-york-v4/ui/button"
2018import { Kbd } from "@/registry/new-york-v4/ui/kbd"
19+ import {
20+ Tooltip ,
21+ TooltipContent ,
22+ TooltipTrigger ,
23+ } from "@/registry/new-york-v4/ui/tooltip"
2124import { useLocks } from "@/app/(create)/hooks/use-locks"
2225import { FONTS } from "@/app/(create)/lib/fonts"
2326import {
@@ -33,26 +36,10 @@ function randomItem<T>(array: readonly T[]): T {
3336 return array [ Math . floor ( Math . random ( ) * array . length ) ]
3437}
3538
36- export function CustomizerControls ( { className } : { className ?: string } ) {
39+ export function RandomButton ( ) {
3740 const { locks } = useLocks ( )
3841 const [ params , setParams ] = useDesignSystemSearchParams ( )
3942
40- const handleReset = React . useCallback ( ( ) => {
41- setParams ( {
42- base : params . base , // Keep the current base value
43- style : DEFAULT_CONFIG . style ,
44- baseColor : DEFAULT_CONFIG . baseColor ,
45- theme : DEFAULT_CONFIG . theme ,
46- iconLibrary : DEFAULT_CONFIG . iconLibrary ,
47- font : DEFAULT_CONFIG . font ,
48- menuAccent : DEFAULT_CONFIG . menuAccent ,
49- menuColor : DEFAULT_CONFIG . menuColor ,
50- radius : DEFAULT_CONFIG . radius ,
51- template : DEFAULT_CONFIG . template ,
52- item : "preview" ,
53- } )
54- } , [ setParams , params . base ] )
55-
5643 const handleRandomize = React . useCallback ( ( ) => {
5744 // Use current value if locked, otherwise randomize.
5845 const baseColor = locks . has ( "baseColor" )
@@ -130,33 +117,30 @@ export function CustomizerControls({ className }: { className?: string }) {
130117 } , [ handleRandomize ] )
131118
132119 return (
133- < div className = { cn ( "items-center gap-0" , className ) } >
134- < Button
135- variant = "ghost"
136- size = "sm"
137- onClick = { handleRandomize }
138- className = "border-foreground/10 bg-muted/50 h-[calc(--spacing(13.5))] w-[140px] touch-manipulation justify-between rounded-xl border select-none focus-visible:border-transparent focus-visible:ring-1 sm:rounded-lg md:w-full md:rounded-lg md:border-transparent md:bg-transparent md:pr-3.5! md:pl-2!"
139- >
140- < div className = "flex flex-col justify-start text-left" >
141- < div className = "text-muted-foreground text-xs" > Shuffle</ div >
142- < div className = "text-foreground text-sm font-medium" > Try Random</ div >
143- </ div >
144- < HugeiconsIcon icon = { DiceFaces05Icon } className = "size-5 md:hidden" />
145- < Kbd className = "bg-foreground/10 text-foreground hidden md:flex" > R</ Kbd >
146- </ Button >
147- < Button
148- variant = "ghost"
149- size = "sm"
150- onClick = { handleReset }
151- className = "border-foreground/10 bg-muted/50 hidden h-[calc(--spacing(13.5))] w-[140px] touch-manipulation justify-between rounded-xl border select-none focus-visible:border-transparent focus-visible:ring-1 sm:rounded-lg md:flex md:w-full md:rounded-lg md:border-transparent md:bg-transparent md:pr-3.5! md:pl-2!"
152- >
153- < div className = "flex flex-col justify-start text-left" >
154- < div className = "text-muted-foreground text-xs" > Reset</ div >
155- < div className = "text-foreground text-sm font-medium" > Start Over</ div >
156- </ div >
157- < HugeiconsIcon icon = { Undo02Icon } className = "-translate-x-0.5" />
158- </ Button >
159- </ div >
120+ < Tooltip >
121+ < TooltipTrigger asChild >
122+ < Button
123+ variant = "ghost"
124+ size = "sm"
125+ onClick = { handleRandomize }
126+ className = "border-foreground/10 bg-muted/50 h-[calc(--spacing(13.5))] w-[140px] touch-manipulation justify-between rounded-xl border select-none focus-visible:border-transparent focus-visible:ring-1 sm:rounded-lg md:w-full md:rounded-lg md:border-transparent md:bg-transparent md:pr-3.5! md:pl-2!"
127+ >
128+ < div className = "flex flex-col justify-start text-left" >
129+ < div className = "text-muted-foreground text-xs" > Shuffle</ div >
130+ < div className = "text-foreground text-sm font-medium" >
131+ Try Random
132+ </ div >
133+ </ div >
134+ < HugeiconsIcon icon = { DiceFaces05Icon } className = "size-5 md:hidden" />
135+ < Kbd className = "bg-foreground/10 text-foreground hidden md:flex" >
136+ R
137+ </ Kbd >
138+ </ Button >
139+ </ TooltipTrigger >
140+ < TooltipContent side = "left" >
141+ Use browser back/forward to navigate history
142+ </ TooltipContent >
143+ </ Tooltip >
160144 )
161145}
162146
0 commit comments