import typography from 'foundations/typography'; import { ComponentPropsWithRef } from 'react'; import styled from '@emotion/styled'; import { css } from '@emotion/react'; interface TypographyProps { color?: string; variant?: keyof typeof typography; noOfLines?: number; margin?: number; marginTop?: number; marginRight?: number; marginBottom?: number; marginLeft?: number; lineHeight?: number; } const Text = styled.div` ${({ variant = 'body2Regular' }) => variant in typography && typography[variant]}; ${({ color }) => color && css` color: ${color}; `}; ${({ noOfLines }) => noOfLines && css` overflow: hidden; display: -webkit-box; -webkit-line-clamp: ${noOfLines}; -webkit-box-orient: vertical; `} margin: ${({ margin = 0 }) => margin !== undefined && `${margin}px;`} ${({ marginTop }) => marginTop !== undefined && css` margin-top: ${marginTop}px; `} ${({ marginRight }) => marginRight !== undefined && css` margin-right: ${marginRight}px; `} ${({ marginBottom }) => marginBottom !== undefined && css` margin-bottom: ${marginBottom}px; `} ${({ marginLeft }) => marginLeft !== undefined && css` margin-left: ${marginLeft}px; `} ${({ lineHeight }) => lineHeight !== undefined && css` line-height: ${lineHeight}px}; `} `; export interface TextProps extends ComponentPropsWithRef {} export default Text;