@dnanpm/styleguide
Version:
DNA Styleguide repository provides the set of components and theme object used in various DNA projects.
29 lines (24 loc) • 1.04 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var theme = require('../themes/theme.js');
const getElevationShadow = ({ elevation, shadow, }) => {
const shadowConfig = {
none: [0, 0, 0],
low: [0, 2, 16, `${theme.default.color.default.black}0f`],
high: [0, 6, 24, `${theme.default.color.default.black}14`],
extraHigh: [0, 8, 64, `${theme.default.color.default.black}29`],
};
const sidesMap = shadow === null || shadow === void 0 ? void 0 : shadow.split(' ').map(Number);
const clipSize = sidesMap &&
shadowConfig[elevation]
.filter((arg) => typeof arg === 'number')
.reduce((sum, v) => sum + v);
const boxShadow = `box-shadow: ${shadowConfig[elevation].join('px ')};`;
const clipPath = sidesMap && clipSize
? `clip-path: inset(${sidesMap
.map(val => (val ? `-${clipSize}px` : '0px'))
.join(' ')});`
: '';
return `${boxShadow}${clipPath}`;
};
exports.default = getElevationShadow;