Skip to content

Commit

Permalink
feat(components): migrate Text to TypeScript (#581)
Browse files Browse the repository at this point in the history
alpha
  • Loading branch information
connor-baer committed May 4, 2020
1 parent 301414d commit 86f73dd
Show file tree
Hide file tree
Showing 27 changed files with 662 additions and 672 deletions.
2 changes: 1 addition & 1 deletion .storybook/components/BorderRadius.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const BorderRadius = ({ size, ...props }) => (
<div>
<Text as="span">{size}</Text>
<BorderRadiusSize>
<BorderRadiusName size={Text.KILO} as="span">
<BorderRadiusName size="kilo" as="span">
{light.borderRadius[size]}
</BorderRadiusName>
</BorderRadiusSize>
Expand Down
2 changes: 1 addition & 1 deletion .storybook/components/BorderWidth.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const BorderWidth = ({ size }) => (
<div>
<Text as="span">{size}</Text>
<BorderWidthSize>
<BorderWidthName size={Text.KILO} as="span">
<BorderWidthName size="kilo" as="span">
{light.borderWidth[size]}
</BorderWidthName>
</BorderWidthSize>
Expand Down
2 changes: 1 addition & 1 deletion .storybook/components/IconSize.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const IconSize = ({ size }) => (
<div>
<Text as="span">{size}</Text>
<IconSizeSize>
<IconSizeName size={Text.KILO} as="span">
<IconSizeName size="kilo" as="span">
{light.iconSizes[size]}
</IconSizeName>
</IconSizeSize>
Expand Down
8 changes: 4 additions & 4 deletions .storybook/components/Intro.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ const StyledText = styled(Text)(

const Intro = ({ children, ...props }) => (
<ThemeProvider theme={light}>
<StyledText size={Text.GIGA} {...props}>
<StyledText size="giga" {...props}>
{children}
</StyledText>
</ThemeProvider>
);

Intro.KILO = Text.KILO;
Intro.MEGA = Text.MEGA;
Intro.GIGA = Text.GIGA;
Intro.KILO = 'kilo';
Intro.MEGA = 'mega';
Intro.GIGA = 'giga';

export default Intro;
2 changes: 1 addition & 1 deletion .storybook/components/Spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const Spacing = ({ spacingName }) => (
<div>
<Text as="span">{spacingName}</Text>
<SpacingSize>
<SpacingName size={Text.KILO} as="span">
<SpacingName size="kilo" as="span">
{light.spacings[spacingName]}
</SpacingName>
</SpacingSize>
Expand Down
2 changes: 1 addition & 1 deletion .storybook/components/Statuses.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const Status = ({ variant = 'stable' }) => {

Status.Description = ({ children }) => (
<ThemeProvider theme={light}>
<Text size={Text.KILO} as="span" italic>
<Text size="kilo" as="span" italic>
{' '}
{children}
</Text>
Expand Down
2 changes: 1 addition & 1 deletion .storybook/components/Type.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const Type = ({ size, component, name, fontWeight, ...props }) => {
children: (
<Fragment>
This is {size}
<TypePx as="span" size={Text.KILO}>
<TypePx as="span" size="kilo">
{weight ? `${weight}` : `${fontSize}, ${lineHeight}`}
</TypePx>
</Fragment>
Expand Down
2 changes: 1 addition & 1 deletion .storybook/util/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const withThemeProvider = (Component, baseProps = {}) => (props = {}) => (
</ThemeProvider>
);

const TEXT_SIZE = Text.MEGA;
const TEXT_SIZE = 'mega';

const headingStyles = theme => css`
*:not(h1):not(h2):not(h3) + & {
Expand Down
10 changes: 5 additions & 5 deletions docs/advanced/theme.story.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ Avoid using `theme.typography` directly in your styles, rather use the specializ
#### Text

<Preview>
<Type size={Text.GIGA} component={Text} name="text" />
<Type size={Text.MEGA} component={Text} name="text" />
<Type size={Text.KILO} component={Text} name="text" />
<Type size="giga" component={Text} name="text" />
<Type size="mega" component={Text} name="text" />
<Type size="kilo" component={Text} name="text" />
</Preview>

### Font stack
Expand All @@ -243,8 +243,8 @@ theme.fontWeight.[regular|bold]
You can only toggle the boldness of `Text`, but not `Heading` or `Subheading`.

<Preview>
<Type size={Text.MEGA} bold component={Text} fontWeight="bold" name="text" />
<Type size={Text.MEGA} component={Text} fontWeight="regular" name="text" />
<Type size="mega" bold component={Text} fontWeight="bold" name="text" />
<Type size="mega" component={Text} fontWeight="regular" name="text" />
</Preview>

### Grid
Expand Down
15 changes: 7 additions & 8 deletions scripts/static-styles/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { light } from '@sumup/design-tokens';
import {
Badge,
Blockquote,
Button,
ButtonGroup,
Card,
Checkbox,
Expand All @@ -36,14 +35,12 @@ import {
Selector,
SubHeading,
Tag,
Text,
TextArea,
Toggle,
styleConstants
} from '../../src';

const { colorNames, sizes } = styleConstants;
const { KILO, MEGA, GIGA } = sizes;
const { colorNames } = styleConstants;

const element = props => <div {...props} />;

Expand Down Expand Up @@ -133,7 +130,8 @@ export default {
circle: PropTypes.bool
}
},
getComponentInfo(Button, { size: [KILO, MEGA, GIGA] }),
// TODO: Make React DocGen work with TypeScript
// getComponentInfo(Button, { size: [KILO, MEGA, GIGA] }),
getComponentInfo(Blockquote, {
size: [Blockquote.KILO, Blockquote.MEGA, Blockquote.GIGA]
}),
Expand Down Expand Up @@ -189,9 +187,10 @@ export default {
prefix: PropTypes.element,
suffix: PropTypes.element
}),
getComponentInfo(Text, {
size: [Text.KILO, Text.MEGA, Text.GIGA]
}),
// TODO: Make React DocGen work with TypeScript
// getComponentInfo(Text, {
// size: ['kilo', 'mega', 'giga']
// }),
getComponentInfo(TextArea),
getComponentInfo(Toggle)
]
Expand Down
Loading

0 comments on commit 86f73dd

Please sign in to comment.