-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Typography component for cmp library
- Loading branch information
1 parent
def532b
commit 31bb2fd
Showing
3 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)}; | ||
`; |