Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(button): introduce size variant #7348

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/site/components/Common/Button/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
@apply cursor-not-allowed;
}

&.small {
@apply px-3
py-2
text-sm;
ovflowd marked this conversation as resolved.
Show resolved Hide resolved
}

&.neutral {
@apply rounded
bg-neutral-900
Expand Down
15 changes: 14 additions & 1 deletion apps/site/components/Common/Button/index.stories.tsx
bmuenzenmeyer marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const Neutral: Story = {
kind: 'neutral',
children: 'Download Node (LTS)',
disabled: false,
size: 'default',
},
};

Expand All @@ -19,6 +20,7 @@ export const Primary: Story = {
kind: 'primary',
children: 'Download Node (LTS)',
disabled: false,
size: 'default',
},
};

Expand All @@ -27,6 +29,7 @@ export const Secondary: Story = {
kind: 'secondary',
children: 'Download Node (LTS)',
disabled: false,
size: 'default',
},
};

Expand All @@ -35,6 +38,7 @@ export const Special: Story = {
kind: 'special',
children: 'Download Node (LTS)',
disabled: false,
size: 'default',
},
};

Expand All @@ -48,7 +52,16 @@ export const WithIcon: Story = {
</>
),
disabled: false,
size: 'default',
},
};

export default { component: Button } as Meta;
export default {
component: Button,
argTypes: {
size: {
options: ['default', 'small'],
control: { type: 'radio' },
},
},
} as Meta;
9 changes: 8 additions & 1 deletion apps/site/components/Common/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import styles from './index.module.css';

type ButtonProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
kind?: 'neutral' | 'primary' | 'secondary' | 'special';
size?: 'default' | 'small';
disabled?: boolean;
};

const Button: FC<ButtonProps> = ({
kind = 'primary',
size = 'default',
disabled = false,
href = undefined,
children,
Expand Down Expand Up @@ -56,7 +58,12 @@ const Button: FC<ButtonProps> = ({
role="button"
href={disabled ? undefined : href}
aria-disabled={disabled}
className={classNames(styles.button, styles[kind], className)}
className={classNames(
styles.button,
styles[kind],
styles[size],
className
)}
tabIndex={disabled ? -1 : 0} // Ensure focusable if not disabled
onClick={onClickHandler}
onKeyDown={onKeyDownHandler}
Expand Down
Loading