UNPKG

@wordpress/components

Version:
37 lines (36 loc) 991 B
import { useMemo } from "@wordpress/element"; import { useContextSystem } from "../context"; import * as styles from "./styles"; import { useCx } from "../utils/hooks/use-cx"; function useSurface(props) { const { backgroundSize = 12, borderBottom = false, borderLeft = false, borderRight = false, borderTop = false, className, variant = "primary", ...otherProps } = useContextSystem(props, "Surface"); const cx = useCx(); const classes = useMemo(() => { const sx = { borders: styles.getBorders({ borderBottom, borderLeft, borderRight, borderTop }) }; return cx(styles.Surface, sx.borders, styles.getVariant(variant, `${backgroundSize}px`, `${backgroundSize - 1}px`), className); }, [backgroundSize, borderBottom, borderLeft, borderRight, borderTop, className, cx, variant]); return { ...otherProps, className: classes }; } export { useSurface }; //# sourceMappingURL=hook.js.map