import React, { useMemo } from 'react' import withDefaults from '../utils/with-defaults' import useTheme from '../styles/use-theme' interface Props { bash?: boolean darkBash?: boolean block?: boolean width?: string className?: string } const defaultProps = { bash: false, darkBash: false, block: false, className: '', } export type CodeProps = Props & typeof defaultProps & React.HTMLAttributes const Code: React.FC> = React.memo(({ children, block, bash, darkBash, className, width, ...props }) => { const theme = useTheme() const isBash = bash || darkBash const isBlock = isBash || block if (!isBlock) return {children} const classes = useMemo( () => `${darkBash ? 'dark' : ''} ${className}`, [className, darkBash] ) return ( <>
{children}
) }) export default withDefaults(Code, defaultProps)