File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 11import { ComponentProps , ReactElement , ReactNode } from 'react' ;
2+ import { match } from 'ts-pattern' ;
23
34import { cloneAsChild } from '@/lib/clone-as-child' ;
45import { cn } from '@/lib/tailwind/utils' ;
@@ -15,12 +16,16 @@ export const ResponsiveIconButton = ({
1516} : Omit < ComponentProps < typeof Button > , 'size' | 'children' > & {
1617 children : ReactElement < { children ?: ReactNode } > ;
1718 label : ReactNode ;
18- size ?: 'sm' | 'default' | 'lg' ;
19+ size ?: 'xs' | ' sm' | 'default' | 'lg' ;
1920 breakpoint ?: number ;
2021} ) => {
2122 const isMobile = useIsMobile ( breakpoint ) ;
22- const buttonIconSize =
23- size === 'default' ? 'icon' : ( `icon-${ size } ` as const ) ;
23+ const buttonIconSize = match ( size )
24+ . with ( 'default' , ( ) => 'icon' as const )
25+ . with ( 'xs' , ( ) => 'icon-xs' as const )
26+ . with ( 'sm' , ( ) => 'icon-sm' as const )
27+ . with ( 'lg' , ( ) => 'icon-lg' as const )
28+ . exhaustive ( ) ;
2429 const buttonSize = isMobile ? buttonIconSize : size ;
2530
2631 return (
You can’t perform that action at this time.
0 commit comments