Skip to content

Commit

Permalink
feat: Add more states to buttons (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
RabbitDoge authored Oct 29, 2020
1 parent f09c44e commit d0d307e
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/components/Button/StyledButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const StyledButton = styled.button<ButtonProps>`
font-family: inherit;
font-size: 16px;
font-weight: 600;
width: ${({ fullWidth }) => (fullWidth ? "100%" : "auto")};
height: ${({ size }) => (size === "sm" ? "32px" : "48px")};
letter-spacing: 0.03em;
justify-content: center;
Expand Down Expand Up @@ -61,4 +62,9 @@ const StyledButton = styled.button<ButtonProps>`
}
`;

StyledButton.defaultProps = {
fullWidth: false,
as: "button",
};

export default StyledButton;
62 changes: 61 additions & 1 deletion src/components/Button/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import Button from "./index";
const Row = styled.div`
margin-bottom: 32px;
& > button + button {
& > button + button,
& > a + a {
margin-left: 16px;
}
`;
Expand Down Expand Up @@ -57,6 +58,65 @@ export const Default: React.FC = () => {
);
};

export const ButtonLink: React.FC = () => {
return (
<>
<Row>
<Button as="a">Primary</Button>
<Button as="a" disabled>
Disabled
</Button>
<Button as="a" size="sm">
Small
</Button>
</Row>
<Row>
<Button as="a" variant="secondary">
Secondary
</Button>
<Button as="a" variant="secondary" disabled>
Disabled
</Button>
<Button as="a" variant="secondary" size="sm">
Small
</Button>
</Row>
<Row>
<Button as="a" variant="tertiary">
Tertiary
</Button>
<Button as="a" variant="tertiary" disabled>
Disabled
</Button>
<Button as="a" variant="tertiary" size="sm">
Small
</Button>
</Row>
<Row>
<Button as="a" variant="text">
Text
</Button>
<Button as="a" variant="text" disabled>
Disabled
</Button>
<Button as="a" variant="text" size="sm">
Small
</Button>
</Row>
</>
);
};

export const WithProps: React.FC = () => {
return (
<>
<Row>
<Button fullWidth>Full size</Button>
</Row>
</>
);
};

const StartIcon = () => (
<span role="img" aria-label="cake" style={{ display: "inline-block", width: "100%", textAlign: "center" }}>
🥞
Expand Down
3 changes: 3 additions & 0 deletions src/components/Button/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
size?: Sizes;
startIcon?: ReactNode;
endIcon?: ReactNode;
fullWidth?: boolean;
as?: "a" | "button";
href?: string;
}

export type ButtonThemeVariant = {
Expand Down

0 comments on commit d0d307e

Please sign in to comment.