mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-27 19:02:07 +00:00
Add a combined tokens.json
for Figma Tokens
- Having individual json files for themes and core is useful for copy+pasting while exploring changes - Figma github sync requires a single json file to pull down
This commit is contained in:
parent
d029a5c376
commit
2d51b103d2
2 changed files with 2460 additions and 13 deletions
|
@ -5,8 +5,13 @@ import light from "./themes/light";
|
|||
import Theme from "./themes/theme";
|
||||
import { colors, fontFamilies, fontSizes, fontWeights } from "./tokens";
|
||||
|
||||
let themes = [
|
||||
dark,
|
||||
light
|
||||
];
|
||||
|
||||
// Organize theme tokens
|
||||
function themeTokens(theme: Theme): Object {
|
||||
function themeTokens(theme: Theme) {
|
||||
return {
|
||||
meta: {
|
||||
themeName: theme.name,
|
||||
|
@ -71,16 +76,6 @@ function themeTokens(theme: Theme): Object {
|
|||
};
|
||||
}
|
||||
|
||||
let themes = [themeTokens(dark), themeTokens(light)];
|
||||
|
||||
// Create {theme}.json
|
||||
const themePath = path.resolve(`${__dirname}/figma`);
|
||||
themes.forEach((theme) => {
|
||||
const tokenJSON = JSON.stringify(theme, null, 2);
|
||||
//@ts-ignore //TODO: IDK what the hell TS wants me to do here
|
||||
fs.writeFileSync(`${themePath}/${theme.meta.themeName}.json`, tokenJSON);
|
||||
});
|
||||
|
||||
// Organize core tokens
|
||||
const coreTokens = {
|
||||
color: {
|
||||
|
@ -93,7 +88,28 @@ const coreTokens = {
|
|||
size: fontSizes,
|
||||
};
|
||||
|
||||
const combinedTokens = {
|
||||
core: coreTokens,
|
||||
dark: themeTokens(dark),
|
||||
light: themeTokens(light)
|
||||
}
|
||||
|
||||
// Create core.json
|
||||
const corePath = path.resolve(`${__dirname}/figma/core.json`);
|
||||
const coreTokenJSON = JSON.stringify(coreTokens, null, 2);
|
||||
fs.writeFileSync(corePath, coreTokenJSON);
|
||||
const coreJSON = JSON.stringify(coreTokens, null, 2);
|
||||
fs.writeFileSync(corePath, coreJSON);
|
||||
console.log(`- Core: core.json created`);
|
||||
|
||||
// Create {theme}.json
|
||||
const themePath = path.resolve(`${__dirname}/figma`);
|
||||
themes.forEach((theme) => {
|
||||
const tokenJSON = JSON.stringify(themeTokens(theme), null, 2);
|
||||
fs.writeFileSync(`${themePath}/${theme.name}.json`, tokenJSON);
|
||||
console.log(`- Theme: ${theme.name}.json created`);
|
||||
});
|
||||
|
||||
// Create combined tokens.json
|
||||
const combinedPath = path.resolve(`${__dirname}/figma/tokens.json`);
|
||||
const combinedJSON = JSON.stringify(combinedTokens, null, 2);
|
||||
fs.writeFileSync(combinedPath, combinedJSON);
|
||||
console.log(`- Combined: tokens.json created`);
|
2431
styles/figma/tokens.json
Normal file
2431
styles/figma/tokens.json
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue