Skip to content

Commit

Permalink
feat: migrate Heading to TypeScript (#594)
Browse files Browse the repository at this point in the history
* feat(components): migrate Heading to TypeScript

BREAKING CHANGE:
The Heading component doesn't export sizes anymore. Instead of writing `size={Heading.GIGA}`, write `size="giga"`.

feature/typescript-heading

* fix: use single string placeholder in spec names

feature/typescript-heading
  • Loading branch information
Robin Métral authored May 27, 2020
1 parent 9444fb0 commit 4675ef1
Show file tree
Hide file tree
Showing 18 changed files with 325 additions and 376 deletions.
2 changes: 1 addition & 1 deletion .storybook/components/Icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const Icons = () => {
) : (
group('category', activeIcons).map(({ category, items }) => (
<Category key={category}>
<Heading as="h3" size={Heading.GIGA}>
<Heading as="h3" size="giga">
{category}
</Heading>
<List>
Expand Down
2 changes: 1 addition & 1 deletion .storybook/components/Teaser.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Wrapper = styled(Card)(
const Teaser = ({ title, children, ...props }) => (
<ThemeProvider theme={light}>
<Wrapper shadow={Card.DOUBLE}>
<Heading as="h2" size={Heading.GIGA}>
<Heading as="h2" size="giga">
{title}
</Heading>

Expand Down
6 changes: 3 additions & 3 deletions .storybook/util/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ const subHeadingStyles = theme => css`
export const components = {
h1: withThemeProvider(Heading, {
as: 'h1',
size: Heading.ZETTA,
size: 'zetta',
css: headingStyles
}),
h2: withThemeProvider(Heading, {
as: 'h2',
size: Heading.PETA,
size: 'peta',
css: headingStyles
}),
h3: withThemeProvider(Heading, {
as: 'h3',
size: Heading.GIGA,
size: 'giga',
css: headingStyles
}),
h4: withThemeProvider(SubHeading, {
Expand Down
14 changes: 7 additions & 7 deletions docs/advanced/theme.story.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,13 @@ Avoid using `theme.typography` directly in your styles, rather use the specializ
#### Headings

<Preview>
<Type size={Heading.ZETTA} component={Heading} name="headings" />
<Type size={Heading.EXA} component={Heading} name="headings" />
<Type size={Heading.PETA} component={Heading} name="headings" />
<Type size={Heading.TERA} component={Heading} name="headings" />
<Type size={Heading.GIGA} component={Heading} name="headings" />
<Type size={Heading.MEGA} component={Heading} name="headings" />
<Type size={Heading.KILO} component={Heading} name="headings" />
<Type size="zetta" component={Heading} name="headings" />
<Type size="exa" component={Heading} name="headings" />
<Type size="peta" component={Heading} name="headings" />
<Type size="tera" component={Heading} name="headings" />
<Type size="giga" component={Heading} name="headings" />
<Type size="mega" component={Heading} name="headings" />
<Type size="kilo" component={Heading} name="headings" />
</Preview>

#### Subheading
Expand Down
23 changes: 11 additions & 12 deletions scripts/static-styles/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
ButtonGroup,
Card,
Checkbox,
Heading,
Hr,
Image,
Input,
Expand Down Expand Up @@ -147,17 +146,17 @@ export default {
getComponentInfo(Checkbox),
// TODO: Make React DocGen work with TypeScript
// getComponentInfo(Hamburger),
getComponentInfo(Heading, {
size: [
Heading.KILO,
Heading.MEGA,
Heading.GIGA,
Heading.TERA,
Heading.PETA,
Heading.EXA,
Heading.ZETTA
]
}),
// getComponentInfo(Heading, {
// size: [
// "kilo",
// "mega",
// "giga",
// "tera",
// "peta",
// "exa",
// "zetta"
// ]
// }),
{ name: 'hr', component: Hr },
{ name: 'image', component: Image },
getComponentInfo(Input, {
Expand Down
Loading

0 comments on commit 4675ef1

Please sign in to comment.