Skip to content

Commit

Permalink
feat: reduce right for layered effects
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasfrancisco committed Nov 15, 2024
1 parent 433cf17 commit 6edd4a7
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,17 @@ async function extractEffect(effect: Effect): Promise<ShadowValue | null> {
}

export async function extractEffectStyle(effectStyle: EffectStyle) {
const variableAlias = await Promise.all(
(effectStyle.boundVariables?.effects ?? []).map<Promise<AliasValue>>(
(value) => extractAlias(value.id)
)
);

console.log({ variableAlias });

const effectValues = await effectStyle.effects.reduce(
// reduceRight is used because for some reason figma order is reversed
const effectValues = await effectStyle.effects.reduceRight(
async (accumulator, effect) => {
const effectToken = await extractEffect(effect);
return effectToken ? [...(await accumulator), effectToken] : accumulator;
},
Promise.resolve([] as ShadowValue[])
);

console.log({ effects: effectStyle.effects });

const token = {
$type: 'shadow',
$value: effectValues,
Expand Down
69 changes: 49 additions & 20 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6edd4a7

Please sign in to comment.