import { ReactNode } from 'react'; import styled from '@emotion/styled'; import { css } from '@emotion/react'; const FlagContainer = styled.div<{ variant: Props['variant'] }>` display: flex; ${({ theme: { rtl } }) => rtl && css` direction: rtl; `}; align-items: ${({ variant }) => { switch (variant) { case 'top': return 'flex-start'; case 'bottom': return 'flex-end'; case 'center': default: return 'center'; } }}; `; const FlagImage = styled.figure` margin: 0; /* reset */ ${({ theme: { rtl } }) => css` margin-${rtl ? 'left' : 'right'}: 1em;`} `; const FlagBody = styled.div` flex: 1; `; interface Props { /** The image to the left */ image?: ReactNode; /** Image placement variation */ variant?: 'top' | 'center' | 'bottom'; /** The descriptive content to the right */ children?: ReactNode; /** Rest Props */ [rest: string]: any; } /** * The Flag component (also known as media object) is composed of an image to the left, with descriptive content to the right. * The content area on the right can contain any other objects. Commonly, it contains text, but we could put lists, tables, or even other Flag inside. */ const Flag = ({ image = null, variant = 'center', children = null, ...rest }: Props) => ( {image} {children} ); export default Flag;