UNPKG

768 BJavaScriptView Raw
1import { Color } from '../../color';
2import { parseCSSShorthand } from './css-utils';
3/**
4 * Parse a string into ShadowCSSValues
5 * Supports any valid css box/text shadow combination.
6 *
7 * inspired by https://github.com/jxnblk/css-box-shadow/blob/master/index.js (MIT License)
8 *
9 * @param value
10 */
11export function parseCSSShadow(value) {
12 const data = parseCSSShorthand(value);
13 if (!data) {
14 return null;
15 }
16 const [offsetX, offsetY, blurRadius, spreadRadius] = data.values;
17 return {
18 inset: data.inset,
19 offsetX: offsetX,
20 offsetY: offsetY,
21 blurRadius: blurRadius,
22 spreadRadius: spreadRadius,
23 color: data.color ? new Color(data.color) : undefined,
24 };
25}
26//# sourceMappingURL=css-shadow.js.map
\No newline at end of file