diff --git a/src/builder/shadow.ts b/src/builder/shadow.ts index f984e582..f199ca48 100644 --- a/src/builder/shadow.ts +++ b/src/builder/shadow.ts @@ -24,7 +24,14 @@ const SCALE = 1.1 export function buildDropShadow( { id, width, height }: { id: string; width: number; height: number }, - style: Record + style: { + shadowColor: string[] + shadowOffset: { + width: number + height: number + }[] + shadowRadius: number[] + } ) { if ( !style.shadowColor || diff --git a/src/handler/expand.ts b/src/handler/expand.ts index 1a2daba9..9f054905 100644 --- a/src/handler/expand.ts +++ b/src/handler/expand.ts @@ -173,9 +173,9 @@ function handleSpecialCase( if (name === 'textShadow') { // Handle multiple text shadows if provided. value = value.toString().trim() + const result = {} if (value.includes(',')) { const shadows = splitEffects(value) - const result = {} for (const shadow of shadows) { const styles = getStylesForProperty('textShadow', shadow, true) for (const k in styles) { @@ -186,8 +186,14 @@ function handleSpecialCase( } } } - return result + } else { + const styles = getStylesForProperty('textShadow', value, true) + for (const k in styles) { + result[k] = [styles[k]] + } } + + return result } return @@ -255,6 +261,13 @@ type MainStyle = { gap: number rowGap: number columnGap: number + + textShadowOffset: { + width: number + height: number + }[] + textShadowColor: string[] + textShadowRadius: number[] } type OtherStyle = Exclude, keyof MainStyle> @@ -288,7 +301,7 @@ export default function expand( const name = getPropertyName(prop) const value = preprocess(style[prop], currentColor) - + console.log('::;name', name) try { const resolvedStyle = handleSpecialCase(name, value, currentColor) || @@ -300,6 +313,8 @@ export default function expand( ) Object.assign(serializedStyle, resolvedStyle) + + console.log(':::resolvedStyle', resolvedStyle) } catch (err) { throw new Error( err.message + diff --git a/src/text/index.ts b/src/text/index.ts index 57c8b22f..87b85c2b 100644 --- a/src/text/index.ts +++ b/src/text/index.ts @@ -439,13 +439,9 @@ export default async function* buildTextNodes( let filter = '' if (parentStyle.textShadowOffset) { - let { textShadowColor, textShadowOffset, textShadowRadius } = - parentStyle as any - if (!Array.isArray(parentStyle.textShadowOffset)) { - textShadowColor = [textShadowColor] - textShadowOffset = [textShadowOffset] - textShadowRadius = [textShadowRadius] - } + const { textShadowColor, textShadowOffset, textShadowRadius } = parentStyle + + console.log(':::parentStyle', parentStyle) filter = buildDropShadow( {