import { getSystemStyle, SystemProps } from '../utils/systemProps';

interface BoxProps extends SystemProps {
  style?: React.CSSProperties;
  children?: React.ReactNode;
  el?: keyof React.ReactHTML;
};

const Box: React.FC<BoxProps> = ({ el, style, children, ...props}) => {
  const systemStyle = getSystemStyle(props, style);

  let Tag = el;

  if(!el) {
    Tag = 'div' as keyof React.ReactHTML;
  }

  return (
    // @ts-ignore
    <Tag style={systemStyle}>
      { children }
    </Tag>
  );
};

export default Box;
