mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-11 05:00:16 +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
90df8a31e7
commit
a3fc719a52
2 changed files with 2460 additions and 13 deletions
|
@ -5,8 +5,13 @@ import light from "./themes/light";
|
||||||
import Theme from "./themes/theme";
|
import Theme from "./themes/theme";
|
||||||
import { colors, fontFamilies, fontSizes, fontWeights } from "./tokens";
|
import { colors, fontFamilies, fontSizes, fontWeights } from "./tokens";
|
||||||
|
|
||||||
|
let themes = [
|
||||||
|
dark,
|
||||||
|
light
|
||||||
|
];
|
||||||
|
|
||||||
// Organize theme tokens
|
// Organize theme tokens
|
||||||
function themeTokens(theme: Theme): Object {
|
function themeTokens(theme: Theme) {
|
||||||
return {
|
return {
|
||||||
meta: {
|
meta: {
|
||||||
themeName: theme.name,
|
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
|
// Organize core tokens
|
||||||
const coreTokens = {
|
const coreTokens = {
|
||||||
color: {
|
color: {
|
||||||
|
@ -93,7 +88,28 @@ const coreTokens = {
|
||||||
size: fontSizes,
|
size: fontSizes,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const combinedTokens = {
|
||||||
|
core: coreTokens,
|
||||||
|
dark: themeTokens(dark),
|
||||||
|
light: themeTokens(light)
|
||||||
|
}
|
||||||
|
|
||||||
// Create core.json
|
// Create core.json
|
||||||
const corePath = path.resolve(`${__dirname}/figma/core.json`);
|
const corePath = path.resolve(`${__dirname}/figma/core.json`);
|
||||||
const coreTokenJSON = JSON.stringify(coreTokens, null, 2);
|
const coreJSON = JSON.stringify(coreTokens, null, 2);
|
||||||
fs.writeFileSync(corePath, coreTokenJSON);
|
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