-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update json shape for docs (#8308)
**Related Issue:** #8287 ## Summary This changes the new format "json" to "docs" to better capture where this platform output should be used. This replaces the folder "json" with "docs".
- Loading branch information
1 parent
1d7a64c
commit 6fac3e9
Showing
12 changed files
with
45 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/calcite-design-tokens/support/token-transformer/styleDictionary/formatter/docs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Core as StyleDictionary } from "style-dictionary"; | ||
import { CalledFormatterFunction, FormatterConfig } from "../../../types/styleDictionary/formatterArguments"; | ||
|
||
export const formatDocsPlatform: CalledFormatterFunction = (args) => { | ||
const output = { | ||
timestamp: Date.now(), | ||
tokens: {}, | ||
}; | ||
for (let i = 0; i < args.dictionary.allTokens.length; i++) { | ||
const token = args.dictionary.allTokens[i]; | ||
|
||
if (!output.tokens[token.type]) { | ||
output.tokens[token.type] = []; | ||
} | ||
output.tokens[token.type].push(token); | ||
} | ||
|
||
return JSON.stringify(output, null, 2); | ||
}; | ||
|
||
export const registerFormatterDocs = (sd: StyleDictionary): void => { | ||
const formatterConfig: FormatterConfig = { | ||
name: CalciteDocs, | ||
formatter: formatDocsPlatform, | ||
}; | ||
|
||
sd.registerFormat(formatterConfig); | ||
}; | ||
|
||
export const CalciteDocs = "calcite/format/docs"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters