import { CSSProperties, ReactNode } from 'react' import classNames from 'classnames' import { CellGroup } from './CellGroup' import Icon from '../icon/Icon' import { CommonComponentProps } from '../../utils/types' import './Cell.scss' export * from './CellGroup' export interface CellProps extends CommonComponentProps { className?: string style?: CSSProperties children?: ReactNode header?: ReactNode title?: ReactNode label?: ReactNode body?: ReactNode footer?: ReactNode value?: ReactNode isLink?: boolean fullDisplay?: '' | 'body' | 'footer' icon?: ReactNode onClick?: () => any } export function Cell(props: CellProps) { const { className = '', children, header, title, label, body, footer, value, isLink = false, fullDisplay = 'body', icon, onClick, ...restProps } = props const cellClass = classNames( 's-cell', { 's-cell-is-link': isLink, }, className ) const bodyClass = classNames('s-cell-body', { 's-cell-body-full-display': fullDisplay === 'body', }) const footerClass = classNames('s-cell-footer', { 's-cell-footer-full-display': fullDisplay === 'footer', }) return (
{!children && header &&
{header}
}
{children ?? ( <> {body || (
{title &&
{title}
} {label &&
{label}
}
)} {footer || (
<> {value &&
{value}
} {(isLink || icon) && (
{icon ?? }
)}
)} )}
) } Cell.Group = CellGroup export default Cell