remove old shadow parser, fix only first shadow applying

This commit is contained in:
Henry Jameson 2024-10-02 23:59:56 +03:00
commit 02ecd8bb6c
6 changed files with 27 additions and 40 deletions

View file

@ -1,6 +1,6 @@
import { flattenDeep } from 'lodash'
const parseShadow = string => {
export const parseShadow = string => {
const modes = ['_full', 'inset', 'x', 'y', 'blur', 'spread', 'color', 'alpha']
const regexPrep = [
// inset keyword (optional)
@ -26,7 +26,12 @@ const parseShadow = string => {
const numeric = new Set(['x', 'y', 'blur', 'spread', 'alpha'])
const { x, y, blur, spread, alpha, inset, color } = Object.fromEntries(modes.map((mode, i) => {
if (numeric.has(mode)) {
return [mode, Number(result[i])]
const number = Number(result[i])
if (Number.isNaN(number)) {
if (mode === 'alpha') return [mode, 1]
return [mode, 0]
}
return [mode, number]
} else if (mode === 'inset') {
return [mode, !!result[i]]
} else {