import { ReactNode } from 'react'; import styled from '@emotion/styled'; import { css } from '@emotion/react'; import { mineShaft, mountainMeadow, nobel, pictonBlue, primary, secondary, treePoppy, valencia, white, } from 'styles/colors'; import { fontSize } from 'styles/fonts'; const COLORS_MAP = { default: mineShaft['800'], mineShaft: mineShaft.main, mountainMeadow: mountainMeadow.main, nobel: nobel.main, pictonBlue: pictonBlue.main, pictonBlueDark: pictonBlue['800'], primary: primary.main, secondary: secondary.main, treePoppy: treePoppy.main, valencia: valencia.main, }; const StyledPill = styled.span>` padding: 0.4em 0.4em; display: inline-block; font-size: ${({ size }) => size === 'small' ? fontSize.small : fontSize.regular}; font-weight: bold; line-height: 1; text-align: center; border: 1px solid; border-radius: 1em; border-color: ${({ variant = 'default' }) => COLORS_MAP[variant]}; ${({ solid, variant = 'default' }) => solid ? css` background-color: ${COLORS_MAP[variant]}; color: ${white}; ` : css` color: ${COLORS_MAP[variant]}; `}; `; interface Props { /** Size of Pill component */ size?: 'small' | 'default'; /** `true` for showing as solid background color */ solid?: boolean; /** Variant of Pill component */ variant?: keyof typeof COLORS_MAP; /** Text in the Pill component */ children: ReactNode; /** Rest Props */ [rest: string]: any; } /** * Pill component is label with a background color for displaying numerical value. */ const Pill = ({ size = 'default', solid = false, variant = 'default', children, ...rest }: Props) => ( {children} ); export default Pill;