/* eslint-disable no-nested-ternary */ import React, { ReactNode } from 'react'; import styled from 'styled-components'; import { MarginProps, variant, WidthProps } from 'styled-system'; import { getThemeColor } from '@t3n/theme'; import Box from '../Box'; import Icon from '../Icon'; import Text from '../Text'; export type DividerVariants = 'primary' | 'inverse'; export interface DividerProps extends WidthProps, MarginProps { variant?: DividerVariants; iconComponent?: React.FC>; children?: ReactNode; } const StyledBox = styled(Box)>` ${variant({ variants: { primary: { color: 'text.primary', }, inverse: { color: 'text.inverse', }, }, })} `; const StyledLine = styled.span>` height: 1px; flex-grow: 1; opacity: 0.6; ${variant({ variants: { primary: { bg: 'text.primary', }, inverse: { bg: 'text.inverse', }, }, })} `; const StyledIcon = styled(Icon)>` fill: ${({ theme, variant: variantProp }) => getThemeColor(variantProp === 'inverse' ? 'text.inverse' : 'text.primary')({ theme, })}; `; const Divider: React.FC = ({ children, variant: variantProp = 'primary', iconComponent, my = 3, ...rest }) => ( {children ? ( {children} ) : iconComponent ? ( ) : null} {(children || iconComponent) && } ); export default Divider;