Skip to content

Commit 094fa47

Browse files
feat(button): introduce size variant (#7348)
1 parent 8b643f6 commit 094fa47

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

apps/site/components/Common/Button/index.module.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
@apply cursor-not-allowed;
1818
}
1919

20+
&.small {
21+
@apply px-3
22+
py-2
23+
text-sm;
24+
}
25+
2026
&.neutral {
2127
@apply rounded
2228
bg-neutral-900

apps/site/components/Common/Button/index.stories.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const Neutral: Story = {
1111
kind: 'neutral',
1212
children: 'Download Node (LTS)',
1313
disabled: false,
14+
size: 'default',
1415
},
1516
};
1617

@@ -19,6 +20,7 @@ export const Primary: Story = {
1920
kind: 'primary',
2021
children: 'Download Node (LTS)',
2122
disabled: false,
23+
size: 'default',
2224
},
2325
};
2426

@@ -27,6 +29,7 @@ export const Secondary: Story = {
2729
kind: 'secondary',
2830
children: 'Download Node (LTS)',
2931
disabled: false,
32+
size: 'default',
3033
},
3134
};
3235

@@ -35,6 +38,7 @@ export const Special: Story = {
3538
kind: 'special',
3639
children: 'Download Node (LTS)',
3740
disabled: false,
41+
size: 'default',
3842
},
3943
};
4044

@@ -48,7 +52,16 @@ export const WithIcon: Story = {
4852
</>
4953
),
5054
disabled: false,
55+
size: 'default',
5156
},
5257
};
5358

54-
export default { component: Button } as Meta;
59+
export default {
60+
component: Button,
61+
argTypes: {
62+
size: {
63+
options: ['default', 'small'],
64+
control: { type: 'radio' },
65+
},
66+
},
67+
} as Meta;

apps/site/components/Common/Button/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ import styles from './index.module.css';
1414

1515
type ButtonProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
1616
kind?: 'neutral' | 'primary' | 'secondary' | 'special';
17+
size?: 'default' | 'small';
1718
disabled?: boolean;
1819
};
1920

2021
const Button: FC<ButtonProps> = ({
2122
kind = 'primary',
23+
size = 'default',
2224
disabled = false,
2325
href = undefined,
2426
children,
@@ -56,7 +58,12 @@ const Button: FC<ButtonProps> = ({
5658
role="button"
5759
href={disabled ? undefined : href}
5860
aria-disabled={disabled}
59-
className={classNames(styles.button, styles[kind], className)}
61+
className={classNames(
62+
styles.button,
63+
styles[kind],
64+
styles[size],
65+
className
66+
)}
6067
tabIndex={disabled ? -1 : 0} // Ensure focusable if not disabled
6168
onClick={onClickHandler}
6269
onKeyDown={onKeyDownHandler}

0 commit comments

Comments
 (0)