Skip to content

Commit

Permalink
docs: auto generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
maxholman committed Jun 23, 2024
1 parent abe0548 commit a85a967
Show file tree
Hide file tree
Showing 2 changed files with 951 additions and 504 deletions.
18 changes: 17 additions & 1 deletion bin/open-props-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,22 @@ const groupedTokens = Object.groupBy(Object.entries(tokens), ([, token]) =>
'$type' in token ? token.$type : 'other',
);

sourceFile.addStatements([
`/**
* This file was auto generated by @block65/react-design-system
*
* Original tokens from the open-props project by @argyleink
* https://github.com/argyleink/open-props
*
* WARN: Do not edit directly.
*
* Generated on ${new Date().toISOString()} by ${JSON.stringify(process.env.USER)}
*
*/`,
]);

for (const [group, tokenGroup] of Object.entries(groupedTokens)) {
sourceFile.addStatements(['', `// ${group}`]);
sourceFile.addStatements(['', `// Token Group: ${JSON.stringify(group)}`]);

if (tokenGroup) {
tokenGroup.sort(([a], [b]) => collator.compare(a, b));
Expand All @@ -23,6 +37,7 @@ for (const [group, tokenGroup] of Object.entries(groupedTokens)) {
sourceFile.addVariableStatement({
declarationKind: VariableDeclarationKind.Const,
isExported: true,
docs: [`Source CSS var: ${cssVarName}`],
declarations: [
{
name: camelCase(cssVarName, {
Expand All @@ -42,4 +57,5 @@ for (const [group, tokenGroup] of Object.entries(groupedTokens)) {
}
}

sourceFile.formatText();
process.stdout.write(`${sourceFile.getFullText()}\n`);
Loading

0 comments on commit a85a967

Please sign in to comment.