Skip to content

Commit

Permalink
chore: expose all props to button
Browse files Browse the repository at this point in the history
  • Loading branch information
thisyahlen-deriv committed Feb 15, 2024
1 parent f0cf1b1 commit d8f45d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
21 changes: 5 additions & 16 deletions lib/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,28 @@ import './Button.scss';
type TVariant = 'contained' | 'ghost' | 'outlined';
type TColor = 'black' | 'primary-light' | 'primary' | 'white';

interface ButtonProps {
ariaLabel?: ComponentProps<'button'>['aria-label'];
interface ButtonProps extends ComponentProps<'button'> {
color?: TColor;
disabled?: ComponentProps<'button'>['disabled'];
icon?: ReactElement;
isFullWidth?: boolean;
isLoading?: boolean;
onClick?: ComponentProps<'button'>['onClick'];
rounded?: Extract<TGenericSizes, 'md' | 'sm'>;
size?: Extract<TGenericSizes, 'lg' | 'md' | 'sm'>;
textSize?: ComponentProps<typeof Text>['size'];
type?: ComponentProps<'button'>['type'];
variant?: TVariant;
className?: string;
}

export const Button = ({
ariaLabel,
children,
color = 'primary',
disabled = false,
icon,
isFullWidth = false,
isLoading = false,
onClick,
rounded = 'sm',
size = 'md',
textSize,
type,
variant = 'contained',
className
...props
}: PropsWithChildren<ButtonProps>) => {
const isContained = variant === 'contained';

Expand All @@ -49,7 +40,7 @@ export const Button = ({
`derivs-button__rounded--${rounded}`,
isContained && `derivs-button__color--${color}`,
isFullWidth && 'derivs-button__full-width',
className
props.className
);

type TButtonFontColor = {
Expand Down Expand Up @@ -94,11 +85,9 @@ export const Button = ({

return (
<button
aria-label={ariaLabel}
className={buttonClassNames}
disabled={disabled || isLoading}
onClick={onClick}
type={type}
disabled={props.disabled || isLoading}
{...props}
>
{isLoading && (
<div className='derivs-button__loader'>
Expand Down
2 changes: 1 addition & 1 deletion src/stories/Button.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const meta = {
options: ['contained', 'outlined', 'ghost'],
control: { type: 'radio' },
},
ariaLabel: {
'aria-label': {
table: {
disable: true,
}
Expand Down

0 comments on commit d8f45d1

Please sign in to comment.