Skip to content

Commit a90fd94

Browse files
committed
fix: responsive icon button
1 parent 0ab16c6 commit a90fd94

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

app/components/ui/responsive-icon-button.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ComponentProps, ReactElement, ReactNode } from 'react';
2+
import { match } from 'ts-pattern';
23

34
import { cloneAsChild } from '@/lib/clone-as-child';
45
import { 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 (

0 commit comments

Comments
 (0)