1+ import { forwardRef } from "react"
12import { cn } from "@src/lib/utils"
23import { Button , StandardTooltip } from "@src/components/ui"
34import { Loader2 , LucideIcon } from "lucide-react"
@@ -11,40 +12,35 @@ interface LucideIconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonEle
1112 style ?: React . CSSProperties
1213}
1314
14- export const LucideIconButton : React . FC < LucideIconButtonProps > = ( {
15- icon,
16- title,
17- className,
18- disabled,
19- tooltip = true ,
20- isLoading,
21- onClick,
22- style,
23- ...props
24- } ) => {
25- const Icon = icon
26- return (
27- < StandardTooltip content = { tooltip ? title : undefined } >
28- < Button
29- aria-label = { title }
30- className = { cn (
31- "relative inline-flex items-center justify-center" ,
32- "bg-transparent border-none p-1.5" ,
33- "rounded-full" ,
34- "text-vscode-foreground opacity-85" ,
35- "transition-all duration-150" ,
36- "focus:outline-none focus-visible:ring-1 focus-visible:ring-vscode-focusBorder" ,
37- "active:bg-[rgba(255,255,255,0.1)]" ,
38- ! disabled && "cursor-pointer hover:opacity-100 hover:bg-[rgba(255,255,255,0.03)]" ,
39- disabled && "cursor-not-allowed opacity-40 hover:bg-transparent active:bg-transparent" ,
40- className ,
41- ) }
42- disabled = { disabled }
43- onClick = { ! disabled ? onClick : undefined }
44- style = { { fontSize : 16.5 , ...style } }
45- { ...props } >
46- { isLoading ? < Loader2 className = "size-2.5 animate-spin" /> : < Icon className = "size-2.5" /> }
47- </ Button >
48- </ StandardTooltip >
49- )
50- }
15+ export const LucideIconButton = forwardRef < HTMLButtonElement , LucideIconButtonProps > (
16+ ( { icon, title, className, disabled, tooltip = true , isLoading, onClick, style, ...props } , ref ) => {
17+ const Icon = icon
18+ return (
19+ < StandardTooltip content = { tooltip ? title : undefined } >
20+ < Button
21+ ref = { ref }
22+ aria-label = { title }
23+ className = { cn (
24+ "relative inline-flex items-center justify-center" ,
25+ "bg-transparent border-none p-1.5" ,
26+ "rounded-full" ,
27+ "text-vscode-foreground opacity-85" ,
28+ "transition-all duration-150" ,
29+ "focus:outline-none focus-visible:ring-1 focus-visible:ring-vscode-focusBorder" ,
30+ "active:bg-[rgba(255,255,255,0.1)]" ,
31+ ! disabled && "cursor-pointer hover:opacity-100 hover:bg-[rgba(255,255,255,0.03)]" ,
32+ disabled && "cursor-not-allowed opacity-40 hover:bg-transparent active:bg-transparent" ,
33+ className ,
34+ ) }
35+ disabled = { disabled }
36+ onClick = { ! disabled ? onClick : undefined }
37+ style = { { fontSize : 16.5 , ...style } }
38+ { ...props } >
39+ { isLoading ? < Loader2 className = "size-2.5 animate-spin" /> : < Icon className = "size-2.5" /> }
40+ </ Button >
41+ </ StandardTooltip >
42+ )
43+ } ,
44+ )
45+
46+ LucideIconButton . displayName = "LucideIconButton"
0 commit comments