Skip to content

Commit

Permalink
Merged in develop (pull request #14)
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
nick-instant committed Oct 13, 2020
2 parents de3d8d2 + 037e092 commit c91ed3d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
37 changes: 22 additions & 15 deletions src/components/Typography/Text.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { Box } from '../Box';

import { withTheme } from 'styled-components';
import { themeGet } from '@styled-system/theme-get';

export const Text = ({ children, as = 'p', ...rest }) => <Box {...rest} as={as} __css={{
fontSize: 'inherit',
Expand Down Expand Up @@ -30,20 +31,26 @@ export const Paragraph = ({
);
}

export const Heading = ({
children,
level = '1',
variant = "heading.default",
...rest
}) => <Text
__css={{
fontSize: `heading${level}`,
lineHeight: `heading${level}`,
mb: "small",
}}
variant={variant}
{...rest}
as={`h${level}`}>{children}</Text>
export const Heading = withTheme(
({
children,
level = '1',
variant = "heading.default",
...rest
}) => {
const variantName = themeGet(variant + '.h'+level)(rest) ? variant + '.h'+level : variant;

return <Text
__css={{
fontSize: `heading${level}`,
lineHeight: `heading${level}`,
mb: "small",
}}
variant={variantName}
{...rest}
as={`h${level}`}>{children}</Text>
}
)



Expand Down
2 changes: 1 addition & 1 deletion src/components/Typography/stories/Heading.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const HeadingComponent = () => {
return (
<div>
{levelOption.map((level, index) => {
return <Heading level={level}
return <Heading key={index} level={level}
color={select("color",colorOption, 'black', themeId )}
fontFamily={select("fontFamily", fontFamilyOption, 'sans', themeId)}
>
Expand Down

0 comments on commit c91ed3d

Please sign in to comment.