Skip to content

Commit 33533ee

Browse files
committed
Refactors code to generate style-dictionary tokens
1 parent 63c8b9d commit 33533ee

File tree

13 files changed

+48
-248
lines changed

13 files changed

+48
-248
lines changed

style-dictionary-dist/button_variables.js

Lines changed: 0 additions & 69 deletions
This file was deleted.

style-dictionary-dist/button_variables.scss

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
// Do not edit directly
3-
// Generated on Mon, 28 Jun 2021 19:26:48 GMT
3+
// Generated on Fri, 02 Jul 2021 05:56:45 GMT
44

55
$tw-clr-btn-destructive-primary-fill: #d40002;
66
$tw-clr-btn-destructive-sold-fill-active: #ad0001;
@@ -38,6 +38,10 @@ $tw-sz-btn-small-min-width: 80px;
3838
$tw-sz-btn-medium-min-width: 100px;
3939
$tw-sz-btn-large-min-width: 120px;
4040
$tw-sz-btn-x-large-min-width: 140px;
41+
$tw-sz-btn-small-icon: $tw-fnt-btn-label-small-line-height;
42+
$tw-sz-btn-medium-icon: $tw-fnt-btn-label-medium-line-height;
43+
$tw-sz-btn-large-icon: $tw-fnt-btn-label-large-line-height;
44+
$tw-sz-btn-x-large-icon: $tw-fnt-btn-label-x-large-line-height;
4145
$tw-sz-btn-stroke: 2px;
4246
$tw-sz-btn-stroke-focus: 2px;
4347
$tw-fnt-btn-label-large-font-family: 'Inter', 'Inter-SemiBold';
@@ -58,9 +62,9 @@ $tw-fnt-btn-label-small-letter-spacing: 0px;
5862
$tw-fnt-btn-label-small-line-height: 20px;
5963
$tw-fnt-btn-label-small-font-weight: 600;
6064
$tw-fnt-btn-label-small-color: black;
61-
$tw-fnt-btn-label-xlarge-font-family: 'Inter', 'Inter-SemiBold';
62-
$tw-fnt-btn-label-xlarge-font-size: 24px;
63-
$tw-fnt-btn-label-xlarge-letter-spacing: 0px;
64-
$tw-fnt-btn-label-xlarge-line-height: 32px;
65-
$tw-fnt-btn-label-xlarge-font-weight: 600;
66-
$tw-fnt-btn-label-xlarge-color: black;
65+
$tw-fnt-btn-label-x-large-font-family: 'Inter', 'Inter-SemiBold';
66+
$tw-fnt-btn-label-x-large-font-size: 24px;
67+
$tw-fnt-btn-label-x-large-letter-spacing: 0px;
68+
$tw-fnt-btn-label-x-large-line-height: 32px;
69+
$tw-fnt-btn-label-x-large-font-weight: 600;
70+
$tw-fnt-btn-label-x-large-color: black;

style-dictionary-dist/system_variables.js

Lines changed: 0 additions & 94 deletions
This file was deleted.

style-dictionary/build.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
function build(source, destination) {
2+
const StyleDictionary = require('style-dictionary').extend({
3+
"source": source,
4+
"platforms": {
5+
"scss": {
6+
"transformGroup": "scss",
7+
"transforms": ["name/css_colors", "name/css_size", "name/css_typography"],
8+
"buildPath": "../style-dictionary-dist/",
9+
"files": [{
10+
"format": "scss/variables",
11+
"destination": destination,
12+
}]
13+
}
14+
}
15+
});
16+
17+
StyleDictionary.registerTransform(require('./transforms/name_css_colors.js'));
18+
StyleDictionary.registerTransform(require('./transforms/name_css_typography.js'));
19+
StyleDictionary.registerTransform(require('./transforms/name_css_size.js'));
20+
21+
StyleDictionary.buildAllPlatforms();
22+
}
23+
24+
build(["./json/button/**/*.json"], "button_variables.scss");
25+
build(["./json/system/**/*.json"], "system_variables.scss");

style-dictionary/button/build.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

style-dictionary/generate.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
rm -r style-dictionary-dist
44
mkdir style-dictionary-dist
5+
rm -r style-dictionary/json
6+
mkdir -p style-dictionary/json/system
7+
mkdir -p style-dictionary/json/button
58

6-
cd style-dictionary/system
7-
curl https://terraformation.zeroheight.com/api/token_file/59958aac0858/share > colors.json
8-
node build.js
9-
10-
cd ../button
11-
curl https://terraformation.zeroheight.com/api/token_file/cb5cd890ddf4/share > typography.json
12-
curl https://terraformation.zeroheight.com/api/token_file/2f90d49d4334/share > productive-colors.json
13-
curl https://terraformation.zeroheight.com/api/token_file/5e072293caf0/share > passive-colors.json
14-
curl https://terraformation.zeroheight.com/api/token_file/a170e0886291/share > destructive-colors.json
15-
curl https://terraformation.zeroheight.com/api/token_file/cfb0cfaf26bf/share > size.json
9+
cd style-dictionary
10+
curl https://terraformation.zeroheight.com/api/token_file/59958aac0858/share > json/system/colors.json
11+
curl https://terraformation.zeroheight.com/api/token_file/cb5cd890ddf4/share > json/button/typography.json
12+
curl https://terraformation.zeroheight.com/api/token_file/2f90d49d4334/share > json/button/productive-colors.json
13+
curl https://terraformation.zeroheight.com/api/token_file/5e072293caf0/share > json/button/passive-colors.json
14+
curl https://terraformation.zeroheight.com/api/token_file/a170e0886291/share > json/button/destructive-colors.json
15+
curl https://terraformation.zeroheight.com/api/token_file/cfb0cfaf26bf/share > json/button/size.json
1616
node build.js
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"Button":{"Small Height [$tw-sz-btn-small-height]":{"value":"32px"},"Medium Height [$tw-sz-btn-medium-height]":{"value":"40px"},"Large Height [$tw-sz-btn-large-height]":{"value":"48px"},"X-Large Height [$tw-sz-btn-x-large-height]":{"value":"56px"},"Small Min-Width [$tw-sz-btn-small-min-width]":{"value":"80px"},"Medium Min-Width [$tw-sz-btn-medium-min-width]":{"value":"100px"},"Large Min-Width [$tw-sz-btn-large-min-width]":{"value":"120px"},"X-Large Min-Width [$tw-sz-btn-x-large-min-width]":{"value":"140px"},"Stroke [$tw-sz-btn-stroke]":{"value":"2px"},"Stroke Focus [$tw-sz-btn-stroke-focus]":{"value":"2px"}}}
1+
{"Button":{"Small Height [$tw-sz-btn-small-height]":{"value":"32px"},"Medium Height [$tw-sz-btn-medium-height]":{"value":"40px"},"Large Height [$tw-sz-btn-large-height]":{"value":"48px"},"X-Large Height [$tw-sz-btn-x-large-height]":{"value":"56px"},"Small Min-Width [$tw-sz-btn-small-min-width]":{"value":"80px"},"Medium Min-Width [$tw-sz-btn-medium-min-width]":{"value":"100px"},"Large Min-Width [$tw-sz-btn-large-min-width]":{"value":"120px"},"X-Large Min-Width [$tw-sz-btn-x-large-min-width]":{"value":"140px"},"Small Icon [$tw-sz-btn-small-icon]":{"value":"$tw-fnt-btn-label-small-line-height"},"Medium Icon [$tw-sz-btn-medium-icon]":{"value":"$tw-fnt-btn-label-medium-line-height"},"Large Icon [$tw-sz-btn-large-icon]":{"value":"$tw-fnt-btn-label-large-line-height"},"X-Large Icon [$tw-sz-btn-x-large-icon]":{"value":"$tw-fnt-btn-label-x-large-line-height"},"Stroke [$tw-sz-btn-stroke]":{"value":"2px"},"Stroke Focus [$tw-sz-btn-stroke-focus]":{"value":"2px"}}}

0 commit comments

Comments
 (0)