UNPKG

@wordpress/components

Version:
8 lines (7 loc) 1.78 kB
{ "version": 3, "sources": ["../../src/surface/hook.ts"], "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useContextSystem } from '../context';\nimport * as styles from './styles';\nimport { useCx } from '../utils/hooks/use-cx';\nexport function useSurface(props) {\n const {\n backgroundSize = 12,\n borderBottom = false,\n borderLeft = false,\n borderRight = false,\n borderTop = false,\n className,\n variant = 'primary',\n ...otherProps\n } = useContextSystem(props, 'Surface');\n const cx = useCx();\n const classes = useMemo(() => {\n const sx = {\n borders: styles.getBorders({\n borderBottom,\n borderLeft,\n borderRight,\n borderTop\n })\n };\n return cx(styles.Surface, sx.borders, styles.getVariant(variant, `${backgroundSize}px`, `${backgroundSize - 1}px`), className);\n }, [backgroundSize, borderBottom, borderLeft, borderRight, borderTop, className, cx, variant]);\n return {\n ...otherProps,\n className: classes\n };\n}"], "mappings": ";AAGA,SAAS,eAAe;AAKxB,SAAS,wBAAwB;AACjC,YAAY,YAAY;AACxB,SAAS,aAAa;AACf,SAAS,WAAW,OAAO;AAChC,QAAM;AAAA,IACJ,iBAAiB;AAAA,IACjB,eAAe;AAAA,IACf,aAAa;AAAA,IACb,cAAc;AAAA,IACd,YAAY;AAAA,IACZ;AAAA,IACA,UAAU;AAAA,IACV,GAAG;AAAA,EACL,IAAI,iBAAiB,OAAO,SAAS;AACrC,QAAM,KAAK,MAAM;AACjB,QAAM,UAAU,QAAQ,MAAM;AAC5B,UAAM,KAAK;AAAA,MACT,SAAgB,kBAAW;AAAA,QACzB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AACA,WAAO,GAAU,gBAAS,GAAG,SAAgB,kBAAW,SAAS,GAAG,cAAc,MAAM,GAAG,iBAAiB,CAAC,IAAI,GAAG,SAAS;AAAA,EAC/H,GAAG,CAAC,gBAAgB,cAAc,YAAY,aAAa,WAAW,WAAW,IAAI,OAAO,CAAC;AAC7F,SAAO;AAAA,IACL,GAAG;AAAA,IACH,WAAW;AAAA,EACb;AACF;", "names": [] }