From 2edf3e2a9092fc8ef5db54c20b7234f5bff96687 Mon Sep 17 00:00:00 2001 From: takanorip Date: Tue, 18 Oct 2022 20:03:38 +0900 Subject: [PATCH 1/3] add radius token --- scripts/figma.js | 25 ++++++++++++++++++++++++- tokens/size/radius.json | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tokens/size/radius.json diff --git a/scripts/figma.js b/scripts/figma.js index be483ae..69b2bc8 100644 --- a/scripts/figma.js +++ b/scripts/figma.js @@ -6,7 +6,6 @@ const writeFile = promisify(fs.writeFile); const TOKEN = process.env.FIGMA_TOKEN; const FIGMA_FILE_KEY = process.env.FIGMA_DESIGN_TOKEN_FILE_KEY; -const PREFIX = 'ubie'; const ROOT_FONT_SIZE = 16; const fetchFigma = (path) => @@ -150,10 +149,34 @@ const main = async () => { }, }); + // Generate Radius tokens + console.log(Object.values(componentNodes).filter(({ document }) => document.name.includes('Radius'))[0].document.cornerRadius); + const radius = {}; + Object.values(componentNodes) + .filter(({ document }) => document.name.includes('Radius')) + .forEach(({ document }) => { + const name = 'radius' + '-' + document.name.split('/')[1].toLowerCase(); + const srcValue = document.cornerRadius; + const value = Number(srcValue) / ROOT_FONT_SIZE; + radius[name] = { + value: value, + attributes: { + note: `${srcValue}px`, + }, + }; + }) + + const radiusContent = JSON.stringify({ + size: { + ...radius, + }, + }); + await writeFile(path.resolve(__dirname, '../tokens/color/primitive.json'), primitiveColorContent); await writeFile(path.resolve(__dirname, '../tokens/color/semantics.json'), semanticsColorContent); await writeFile(path.resolve(__dirname, '../tokens/size/spacing.json'), spacingContent); await writeFile(path.resolve(__dirname, '../tokens/text/typography.json'), typographyContent); + await writeFile(path.resolve(__dirname, '../tokens/size/radius.json'), radiusContent); console.log('DONE'); }; diff --git a/tokens/size/radius.json b/tokens/size/radius.json new file mode 100644 index 0000000..f2455f3 --- /dev/null +++ b/tokens/size/radius.json @@ -0,0 +1 @@ +{"size":{"radius-md":{"value":0.5,"attributes":{"note":"8px"}},"radius-full":{"value":624.9375,"attributes":{"note":"9999px"}},"radius-sm":{"value":0.25,"attributes":{"note":"4px"}},"radius-lg":{"value":0.75,"attributes":{"note":"12px"}},"radius-xs":{"value":0.125,"attributes":{"note":"2px"}}}} \ No newline at end of file From ac8e4cf94f1f1d2667e76c0a57a8536052576c09 Mon Sep 17 00:00:00 2001 From: takanorip Date: Wed, 19 Oct 2022 07:18:37 +0900 Subject: [PATCH 2/3] fix rule --- package-lock.json | 4 ++-- scripts/figma.js | 17 ++++++----------- tokens/size/radius.json | 2 +- tokens/size/spacing.json | 2 +- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 93a667f..228b300 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@ubie/design-tokens", - "version": "0.1.0", + "version": "0.1.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@ubie/design-tokens", - "version": "0.1.0", + "version": "0.1.2", "license": "Apache-2.0", "devDependencies": { "@ubie/prettier-config": "^0.1.0", diff --git a/scripts/figma.js b/scripts/figma.js index 69b2bc8..3d89a30 100644 --- a/scripts/figma.js +++ b/scripts/figma.js @@ -150,24 +150,19 @@ const main = async () => { }); // Generate Radius tokens - console.log(Object.values(componentNodes).filter(({ document }) => document.name.includes('Radius'))[0].document.cornerRadius); const radius = {}; Object.values(componentNodes) .filter(({ document }) => document.name.includes('Radius')) .forEach(({ document }) => { - const name = 'radius' + '-' + document.name.split('/')[1].toLowerCase(); - const srcValue = document.cornerRadius; - const value = Number(srcValue) / ROOT_FONT_SIZE; + const name = document.name.split('/')[1].toLowerCase(); + const value = document.cornerRadius; radius[name] = { - value: value, - attributes: { - note: `${srcValue}px`, - }, + value: `${value}px`, }; - }) - + }); + const radiusContent = JSON.stringify({ - size: { + radius: { ...radius, }, }); diff --git a/tokens/size/radius.json b/tokens/size/radius.json index f2455f3..7cbf0e5 100644 --- a/tokens/size/radius.json +++ b/tokens/size/radius.json @@ -1 +1 @@ -{"size":{"radius-md":{"value":0.5,"attributes":{"note":"8px"}},"radius-full":{"value":624.9375,"attributes":{"note":"9999px"}},"radius-sm":{"value":0.25,"attributes":{"note":"4px"}},"radius-lg":{"value":0.75,"attributes":{"note":"12px"}},"radius-xs":{"value":0.125,"attributes":{"note":"2px"}}}} \ No newline at end of file +{"radius":{"md":{"value":"8px"},"full":{"value":"9999px"},"sm":{"value":"4px"},"lg":{"value":"12px"},"xs":{"value":"2px"}}} \ No newline at end of file diff --git a/tokens/size/spacing.json b/tokens/size/spacing.json index 6c3a054..d9891a8 100644 --- a/tokens/size/spacing.json +++ b/tokens/size/spacing.json @@ -1 +1 @@ -{"size":{"spacing-lg":{"value":1.5,"attributes":{"note":"24px"}},"spacing-xxl":{"value":4,"attributes":{"note":"64px"}},"spacing-xl":{"value":2.5,"attributes":{"note":"40px"}},"spacing-sm":{"value":0.75,"attributes":{"note":"12px"}},"spacing-md":{"value":1,"attributes":{"note":"16px"}},"spacing-xs":{"value":0.5,"attributes":{"note":"8px"}},"spacing-xxs":{"value":0.25,"attributes":{"note":"4px"}}}} \ No newline at end of file +{"size":{"spacing-xxl":{"value":4,"attributes":{"note":"64px"}},"spacing-xs":{"value":0.5,"attributes":{"note":"8px"}},"spacing-xxs":{"value":0.25,"attributes":{"note":"4px"}},"spacing-md":{"value":1,"attributes":{"note":"16px"}},"spacing-lg":{"value":1.5,"attributes":{"note":"24px"}},"spacing-xl":{"value":2.5,"attributes":{"note":"40px"}},"spacing-sm":{"value":0.75,"attributes":{"note":"12px"}}}} \ No newline at end of file From 06e17f5ca25f80bda2ca4924d7ab7d6a3da36605 Mon Sep 17 00:00:00 2001 From: takanorip Date: Wed, 19 Oct 2022 07:18:55 +0900 Subject: [PATCH 3/3] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8005229..838ec01 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ubie/design-tokens", - "version": "0.1.2", + "version": "0.1.3", "description": "Ubie Design Tokens", "style": "dist/tokens.css", "main": "dist/tokens.js",