aboutsummaryrefslogtreecommitdiff
path: root/components/Box/index.tsx
blob: f81fa5b339484ba611b7110e8cac3424256b692a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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;