import React from 'react' import { TextProps as RebaseTextProps, Text as RebassText } from 'rebass' import styled from 'styled-components' type FVSMap = { wght?: number slnt?: number wdth?: number GRAD?: number YOPQ?: number YTAS?: number YTDE?: number } function _formatFvsMap(fvsMap?: FVSMap) { if (!fvsMap) return null return Object.entries(fvsMap) .flatMap(([name, val]) => { return `"${name}" ${val}` }) .join(', ') } interface AuxProps { colour?: string fvs?: FVSMap fontVariationSettings?: FVSMap } const TextWrapper = styled(RebassText).attrs((props) => ({ fontSize: '1.2rem', ...props }))` color: ${({ colour, theme }): string => colour && (theme as any)[colour]}; ${({ fvs, fontVariationSettings }) => { const style = _formatFvsMap(fvs || fontVariationSettings) return style && `font-variation-settings: ${style};` }} ` export type TextProps = RebaseTextProps & AuxProps export const Text = { Main: styled(({ fontWeight, ...props }: TextProps) => ( ))``, Link: styled(({ fontWeight, ...props }: TextProps) => ( ))``, Black: styled(({ fontWeight, ...props }: TextProps) => ( ))``, White: styled(({ fontWeight, ...props }: TextProps) => ( ))``, Body: styled(({ fontWeight, ...props }: TextProps) => ( ))``, Basic: styled(({ fontWeight, ...props }: TextProps) => ( ))``, Header: styled(({ fontWeight, ...props }: TextProps) => ( ))``, SubHeader: styled(({ fontWeight, ...props }: TextProps) => ( ))``, LargeHeader: styled(({ fontWeight, ...props }: TextProps) => ( ))``, MediumHeader: styled(({ fontWeight, ...props }: TextProps) => ( ))``, Small: styled(({ fontWeight, ...props }: TextProps) => ( ))``, Blue: styled(({ fontWeight, ...props }: TextProps) => ( ))``, Yellow: styled(({ fontWeight, ...props }: TextProps) => ( ))``, DarkGray: styled(({ fontWeight, ...props }: TextProps) => ( ))``, Gray: styled(({ fontWeight, ...props }: TextProps) => ( ))``, Italic: styled(({ fontWeight, ...props }: TextProps) => ( ))``, Error: styled(({ fontWeight, ...props }: TextProps) => ( ))`` }