Skip to content

Commit

Permalink
feat(Button): add size property
Browse files Browse the repository at this point in the history
  • Loading branch information
bramvanhoutte committed Jul 25, 2020
1 parent a1aaac0 commit bf87b2d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/Button/Button.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ Buttons make common actions more obvious and help users more easily perform them
<Button type="secondary">Click me</Button>
</Playground>

### Button sizes

<Playground>
<Button size="normal">Click me</Button>
<br/>
<Button size="small">Click me</Button>
</Playground>

### Button with an onClick function

<Playground>
Expand Down
4 changes: 4 additions & 0 deletions src/components/Button/Button.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
margin-right: 8px;
}

.small {
line-height: 18px;
}

.spinner {
width: 14px;
height: 14px;
Expand Down
4 changes: 4 additions & 0 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface Props {
prefixIcon?: React.ReactElement;
suffixIcon?: React.ReactElement;
name?: string;
size?: 'normal' | 'small';
}

const Button: React.FC<Props> = ({
Expand All @@ -30,20 +31,23 @@ const Button: React.FC<Props> = ({
prefixIcon,
suffixIcon,
name,
size = 'normal',
}: Props) => {
const buttonClassNames = classNames(
cssReset.ventura,
styles.button,
{
[styles.typePrimary]: type === 'primary',
[styles.typeSecondary]: type === 'secondary',
[styles.small]: size === 'small',
},
className,
);

const labelClassNames = classNames({
[styles.labelWithPrefixIcon]: Boolean(prefixIcon) || isLoading,
[styles.labelWithSuffixIcon]: Boolean(suffixIcon),
[styles.small]: size === 'small',
});

return (
Expand Down

0 comments on commit bf87b2d

Please sign in to comment.