Skip to content

Commit

Permalink
feat: Heading (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
RabbitDoge committed Oct 20, 2020
1 parent 0b97b9f commit 9e89a7a
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 1 deletion.
34 changes: 34 additions & 0 deletions src/components/Heading/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from "react";
import Heading from "./index";

export default {
title: "Heading",
component: Heading,
argTypes: {},
};

export const Sizes: React.FC = () => {
return (
<div>
<Heading>Default</Heading>
<Heading size="md">Size md</Heading>
<Heading size="lg">Size lg</Heading>
<Heading size="xl">Size xl</Heading>
<Heading size="xxl">Size xxl</Heading>
</div>
);
};

export const tags: React.FC = () => {
return (
<div>
<Heading>Default</Heading>
<Heading as="h1">Tag h1</Heading>
<Heading as="h2">Tag h2</Heading>
<Heading as="h3">Tag h3</Heading>
<Heading as="h4">Tag h4</Heading>
<Heading as="h5">Tag h5</Heading>
<Heading as="h6">Tag h6</Heading>
</div>
);
};
28 changes: 28 additions & 0 deletions src/components/Heading/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import styled from "styled-components";
import Text from "../Text";
import { tags, sizes, Props } from "./types";

const style = {
[sizes.MD]: {
fontSize: "20px",
},
[sizes.LG]: {
fontSize: "24px",
},
[sizes.XL]: {
fontSize: "40px",
},
[sizes.XXL]: {
fontSize: "64px",
},
};

const Heading = styled(Text).attrs({ bold: true })<Props>`
${({ size }) => style[size || sizes.MD]}
`;

Heading.defaultProps = {
as: tags.H2,
};

export default Heading;
23 changes: 23 additions & 0 deletions src/components/Heading/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export const tags = {
H1: "h1",
H2: "h2",
H3: "h3",
H4: "h4",
H5: "h5",
H6: "h6",
};

export const sizes = {
MD: "md",
LG: "lg",
XL: "xl",
XXL: "xxl",
};

type Tags = typeof tags[keyof typeof tags];
type Sizes = typeof sizes[keyof typeof sizes];

export interface Props {
as?: Tags;
size?: Sizes;
}
2 changes: 1 addition & 1 deletion src/components/Link/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface Props {
}

const Link = styled(Text).attrs({ as: "a", bold: true })<Props>`
color: ${({ theme }) => theme.colors.iris};
color: ${({ theme }) => theme.colors.primary};
&:hover {
text-decoration: underline;
}
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export { default as Button } from "./components/Button";
export { default as ButtonMenu } from "./components/ButtonMenu";
export { default as ButtonMenuItem } from "./components/ButtonMenu/ButtonMenuItem";
export { default as Card } from "./components/Card";
export { default as Heading } from "./components/Heading";
export { default as Text } from "./components/Text";
export { default as Link } from "./components/Link";
export { default as ResetCSS } from "./ResetCSS";
Expand Down

0 comments on commit 9e89a7a

Please sign in to comment.