Files
hudozka/src/ui/Box/index.tsx
T
2022-09-06 21:03:42 +03:00

34 lines
691 B
TypeScript

import s from "./box.module.css"
import classnames from "classnames/bind"
import { createElement } from "react"
const cx = classnames.bind(s)
export type BoxProps = {
as?: keyof HTMLElementTagNameMap
children?: React.ReactNode
style?: React.CSSProperties
wrap?: boolean
align?: boolean
vertical?: boolean
center?: boolean
}
export const Box: React.FC<BoxProps> = ({
as = "div",
wrap = false,
vertical = false,
center = false,
align = true,
style,
...props
}) => {
const newProps = {
className: cx(s.box, { vertical, align, center, wrap }),
style,
}
return createElement(as, newProps, props.children)
}