import styled from 'styled-components'; import * as tokens from '@tokens'; import { mq } from '@tokensDir/media-query'; import { StyledBodyProps } from './interface'; const lrg = { mobile: { font: '20px', line: '28px' }, desktop: { font: '28px', line: '42px' } }; const md = { mobile: { font: '16px', line: '26px' }, desktop: { font: '24px', line: '37px' } }; const sml = { mobile: md.mobile, desktop: { font: '16px', line: '26px' } }; const xSml = { mobile: { font: '12px', line: '21px' }, desktop: { font: '12px', line: '21px' } }; const sizes = { lrg, md, sml, xSml }; const size = ({ variant = '' }: StyledBodyProps) => { if (!variant) { console.warn( `Unable to find variant on "" of type ${variant}. Variant should be one of xSml, sml, md, lrg` ); } return sizes[variant || 'lrg']; }; export default styled.p` font-family: ${tokens.fontBody}; font-weight: ${tokens.fontWeightNormal}; font-size: ${(props: StyledBodyProps) => size(props).mobile.font}; line-height: ${(props: StyledBodyProps) => size(props).mobile.line}; ${({ type }: StyledBodyProps) => type && `font-style: ${type};`} ${mq.md` font-size: ${(props: StyledBodyProps) => size(props).desktop.font}; line-height: ${(props: StyledBodyProps) => size(props).desktop.line}; `} `;