Skip to content

Commit

Permalink
feat: Typography component for cmp library
Browse files Browse the repository at this point in the history
  • Loading branch information
vantaboard committed Sep 23, 2021
1 parent def532b commit 31bb2fd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/Elements/Typography/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React, { HTMLAttributes } from 'react';
import { TypographyProps } from './interface';
import { P } from './styles';

export default (
props: HTMLAttributes<HTMLParagraphElement> & TypographyProps
) => {
const { children, weight } = props;
return <P weight={weight}>{children}</P>;
};
10 changes: 10 additions & 0 deletions src/components/Elements/Typography/interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { theme } from './../../../theme';
const weight = theme.typography.weight;

export interface TypographyProps {
weight?:
| typeof weight.light
| typeof weight.regular
| typeof weight.bold
| typeof weight.black;
}
8 changes: 8 additions & 0 deletions src/components/Elements/Typography/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import styled from 'styled-components';
import { theme } from '../../../theme';
import { TypographyProps } from './interface';

export const P = styled('p')<TypographyProps>`
font-family: ${theme.typography.font.base};
font-weight: ${(p) => (p ? p.weight : theme.typography.weight.regular)};
`;

0 comments on commit 31bb2fd

Please sign in to comment.