Skip to content

Commit

Permalink
[🐛]: Fix an issue in recursion of defaultCSSVariableGenerator (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
mimshins authored Apr 17, 2024
1 parent d1fc7b6 commit 3832c48
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions lib/VariableGenerator/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ export const generateCssVariables = (
tokens: Props["tokens"],
generate: CSSVariableGenerator,
): GeneratedCSSVariables => {
const variables: GeneratedCSSVariables[] = [];

const recurse = (
const generateForParent = (
parent: Record<string, unknown>,
path: string[],
): GeneratedCSSVariables => {
Expand All @@ -51,19 +49,19 @@ export const generateCssVariables = (
return result;
}

return recurse(tokenValue, newPath);
const parentVariables = generateForParent(tokenValue, newPath);

result.push(...parentVariables);

return result;
},
[] as GeneratedCSSVariables,
);

variables.push(cssVariables);

return cssVariables;
};

recurse(tokens, []);

return variables.flat();
return generateForParent(tokens, []);
};

export const getCSSVariablesAsInlineStyle = (
Expand Down

0 comments on commit 3832c48

Please sign in to comment.