import React, { ReactNode, useMemo } from 'react' import withDefaults from '../utils/with-defaults' import useTheme from '../styles/use-theme' interface Props { caption?: ReactNode | string shadow?: boolean className?: string width?: string } const defaultProps = { caption: '' as ReactNode | string, shadow: false, className: '', } type NativeAttrs = Omit, keyof Props> export type DisplayProps = Props & typeof defaultProps & NativeAttrs const Display: React.FC> = ({ children, caption, shadow, className, width, ...props }) => { const theme = useTheme() const showShadow = useMemo(() => shadow && theme.type !== 'dark', [theme.type, shadow]) return (
{children}
{caption}
) } const MemoDisplay = React.memo(Display) export default withDefaults(MemoDisplay, defaultProps)