Skip to content

Commit 2f80da2

Browse files
authoredApr 19, 2024··
Format options improvements (#1165)
* feat: move file options inside the file.options obj * fix: formats using formatHelpers respect formatting

35 files changed

+880
-614
lines changed
 

Diff for: ‎.changeset/chilly-worms-vanish.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
'style-dictionary': patch
3+
---
4+
5+
All formats using `createPropertyFormatter` or `formattedVariables` helpers now respect the `file.options.formatting` option passed by users to customize formatting.
6+
7+
Example:
8+
9+
```js
10+
{
11+
platforms: {
12+
css: {
13+
transformGroup: 'css',
14+
buildPath,
15+
files: [
16+
{
17+
destination: 'variables.css',
18+
format: 'css/variables',
19+
options: {
20+
formatting: { indentation: ' ' },
21+
},
22+
},
23+
]
24+
}
25+
}
26+
}
27+
```

Diff for: ‎.changeset/smooth-jobs-attack.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
'style-dictionary': major
3+
---
4+
5+
BREAKING: `className`, `packageName`, `mapName` and `type` options for a bunch of built-in formats have been moved from `file` to go inside the `file.options` object, for API consistency reasons.
6+
7+
Before:
8+
9+
```json
10+
{
11+
"files": [{
12+
"destination": "tokenmap.scss",
13+
"format": "scss/map-deep",
14+
"mapName": "tokens"
15+
}]
16+
}
17+
```
18+
19+
After:
20+
21+
```json
22+
{
23+
"files": [{
24+
"destination": "tokenmap.scss",
25+
"format": "scss/map-deep",
26+
"options": {
27+
"mapName": "tokens"
28+
}
29+
}]
30+
}
31+
```

Diff for: ‎__integration__/__snapshots__/css.test.snap.js

+165-165
Original file line numberDiff line numberDiff line change
@@ -8,171 +8,171 @@ snapshots["integration css css/variables should match snapshot"] =
88
*/
99
1010
:root {
11-
--breakpoint-xs: 304px;
12-
--breakpoint-sm: 768px;
13-
--breakpoint-md: calc(304px / 768px);
14-
--color-background-primary: #ffffff;
15-
--color-background-secondary: #f3f4f4;
16-
--color-background-tertiary: #dee1e1;
17-
--color-background-danger: #ffeae9;
18-
--color-background-warning: #ffede3;
19-
--color-background-success: #ebf9eb;
20-
--color-background-info: #e9f8ff;
21-
--color-background-disabled: #dee1e1;
22-
--color-border-primary: #c8cccc;
23-
--color-brand-primary: #0b8599;
24-
--color-brand-secondary: #6f5ed3;
25-
--color-core-green-0: #ebf9eb;
26-
--color-core-green-100: #d7f4d7;
27-
--color-core-green-200: #c2f2bd;
28-
--color-core-green-300: #98e58e;
29-
--color-core-green-400: #75dd66;
30-
--color-core-green-500: #59cb59;
31-
--color-core-green-600: #2bb656;
32-
--color-core-green-700: #0ca750;
33-
--color-core-green-800: #008b46;
34-
--color-core-green-900: #006b40;
35-
--color-core-green-1000: #08422f;
36-
--color-core-green-1100: #002b20;
37-
--color-core-teal-0: #e5f9f5;
38-
--color-core-teal-100: #cdf7ef;
39-
--color-core-teal-200: #b3f2e6;
40-
--color-core-teal-300: #7dead5;
41-
--color-core-teal-400: #24e0c5;
42-
--color-core-teal-500: #08c4b2;
43-
--color-core-teal-600: #00a99c;
44-
--color-core-teal-700: #0b968f;
45-
--color-core-teal-800: #067c7c;
46-
--color-core-teal-900: #026661;
47-
--color-core-teal-1000: #083f3f;
48-
--color-core-teal-1100: #002528;
49-
--color-core-aqua-0: #d9fcfb;
50-
--color-core-aqua-100: #c5f9f9;
51-
--color-core-aqua-200: #a5f2f2;
52-
--color-core-aqua-300: #76e5e2;
53-
--color-core-aqua-400: #33d6e2;
54-
--color-core-aqua-500: #17b8ce;
55-
--color-core-aqua-600: #0797ae;
56-
--color-core-aqua-700: #0b8599;
57-
--color-core-aqua-800: #0f6e84;
58-
--color-core-aqua-900: #035e73;
59-
--color-core-aqua-1000: #083d4f;
60-
--color-core-aqua-1100: #002838;
61-
--color-core-blue-0: #e9f8ff;
62-
--color-core-blue-100: #dcf2ff;
63-
--color-core-blue-200: #c7e4f9;
64-
--color-core-blue-300: #a1d2f8;
65-
--color-core-blue-400: #56adf5;
66-
--color-core-blue-500: #3896e3;
67-
--color-core-blue-600: #2b87d3;
68-
--color-core-blue-700: #2079c3;
69-
--color-core-blue-800: #116daa;
70-
--color-core-blue-900: #0c5689;
71-
--color-core-blue-1000: #0a3960;
72-
--color-core-blue-1100: #002138;
73-
--color-core-purple-0: #f2f2f9;
74-
--color-core-purple-100: #eaeaf9;
75-
--color-core-purple-200: #d8d7f9;
76-
--color-core-purple-300: #c1c1f7;
77-
--color-core-purple-400: #a193f2;
78-
--color-core-purple-500: #9180f4;
79-
--color-core-purple-600: #816fea;
80-
--color-core-purple-700: #6f5ed3;
81-
--color-core-purple-800: #5e4eba;
82-
--color-core-purple-900: #483a9c;
83-
--color-core-purple-1000: #2d246b;
84-
--color-core-purple-1100: #1d1d38;
85-
--color-core-magenta-0: #fef0ff;
86-
--color-core-magenta-100: #f9e3fc;
87-
--color-core-magenta-200: #f4c4f7;
88-
--color-core-magenta-300: #edadf2;
89-
--color-core-magenta-400: #f282f5;
90-
--color-core-magenta-500: #db61db;
91-
--color-core-magenta-600: #c44eb9;
92-
--color-core-magenta-700: #ac44a8;
93-
--color-core-magenta-800: #8f3896;
94-
--color-core-magenta-900: #6c2277;
95-
--color-core-magenta-1000: #451551;
96-
--color-core-magenta-1100: #29192d;
97-
--color-core-pink-0: #ffe9f3;
98-
--color-core-pink-100: #fcdbeb;
99-
--color-core-pink-200: #ffb5d5;
100-
--color-core-pink-300: #ff95c1;
101-
--color-core-pink-400: #ff76ae;
102-
--color-core-pink-500: #ef588b;
103-
--color-core-pink-600: #e0447c;
104-
--color-core-pink-700: #ce3665;
105-
--color-core-pink-800: #b22f5b;
106-
--color-core-pink-900: #931847;
107-
--color-core-pink-1000: #561231;
108-
--color-core-pink-1100: #2b1721;
109-
--color-core-red-0: #ffeae9;
110-
--color-core-red-100: #ffd5d2;
111-
--color-core-red-200: #ffb8b1;
112-
--color-core-red-300: #ff9c8f;
113-
--color-core-red-400: #ff7f6e;
114-
--color-core-red-500: #f76054;
115-
--color-core-red-600: #ed4c42;
116-
--color-core-red-700: #db3e3e;
117-
--color-core-red-800: #c63434;
118-
--color-core-red-900: #992222;
119-
--color-core-red-1000: #6d1313;
120-
--color-core-red-1100: #2b1111;
121-
--color-core-orange-0: #ffede3;
122-
--color-core-orange-100: #fcdccc;
123-
--color-core-orange-200: #ffc6a4;
124-
--color-core-orange-300: #ffb180;
125-
--color-core-orange-400: #ff9c5d;
126-
--color-core-orange-500: #fc8943;
127-
--color-core-orange-600: #f57d33;
128-
--color-core-orange-700: #ed7024;
129-
--color-core-orange-800: #ce5511;
130-
--color-core-orange-900: #962c0b;
131-
--color-core-orange-1000: #601700;
132-
--color-core-orange-1100: #2d130e;
133-
--color-core-neutral-0: #ffffff;
134-
--color-core-neutral-100: #f3f4f4;
135-
--color-core-neutral-200: #dee1e1;
136-
--color-core-neutral-300: #c8cccc;
137-
--color-core-neutral-400: #b0b6b7;
138-
--color-core-neutral-500: #929a9b;
139-
--color-core-neutral-600: #6e797a;
140-
--color-core-neutral-700: #515e5f;
141-
--color-core-neutral-800: #364141;
142-
--color-core-neutral-900: #273333;
143-
--color-core-neutral-1000: #162020;
144-
--color-core-neutral-1100: #040404;
145-
--color-core-yellow-0: #fff8e2;
146-
--color-core-yellow-100: #fdefcd;
147-
--color-core-yellow-200: #ffe99a;
148-
--color-core-yellow-300: #ffe16e;
149-
--color-core-yellow-400: #ffd943;
150-
--color-core-yellow-500: #ffcd1c;
151-
--color-core-yellow-600: #ffbc00;
152-
--color-core-yellow-700: #dd9903;
153-
--color-core-yellow-800: #ba7506;
154-
--color-core-yellow-900: #944c0c;
155-
--color-core-yellow-1000: #542a00;
156-
--color-core-yellow-1100: #2d1a05;
157-
--color-font-primary: #040404;
158-
--color-font-secondary: #273333;
159-
--color-font-tertiary: #364141;
160-
--color-font-interactive: #0b8599;
161-
--color-font-interactive-hover: #0b8599;
162-
--color-font-interactive-active: #6f5ed3;
163-
--color-font-interactive-disabled: #364141;
164-
--color-font-danger: #6d1313;
165-
--color-font-warning: #601700;
166-
--color-font-success: #08422f;
167-
--size-border-radius-large: 30rem;
168-
--size-font-small: 0.75rem;
169-
--size-font-medium: 1rem;
170-
--size-font-large: 1.5rem;
171-
--size-font-xl: 2.25rem;
172-
--size-padding-small: 0.5rem;
173-
--size-padding-medium: 1rem;
174-
--size-padding-large: 1rem;
175-
--size-padding-xl: 1rem;
11+
--breakpoint-xs: 304px;
12+
--breakpoint-sm: 768px;
13+
--breakpoint-md: calc(304px / 768px);
14+
--color-background-primary: #ffffff;
15+
--color-background-secondary: #f3f4f4;
16+
--color-background-tertiary: #dee1e1;
17+
--color-background-danger: #ffeae9;
18+
--color-background-warning: #ffede3;
19+
--color-background-success: #ebf9eb;
20+
--color-background-info: #e9f8ff;
21+
--color-background-disabled: #dee1e1;
22+
--color-border-primary: #c8cccc;
23+
--color-brand-primary: #0b8599;
24+
--color-brand-secondary: #6f5ed3;
25+
--color-core-green-0: #ebf9eb;
26+
--color-core-green-100: #d7f4d7;
27+
--color-core-green-200: #c2f2bd;
28+
--color-core-green-300: #98e58e;
29+
--color-core-green-400: #75dd66;
30+
--color-core-green-500: #59cb59;
31+
--color-core-green-600: #2bb656;
32+
--color-core-green-700: #0ca750;
33+
--color-core-green-800: #008b46;
34+
--color-core-green-900: #006b40;
35+
--color-core-green-1000: #08422f;
36+
--color-core-green-1100: #002b20;
37+
--color-core-teal-0: #e5f9f5;
38+
--color-core-teal-100: #cdf7ef;
39+
--color-core-teal-200: #b3f2e6;
40+
--color-core-teal-300: #7dead5;
41+
--color-core-teal-400: #24e0c5;
42+
--color-core-teal-500: #08c4b2;
43+
--color-core-teal-600: #00a99c;
44+
--color-core-teal-700: #0b968f;
45+
--color-core-teal-800: #067c7c;
46+
--color-core-teal-900: #026661;
47+
--color-core-teal-1000: #083f3f;
48+
--color-core-teal-1100: #002528;
49+
--color-core-aqua-0: #d9fcfb;
50+
--color-core-aqua-100: #c5f9f9;
51+
--color-core-aqua-200: #a5f2f2;
52+
--color-core-aqua-300: #76e5e2;
53+
--color-core-aqua-400: #33d6e2;
54+
--color-core-aqua-500: #17b8ce;
55+
--color-core-aqua-600: #0797ae;
56+
--color-core-aqua-700: #0b8599;
57+
--color-core-aqua-800: #0f6e84;
58+
--color-core-aqua-900: #035e73;
59+
--color-core-aqua-1000: #083d4f;
60+
--color-core-aqua-1100: #002838;
61+
--color-core-blue-0: #e9f8ff;
62+
--color-core-blue-100: #dcf2ff;
63+
--color-core-blue-200: #c7e4f9;
64+
--color-core-blue-300: #a1d2f8;
65+
--color-core-blue-400: #56adf5;
66+
--color-core-blue-500: #3896e3;
67+
--color-core-blue-600: #2b87d3;
68+
--color-core-blue-700: #2079c3;
69+
--color-core-blue-800: #116daa;
70+
--color-core-blue-900: #0c5689;
71+
--color-core-blue-1000: #0a3960;
72+
--color-core-blue-1100: #002138;
73+
--color-core-purple-0: #f2f2f9;
74+
--color-core-purple-100: #eaeaf9;
75+
--color-core-purple-200: #d8d7f9;
76+
--color-core-purple-300: #c1c1f7;
77+
--color-core-purple-400: #a193f2;
78+
--color-core-purple-500: #9180f4;
79+
--color-core-purple-600: #816fea;
80+
--color-core-purple-700: #6f5ed3;
81+
--color-core-purple-800: #5e4eba;
82+
--color-core-purple-900: #483a9c;
83+
--color-core-purple-1000: #2d246b;
84+
--color-core-purple-1100: #1d1d38;
85+
--color-core-magenta-0: #fef0ff;
86+
--color-core-magenta-100: #f9e3fc;
87+
--color-core-magenta-200: #f4c4f7;
88+
--color-core-magenta-300: #edadf2;
89+
--color-core-magenta-400: #f282f5;
90+
--color-core-magenta-500: #db61db;
91+
--color-core-magenta-600: #c44eb9;
92+
--color-core-magenta-700: #ac44a8;
93+
--color-core-magenta-800: #8f3896;
94+
--color-core-magenta-900: #6c2277;
95+
--color-core-magenta-1000: #451551;
96+
--color-core-magenta-1100: #29192d;
97+
--color-core-pink-0: #ffe9f3;
98+
--color-core-pink-100: #fcdbeb;
99+
--color-core-pink-200: #ffb5d5;
100+
--color-core-pink-300: #ff95c1;
101+
--color-core-pink-400: #ff76ae;
102+
--color-core-pink-500: #ef588b;
103+
--color-core-pink-600: #e0447c;
104+
--color-core-pink-700: #ce3665;
105+
--color-core-pink-800: #b22f5b;
106+
--color-core-pink-900: #931847;
107+
--color-core-pink-1000: #561231;
108+
--color-core-pink-1100: #2b1721;
109+
--color-core-red-0: #ffeae9;
110+
--color-core-red-100: #ffd5d2;
111+
--color-core-red-200: #ffb8b1;
112+
--color-core-red-300: #ff9c8f;
113+
--color-core-red-400: #ff7f6e;
114+
--color-core-red-500: #f76054;
115+
--color-core-red-600: #ed4c42;
116+
--color-core-red-700: #db3e3e;
117+
--color-core-red-800: #c63434;
118+
--color-core-red-900: #992222;
119+
--color-core-red-1000: #6d1313;
120+
--color-core-red-1100: #2b1111;
121+
--color-core-orange-0: #ffede3;
122+
--color-core-orange-100: #fcdccc;
123+
--color-core-orange-200: #ffc6a4;
124+
--color-core-orange-300: #ffb180;
125+
--color-core-orange-400: #ff9c5d;
126+
--color-core-orange-500: #fc8943;
127+
--color-core-orange-600: #f57d33;
128+
--color-core-orange-700: #ed7024;
129+
--color-core-orange-800: #ce5511;
130+
--color-core-orange-900: #962c0b;
131+
--color-core-orange-1000: #601700;
132+
--color-core-orange-1100: #2d130e;
133+
--color-core-neutral-0: #ffffff;
134+
--color-core-neutral-100: #f3f4f4;
135+
--color-core-neutral-200: #dee1e1;
136+
--color-core-neutral-300: #c8cccc;
137+
--color-core-neutral-400: #b0b6b7;
138+
--color-core-neutral-500: #929a9b;
139+
--color-core-neutral-600: #6e797a;
140+
--color-core-neutral-700: #515e5f;
141+
--color-core-neutral-800: #364141;
142+
--color-core-neutral-900: #273333;
143+
--color-core-neutral-1000: #162020;
144+
--color-core-neutral-1100: #040404;
145+
--color-core-yellow-0: #fff8e2;
146+
--color-core-yellow-100: #fdefcd;
147+
--color-core-yellow-200: #ffe99a;
148+
--color-core-yellow-300: #ffe16e;
149+
--color-core-yellow-400: #ffd943;
150+
--color-core-yellow-500: #ffcd1c;
151+
--color-core-yellow-600: #ffbc00;
152+
--color-core-yellow-700: #dd9903;
153+
--color-core-yellow-800: #ba7506;
154+
--color-core-yellow-900: #944c0c;
155+
--color-core-yellow-1000: #542a00;
156+
--color-core-yellow-1100: #2d1a05;
157+
--color-font-primary: #040404;
158+
--color-font-secondary: #273333;
159+
--color-font-tertiary: #364141;
160+
--color-font-interactive: #0b8599;
161+
--color-font-interactive-hover: #0b8599;
162+
--color-font-interactive-active: #6f5ed3;
163+
--color-font-interactive-disabled: #364141;
164+
--color-font-danger: #6d1313;
165+
--color-font-warning: #601700;
166+
--color-font-success: #08422f;
167+
--size-border-radius-large: 30rem;
168+
--size-font-small: 0.75rem;
169+
--size-font-medium: 1rem;
170+
--size-font-large: 1.5rem;
171+
--size-font-xl: 2.25rem;
172+
--size-padding-small: 0.5rem;
173+
--size-padding-medium: 1rem;
174+
--size-padding-large: 1rem;
175+
--size-padding-xl: 1rem;
176176
}
177177
`;
178178
/* end snapshot integration css css/variables should match snapshot */

Diff for: ‎__integration__/compose.test.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,18 @@ describe('integration', async () => {
2929
{
3030
destination: 'StyleDictionary.kt',
3131
format: 'compose/object',
32-
className: 'StyleDictionary',
33-
packageName: 'com.example.tokens',
32+
options: {
33+
className: 'StyleDictionary',
34+
packageName: 'com.example.tokens',
35+
},
3436
},
3537
{
3638
destination: 'StyleDictionaryWithReferences.kt',
3739
format: 'compose/object',
38-
className: 'StyleDictionary',
39-
packageName: 'com.example.tokens',
4040
options: {
4141
outputReferences: true,
42+
className: 'StyleDictionary',
43+
packageName: 'com.example.tokens',
4244
},
4345
},
4446
],

Diff for: ‎__integration__/css.test.js

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ describe('integration', async () => {
3939
{
4040
destination: 'variables.css',
4141
format: 'css/variables',
42+
options: {
43+
formatting: { indentation: ' ' },
44+
},
4245
},
4346
{
4447
destination: 'variablesWithReferences.css',

Diff for: ‎__integration__/flutter.test.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ describe('integration', async () => {
2929
{
3030
destination: 'style_dictionary.dart',
3131
format: 'flutter/class.dart',
32-
className: 'StyleDictionary',
32+
options: {
33+
className: 'StyleDictionary',
34+
},
3335
},
3436
{
3537
destination: 'style_dictionary_with_references.dart',
3638
format: 'flutter/class.dart',
37-
className: 'StyleDictionary',
3839
options: {
3940
outputReferences: true,
41+
className: 'StyleDictionary',
4042
},
4143
},
4244
],
@@ -48,17 +50,21 @@ describe('integration', async () => {
4850
{
4951
destination: 'style_dictionary_color.dart',
5052
format: 'flutter/class.dart',
51-
className: 'StyleDictionaryColor',
52-
type: 'color',
53+
options: {
54+
className: 'StyleDictionaryColor',
55+
type: 'color',
56+
},
5357
filter: {
5458
type: 'color',
5559
},
5660
},
5761
{
5862
destination: 'style_dictionary_sizes.dart',
5963
format: 'flutter/class.dart',
60-
className: 'StyleDictionarySize',
61-
type: 'float',
64+
options: {
65+
className: 'StyleDictionarySize',
66+
type: 'float',
67+
},
6268
filter: {
6369
type: 'color',
6470
},

Diff for: ‎__integration__/iOSObjectiveC.test.js

+22-10
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,33 @@ describe('integration', async () => {
2929
{
3030
destination: 'singleton.m',
3131
format: 'ios/singleton.m',
32-
className: 'StyleDictionary',
32+
options: {
33+
className: 'StyleDictionary',
34+
},
3335
},
3436
{
3537
destination: 'singleton.h',
3638
format: 'ios/singleton.h',
37-
className: 'StyleDictionary',
39+
options: {
40+
className: 'StyleDictionary',
41+
},
3842
},
3943
{
4044
destination: 'color.h',
4145
format: 'ios/colors.h',
42-
className: 'StyleDictionaryColor',
43-
type: 'StyleDictionaryColorName',
46+
options: {
47+
className: 'StyleDictionaryColor',
48+
type: 'StyleDictionaryColorName',
49+
},
4450
filter: (token) => token.type === 'color',
4551
},
4652
{
4753
destination: 'color.m',
4854
format: 'ios/colors.m',
49-
className: 'StyleDictionaryColor',
50-
type: 'StyleDictionaryColorName',
55+
options: {
56+
className: 'StyleDictionaryColor',
57+
type: 'StyleDictionaryColorName',
58+
},
5159
filter: (token) => token.type === 'color',
5260
},
5361
{
@@ -57,15 +65,19 @@ describe('integration', async () => {
5765
{
5866
destination: 'static.h',
5967
format: 'ios/static.h',
60-
className: 'StyleDictionaryStatic',
61-
type: 'CGFloat',
68+
options: {
69+
className: 'StyleDictionaryStatic',
70+
type: 'CGFloat',
71+
},
6272
filter: (token) => token.type === 'dimension' || token.type === 'fontSize',
6373
},
6474
{
6575
destination: 'static.m',
6676
format: 'ios/static.m',
67-
className: 'StyleDictionaryStatic',
68-
type: 'CGFloat',
77+
options: {
78+
className: 'StyleDictionaryStatic',
79+
type: 'CGFloat',
80+
},
6981
filter: (token) => token.type === 'dimension' || token.type === 'fontSize',
7082
},
7183
],

Diff for: ‎__integration__/logging/platform.test.js

-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
* and limitations under the License.
1212
*/
1313
import { expect } from 'chai';
14-
import { restore, stubMethod } from 'hanbi';
1514
import StyleDictionary from 'style-dictionary';
1615
import { buildPath, cleanConsoleOutput } from '../_constants.js';
1716
import { clearOutput } from '../../__tests__/__helpers.js';
@@ -26,12 +25,7 @@ import { clearOutput } from '../../__tests__/__helpers.js';
2625
*
2726
*/
2827
describe(`integration`, () => {
29-
let stub;
30-
beforeEach(() => {
31-
stub = stubMethod(console, 'log');
32-
});
3328
afterEach(() => {
34-
restore();
3529
clearOutput(buildPath);
3630
});
3731

Diff for: ‎__integration__/scss.test.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,30 @@ describe(`integration`, async () => {
5656
{
5757
destination: `map-flat.scss`,
5858
format: `scss/map-flat`,
59-
mapName: 'design-system-tokens',
59+
options: {
60+
mapName: 'design-system-tokens',
61+
},
6062
},
6163
{
6264
destination: `map-deep.scss`,
6365
format: `scss/map-deep`,
64-
mapName: 'design-system-tokens',
66+
options: {
67+
mapName: 'design-system-tokens',
68+
},
6569
},
6670
{
6771
destination: `map-deep-with-references.scss`,
6872
format: `scss/map-deep`,
69-
mapName: 'design-system-tokens',
7073
options: {
74+
mapName: 'design-system-tokens',
7175
outputReferences: true,
7276
},
7377
},
7478
{
7579
destination: `map-deep-not-themeable.scss`,
7680
format: `scss/map-deep`,
77-
mapName: 'design-system-tokens',
7881
options: {
82+
mapName: 'design-system-tokens',
7983
themeable: false,
8084
},
8185
},

Diff for: ‎__integration__/swift.test.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ describe('integration', async () => {
2929
{
3030
destination: 'style_dictionary.swift',
3131
format: 'ios-swift/class.swift',
32-
className: 'StyleDictionary',
32+
options: {
33+
className: 'StyleDictionary',
34+
},
3335
},
3436
{
3537
destination: 'style_dictionary_with_references.swift',
3638
format: 'ios-swift/class.swift',
37-
className: 'StyleDictionary',
3839
options: {
40+
className: 'StyleDictionary',
3941
outputReferences: true,
4042
},
4143
},

Diff for: ‎__tests__/buildFile.test.js

-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
* and limitations under the License.
1212
*/
1313
import { expect } from 'chai';
14-
import { stubMethod, restore } from 'hanbi';
1514
import chalk from 'chalk';
1615
import { fs } from 'style-dictionary/fs';
1716
import buildFile from '../lib/buildFile.js';
@@ -33,12 +32,10 @@ nestedFormat.nested = true;
3332
describe('buildFile', () => {
3433
beforeEach(() => {
3534
clearOutput();
36-
restore();
3735
});
3836

3937
afterEach(() => {
4038
clearOutput();
41-
restore();
4239
});
4340

4441
it('should error if format doesnt exist or isnt a function', async () => {

Diff for: ‎__tests__/formats/swiftFile.test.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ import flattenTokens from '../../lib/utils/flattenTokens.js';
1818
const originalFile = {
1919
destination: '__output/',
2020
format: 'ios-swift/any.swift',
21-
className: 'StyleDictionary',
21+
options: {
22+
className: 'StyleDictionary',
23+
},
2224
filter: {
2325
type: 'color',
2426
},
25-
options: {},
2627
};
2728

2829
let file = {};

Diff for: ‎docs/src/content/docs/reference/Hooks/Formats/predefined.md

+15-13
Original file line numberDiff line numberDiff line change
@@ -50,28 +50,29 @@ $tokens: (
5050

5151
Creates a SCSS file with a deep map based on the style dictionary.
5252

53-
Name the map by adding a 'mapName' attribute on the file object in your config.
53+
Name the map by adding a 'mapName' attribute on the file `options` object in your config.
5454

5555
| Param | Type | Description |
5656
| -------------------------- | ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
5757
| `options` | `Object` | |
5858
| `options.outputReferences` | `boolean \| OutputReferencesFunction` | Whether or not to keep [references](#references-in-output-files) (a -> b -> c) in the output. Defaults to `false`. Also allows passing a function to conditionally output references on a per token basis. |
5959
| `options.themeable` | `boolean` | Whether or not tokens should default to being themeable, if not otherwise specified per token. Defaults to `false`. |
60+
| `options.mapName` | `string` | Name of your SCSS map. |
6061

6162
Example:
6263

6364
```scss title="vars.scss"
6465
$color-background-base: #f0f0f0 !default;
6566
$color-background-alt: #eeeeee !default;
6667

67-
$tokens: {
68+
$tokens: (
6869
'color': (
6970
'background': (
7071
'base': $color-background-base,
71-
'alt': $color-background-alt
72-
)
73-
)
74-
)
72+
'alt': $color-background-alt,
73+
),
74+
),
75+
);
7576
```
7677

7778
---
@@ -550,14 +551,15 @@ Example:
550551

551552
Creates a Kotlin file for Compose containing an object with a `val` for each property.
552553

553-
| Param | Type | Description |
554-
| -------------------------- | ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
555-
| `className` | `string` | The name of the generated Kotlin object |
556-
| `packageName` | `string` | The package for the generated Kotlin object |
557-
| `options` | `Object` | |
558-
| `options.import` | `string[] \| string` | Modules to import. Can be a string or array of strings. Defaults to `['androidx.compose.ui.graphics.Color', 'androidx.compose.ui.unit.*']`. |
559-
| `options.showFileHeader` | `boolean` | Whether or not to include a comment that has the build date. Defaults to `true` |
554+
| Param | Type | Description |
555+
| ----- | ---- | ----------- |
556+
557+
| `options` | `Object` | |
558+
| `options.import` | `string[] \| string` | Modules to import. Can be a string or array of strings. Defaults to `['androidx.compose.ui.graphics.Color', 'androidx.compose.ui.unit.*']`. |
559+
| `options.showFileHeader` | `boolean` | Whether or not to include a comment that has the build date. Defaults to `true` |
560560
| `options.outputReferences` | `boolean \| OutputReferencesFunction` | Whether or not to keep [references](#references-in-output-files) (a -> b -> c) in the output. Defaults to `false`. Also allows passing a function to conditionally output references on a per token basis. |
561+
| `options.className` | `string` | The name of the generated Kotlin object |
562+
| `options.packageName` | `string` | The package for the generated Kotlin object |
561563

562564
Example:
563565

Diff for: ‎docs/src/content/docs/version-4/migration.md

+51
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,57 @@ import { fileHeader, formattedVariables } from 'style-dictionary/utils';
217217
const { fileHeader, formattedVariables } = StyleDictionary.formatHelpers;
218218
```
219219
220+
## Formatting options
221+
222+
Using [file formats](/reference/hooks/formats), it is possible to pass options that influence how your output is created, and these options differ based on which format you are using.
223+
224+
In v3, the following options were put on the file properties level itself next to `destination` and `format` props, but have been moved into the `options` property:
225+
226+
- `className` -> for formats:
227+
- `compose/object`
228+
- `flutter/class.dart`
229+
- `ios-swift/any.swift`
230+
- `ios/colors.h`
231+
- `ios/colors.m`
232+
- `ios/singleton.h`
233+
- `ios/singleton.m`
234+
- `ios/static.m`
235+
- `ios/strings.h`
236+
- `ios/strings.m`
237+
- `packageName` -> for formats:
238+
- `compose/object`
239+
- `type` -> for formats:
240+
- `ios/colors.h`
241+
- `ios/colors.m`
242+
- `ios/singleton.h`
243+
- `ios/singleton.m`
244+
- `ios/static.h`
245+
- `ios/static.m`
246+
- `mapName` -> for formats:
247+
- `scss/map-deep`
248+
- `scss/map-flat`
249+
250+
```json title="config.json" del={9} ins={10-13}
251+
{
252+
"source": ["tokens.json"],
253+
"platforms": {
254+
"css": {
255+
"transformGroup": "scss",
256+
"files": [
257+
{
258+
"destination": "map.scss",
259+
"format": "scss/map-deep",
260+
"mapName": "tokens",
261+
"options": {
262+
"mapName": "tokens"
263+
}
264+
}
265+
]
266+
}
267+
}
268+
}
269+
```
270+
220271
## Types
221272
222273
Style Dictionary is entirely strictly typed now, and there will be `.d.ts` files published next to every file, this means that if you import from one of Style Dictionary's entrypoints, you automatically get the types implicitly with it. This is a big win for people using TypeScript, as the majority of the codebase now has much better types, with much fewer `any`s.

Diff for: ‎examples/advanced/auto-rebuild-watcher/config.json

+65-47
Original file line numberDiff line numberDiff line change
@@ -4,66 +4,84 @@
44
"scss": {
55
"transformGroup": "scss",
66
"buildPath": "build/scss/",
7-
"files": [{
8-
"destination": "_variables.scss",
9-
"format": "scss/variables"
10-
}]
7+
"files": [
8+
{
9+
"destination": "_variables.scss",
10+
"format": "scss/variables"
11+
}
12+
]
1113
},
1214
"android": {
1315
"transformGroup": "android",
1416
"buildPath": "build/android/",
15-
"files": [{
16-
"destination": "font_dimens.xml",
17-
"format": "android/fontDimens"
18-
},{
19-
"destination": "colors.xml",
20-
"format": "android/colors"
21-
}]
17+
"files": [
18+
{
19+
"destination": "font_dimens.xml",
20+
"format": "android/fontDimens"
21+
},
22+
{
23+
"destination": "colors.xml",
24+
"format": "android/colors"
25+
}
26+
]
2227
},
2328
"ios": {
2429
"transformGroup": "ios",
2530
"buildPath": "build/ios/",
26-
"files": [{
27-
"destination": "StyleDictionaryColor.h",
28-
"format": "ios/colors.h",
29-
"className": "StyleDictionaryColor",
30-
"type": "StyleDictionaryColorName",
31-
"filter": {
32-
"attributes": {
33-
"category": "color"
31+
"files": [
32+
{
33+
"destination": "StyleDictionaryColor.h",
34+
"format": "ios/colors.h",
35+
"options": {
36+
"className": "StyleDictionaryColor",
37+
"type": "StyleDictionaryColorName"
38+
},
39+
"filter": {
40+
"attributes": {
41+
"category": "color"
42+
}
3443
}
35-
}
36-
},{
37-
"destination": "StyleDictionaryColor.m",
38-
"format": "ios/colors.m",
39-
"className": "StyleDictionaryColor",
40-
"type": "StyleDictionaryColorName",
41-
"filter": {
42-
"attributes": {
43-
"category": "color"
44+
},
45+
{
46+
"destination": "StyleDictionaryColor.m",
47+
"format": "ios/colors.m",
48+
"options": {
49+
"className": "StyleDictionaryColor",
50+
"type": "StyleDictionaryColorName"
51+
},
52+
"filter": {
53+
"attributes": {
54+
"category": "color"
55+
}
4456
}
45-
}
46-
},{
47-
"destination": "StyleDictionarySize.h",
48-
"format": "ios/static.h",
49-
"className": "StyleDictionarySize",
50-
"type": "float",
51-
"filter": {
52-
"attributes": {
53-
"category": "size"
57+
},
58+
{
59+
"destination": "StyleDictionarySize.h",
60+
"format": "ios/static.h",
61+
"options": {
62+
"className": "StyleDictionarySize",
63+
"type": "float"
64+
},
65+
"filter": {
66+
"attributes": {
67+
"category": "size"
68+
}
5469
}
55-
}
56-
},{
57-
"destination": "StyleDictionarySize.m",
58-
"format": "ios/static.m",
59-
"className": "StyleDictionarySize",
60-
"type": "float",
61-
"filter": {
62-
"attributes": {
63-
"category": "size"
70+
},
71+
{
72+
"destination": "StyleDictionarySize.m",
73+
"format": "ios/static.m",
74+
"options": {
75+
"className": "StyleDictionarySize",
76+
"type": "float"
77+
},
78+
"filter": {
79+
"attributes": {
80+
"category": "size"
81+
}
6482
}
6583
}
66-
}]
84+
]
6785
}
6886
}
6987
}
+46-42
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,50 @@
11
{
2-
"source": [
3-
"properties/**/*.json"
4-
],
5-
"platforms": {
6-
"flutter": {
7-
"transformGroup": "flutter",
8-
"buildPath": "../lib/unique_file/",
9-
"files": [
10-
{
11-
"destination": "style_dictionary.dart",
12-
"format": "flutter/class.dart",
13-
"className": "StyleDictionary"
14-
}
15-
]
2+
"source": ["properties/**/*.json"],
3+
"platforms": {
4+
"flutter": {
5+
"transformGroup": "flutter",
6+
"buildPath": "../lib/unique_file/",
7+
"files": [
8+
{
9+
"destination": "style_dictionary.dart",
10+
"format": "flutter/class.dart",
11+
"options": {
12+
"className": "StyleDictionary"
13+
}
14+
}
15+
]
16+
},
17+
"flutter-separate": {
18+
"transformGroup": "flutter-separate",
19+
"buildPath": "../lib/",
20+
"files": [
21+
{
22+
"destination": "style_dictionary_color.dart",
23+
"format": "flutter/class.dart",
24+
"options": {
25+
"className": "StyleDictionaryColor",
26+
"type": "color"
27+
},
28+
"filter": {
29+
"attributes": {
30+
"category": "color"
31+
}
32+
}
1633
},
17-
"flutter-separate": {
18-
"transformGroup": "flutter-separate",
19-
"buildPath": "../lib/",
20-
"files": [
21-
{
22-
"destination": "style_dictionary_color.dart",
23-
"format": "flutter/class.dart",
24-
"className": "StyleDictionaryColor",
25-
"type": "color",
26-
"filter": {
27-
"attributes": {
28-
"category": "color"
29-
}
30-
}
31-
},
32-
{
33-
"destination": "style_dictionary_sizes.dart",
34-
"format": "flutter/class.dart",
35-
"className": "StyleDictionarySize",
36-
"type": "float",
37-
"filter": {
38-
"attributes": {
39-
"category": "size"
40-
}
41-
}
42-
}
43-
]
34+
{
35+
"destination": "style_dictionary_sizes.dart",
36+
"format": "flutter/class.dart",
37+
"options": {
38+
"className": "StyleDictionarySize",
39+
"type": "float"
40+
},
41+
"filter": {
42+
"attributes": {
43+
"category": "size"
44+
}
45+
}
4446
}
47+
]
4548
}
46-
}
49+
}
50+
}

Diff for: ‎examples/advanced/s3/config.json

+71-51
Original file line numberDiff line numberDiff line change
@@ -4,74 +4,94 @@
44
"scss": {
55
"transformGroup": "scss",
66
"buildPath": "build/scss/",
7-
"files": [{
8-
"destination": "assets.scss",
9-
"format": "scss/variables"
10-
}]
7+
"files": [
8+
{
9+
"destination": "assets.scss",
10+
"format": "scss/variables"
11+
}
12+
]
1113
},
1214
"android": {
1315
"transformGroup": "android",
1416
"buildPath": "build/android/",
15-
"files": [{
16-
"destination": "font_dimens.xml",
17-
"format": "android/fontDimens"
18-
},{
19-
"destination": "colors.xml",
20-
"format": "android/colors"
21-
}]
17+
"files": [
18+
{
19+
"destination": "font_dimens.xml",
20+
"format": "android/fontDimens"
21+
},
22+
{
23+
"destination": "colors.xml",
24+
"format": "android/colors"
25+
}
26+
]
2227
},
2328
"ios": {
2429
"transformGroup": "ios",
2530
"buildPath": "build/ios/",
26-
"files": [{
27-
"destination": "StyleDictionaryColor.h",
28-
"format": "ios/colors.h",
29-
"className": "StyleDictionaryColor",
30-
"type": "StyleDictionaryColorName",
31-
"filter": {
32-
"attributes": {
33-
"category": "color"
31+
"files": [
32+
{
33+
"destination": "StyleDictionaryColor.h",
34+
"format": "ios/colors.h",
35+
"options": {
36+
"className": "StyleDictionaryColor",
37+
"type": "StyleDictionaryColorName"
38+
},
39+
"filter": {
40+
"attributes": {
41+
"category": "color"
42+
}
3443
}
35-
}
36-
},{
37-
"destination": "StyleDictionaryColor.m",
38-
"format": "ios/colors.m",
39-
"className": "StyleDictionaryColor",
40-
"type": "StyleDictionaryColorName",
41-
"filter": {
42-
"attributes": {
43-
"category": "color"
44+
},
45+
{
46+
"destination": "StyleDictionaryColor.m",
47+
"format": "ios/colors.m",
48+
"options": {
49+
"className": "StyleDictionaryColor",
50+
"type": "StyleDictionaryColorName"
51+
},
52+
"filter": {
53+
"attributes": {
54+
"category": "color"
55+
}
4456
}
45-
}
46-
},{
47-
"destination": "StyleDictionarySize.h",
48-
"format": "ios/static.h",
49-
"className": "StyleDictionarySize",
50-
"type": "float",
51-
"filter": {
52-
"attributes": {
53-
"category": "size"
57+
},
58+
{
59+
"destination": "StyleDictionarySize.h",
60+
"format": "ios/static.h",
61+
"options": {
62+
"className": "StyleDictionarySize",
63+
"type": "float"
64+
},
65+
"filter": {
66+
"attributes": {
67+
"category": "size"
68+
}
5469
}
55-
}
56-
},{
57-
"destination": "StyleDictionarySize.m",
58-
"format": "ios/static.m",
59-
"className": "StyleDictionarySize",
60-
"type": "float",
61-
"filter": {
62-
"attributes": {
63-
"category": "size"
70+
},
71+
{
72+
"destination": "StyleDictionarySize.m",
73+
"format": "ios/static.m",
74+
"options": {
75+
"className": "StyleDictionarySize",
76+
"type": "float"
77+
},
78+
"filter": {
79+
"attributes": {
80+
"category": "size"
81+
}
6482
}
6583
}
66-
}]
84+
]
6785
},
6886
"json/asset": {
6987
"transformGroup": "web",
7088
"buildPath": "build/json/",
71-
"files": [{
72-
"destination": "assets.json",
73-
"format": "json/asset"
74-
}]
89+
"files": [
90+
{
91+
"destination": "assets.json",
92+
"format": "json/asset"
93+
}
94+
]
7595
},
7696
"assets/copy": {
7797
"transformGroup": "assets",

Diff for: ‎examples/advanced/tokens-deprecation/templates/web-scss.template.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
/**
22
* @typedef {import('../../../../types/DesignToken.d.ts').TransformedToken} TransformedToken
3-
* @typedef {import('../../../../types/File.d.ts').File} File
43
* @typedef {import('../../../../types/Config.d.ts').Config} Config
54
* @typedef {import('../../../../types/Config.d.ts').LocalOptions} LocalOptions
65
*/
76

87
/**
98
* @param {{
109
* allTokens: TransformedToken[]
11-
* file: File
1210
* options: Config & LocalOptions
1311
* header: string
1412
* }} opts
1513
*/
16-
export default ({ allTokens, file, options, header }) => `
17-
${header}$${file.mapName ?? 'tokens'}: (
14+
export default ({ allTokens, options, header }) => `
15+
${header}$${options.mapName ?? 'tokens'}: (
1816
${allTokens
1917
.map(
2018
(token) =>

Diff for: ‎examples/basic/config.json

+142-102
Original file line numberDiff line numberDiff line change
@@ -4,140 +4,180 @@
44
"scss": {
55
"transformGroup": "scss",
66
"buildPath": "build/scss/",
7-
"files": [{
8-
"destination": "_variables.scss",
9-
"format": "scss/variables"
10-
}]
7+
"files": [
8+
{
9+
"destination": "_variables.scss",
10+
"format": "scss/variables"
11+
}
12+
]
1113
},
1214
"android": {
1315
"transformGroup": "android",
1416
"buildPath": "build/android/",
15-
"files": [{
16-
"destination": "font_dimens.xml",
17-
"format": "android/fontDimens"
18-
},{
19-
"destination": "colors.xml",
20-
"format": "android/colors"
21-
}]
17+
"files": [
18+
{
19+
"destination": "font_dimens.xml",
20+
"format": "android/fontDimens"
21+
},
22+
{
23+
"destination": "colors.xml",
24+
"format": "android/colors"
25+
}
26+
]
2227
},
2328
"compose": {
2429
"transformGroup": "compose",
2530
"buildPath": "build/compose/",
26-
"files": [{
27-
"destination": "StyleDictionaryColor.kt",
28-
"format": "compose/object",
29-
"className": "StyleDictionaryColor",
30-
"packageName": "StyleDictionaryColor",
31-
"filter": {
32-
"attributes": {
33-
"category": "color"
31+
"files": [
32+
{
33+
"destination": "StyleDictionaryColor.kt",
34+
"format": "compose/object",
35+
"options": {
36+
"className": "StyleDictionaryColor",
37+
"packageName": "StyleDictionaryColor"
38+
},
39+
"filter": {
40+
"attributes": {
41+
"category": "color"
42+
}
3443
}
35-
}
36-
},{
37-
"destination": "StyleDictionarySize.kt",
38-
"format": "compose/object",
39-
"className": "StyleDictionarySize",
40-
"packageName": "StyleDictionarySize",
41-
"type": "float",
42-
"filter": {
43-
"attributes": {
44-
"category": "size"
44+
},
45+
{
46+
"destination": "StyleDictionarySize.kt",
47+
"format": "compose/object",
48+
"options": {
49+
"className": "StyleDictionarySize",
50+
"packageName": "StyleDictionarySize",
51+
"type": "float"
52+
},
53+
"filter": {
54+
"attributes": {
55+
"category": "size"
56+
}
4557
}
4658
}
47-
}]
59+
]
4860
},
4961
"ios": {
5062
"transformGroup": "ios",
5163
"buildPath": "build/ios/",
52-
"files": [{
53-
"destination": "StyleDictionaryColor.h",
54-
"format": "ios/colors.h",
55-
"className": "StyleDictionaryColor",
56-
"type": "StyleDictionaryColorName",
57-
"filter": {
58-
"attributes": {
59-
"category": "color"
64+
"files": [
65+
{
66+
"destination": "StyleDictionaryColor.h",
67+
"format": "ios/colors.h",
68+
"options": {
69+
"className": "StyleDictionaryColor",
70+
"type": "StyleDictionaryColorName"
71+
},
72+
"filter": {
73+
"attributes": {
74+
"category": "color"
75+
}
6076
}
61-
}
62-
},{
63-
"destination": "StyleDictionaryColor.m",
64-
"format": "ios/colors.m",
65-
"className": "StyleDictionaryColor",
66-
"type": "StyleDictionaryColorName",
67-
"filter": {
68-
"attributes": {
69-
"category": "color"
77+
},
78+
{
79+
"destination": "StyleDictionaryColor.m",
80+
"format": "ios/colors.m",
81+
"options": {
82+
"className": "StyleDictionaryColor",
83+
"type": "StyleDictionaryColorName"
84+
},
85+
"filter": {
86+
"attributes": {
87+
"category": "color"
88+
}
7089
}
71-
}
72-
},{
73-
"destination": "StyleDictionarySize.h",
74-
"format": "ios/static.h",
75-
"className": "StyleDictionarySize",
76-
"type": "float",
77-
"filter": {
78-
"attributes": {
79-
"category": "size"
90+
},
91+
{
92+
"destination": "StyleDictionarySize.h",
93+
"format": "ios/static.h",
94+
"options": {
95+
"className": "StyleDictionarySize",
96+
"type": "float"
97+
},
98+
"filter": {
99+
"attributes": {
100+
"category": "size"
101+
}
80102
}
81-
}
82-
},{
83-
"destination": "StyleDictionarySize.m",
84-
"format": "ios/static.m",
85-
"className": "StyleDictionarySize",
86-
"type": "float",
87-
"filter": {
88-
"attributes": {
89-
"category": "size"
103+
},
104+
{
105+
"destination": "StyleDictionarySize.m",
106+
"format": "ios/static.m",
107+
"options": {
108+
"className": "StyleDictionarySize",
109+
"type": "float"
110+
},
111+
"filter": {
112+
"attributes": {
113+
"category": "size"
114+
}
90115
}
91116
}
92-
}]
117+
]
93118
},
94119
"ios-swift": {
95120
"transformGroup": "ios-swift",
96121
"buildPath": "build/ios-swift/",
97-
"files": [{
98-
"destination": "StyleDictionary+Class.swift",
99-
"format": "ios-swift/class.swift",
100-
"className": "StyleDictionaryClass",
101-
"filter": {}
102-
},{
103-
"destination": "StyleDictionary+Enum.swift",
104-
"format": "ios-swift/enum.swift",
105-
"className": "StyleDictionaryEnum",
106-
"filter": {}
107-
},{
108-
"destination": "StyleDictionary+Struct.swift",
109-
"format": "ios-swift/any.swift",
110-
"className": "StyleDictionaryStruct",
111-
"filter": {},
112-
"options": {
113-
"imports": "SwiftUI",
114-
"objectType": "struct",
115-
"accessControl": "internal"
122+
"files": [
123+
{
124+
"destination": "StyleDictionary+Class.swift",
125+
"format": "ios-swift/class.swift",
126+
"options": {
127+
"className": "StyleDictionaryClass"
128+
},
129+
"filter": {}
130+
},
131+
{
132+
"destination": "StyleDictionary+Enum.swift",
133+
"format": "ios-swift/enum.swift",
134+
"options": {
135+
"className": "StyleDictionaryEnum"
136+
},
137+
"filter": {}
138+
},
139+
{
140+
"destination": "StyleDictionary+Struct.swift",
141+
"format": "ios-swift/any.swift",
142+
"options": {
143+
"className": "StyleDictionaryStruct",
144+
"imports": "SwiftUI",
145+
"objectType": "struct",
146+
"accessControl": "internal"
147+
},
148+
"filter": {}
116149
}
117-
}]
150+
]
118151
},
119152
"ios-swift-separate-enums": {
120153
"transformGroup": "ios-swift-separate",
121154
"buildPath": "build/ios-swift/",
122-
"files": [{
123-
"destination": "StyleDictionaryColor.swift",
124-
"format": "ios-swift/enum.swift",
125-
"className": "StyleDictionaryColor",
126-
"filter": {
127-
"attributes": {
128-
"category": "color"
155+
"files": [
156+
{
157+
"destination": "StyleDictionaryColor.swift",
158+
"format": "ios-swift/enum.swift",
159+
"options": {
160+
"className": "StyleDictionaryColor"
161+
},
162+
"filter": {
163+
"attributes": {
164+
"category": "color"
165+
}
129166
}
130-
}
131-
},{
132-
"destination": "StyleDictionarySize.swift",
133-
"format": "ios-swift/enum.swift",
134-
"className": "StyleDictionarySize",
135-
"filter": {
136-
"attributes": {
137-
"category": "size"
167+
},
168+
{
169+
"destination": "StyleDictionarySize.swift",
170+
"format": "ios-swift/enum.swift",
171+
"options": {
172+
"className": "StyleDictionarySize"
173+
},
174+
"filter": {
175+
"attributes": {
176+
"category": "size"
177+
}
138178
}
139179
}
140-
}]
180+
]
141181
}
142182
}
143183
}

Diff for: ‎examples/complete/config.json

+116-85
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,142 @@
11
{
2-
"source": [
3-
"tokens/**/*.json"
4-
],
2+
"source": ["tokens/**/*.json"],
53
"platforms": {
64
"ios": {
75
"transformGroup": "ios",
86
"buildPath": "ios/Classes/Generated/",
97
"prefix": "StyleDictionary",
10-
"files": [{
11-
"destination": "StyleDictionarySize.h",
12-
"format": "ios/static.h",
13-
"type": "float",
14-
"className": "StyleDictionarySize",
15-
"filter": {
16-
"attributes": {
17-
"category": "size"
8+
"files": [
9+
{
10+
"destination": "StyleDictionarySize.h",
11+
"format": "ios/static.h",
12+
"options": {
13+
"className": "StyleDictionarySize",
14+
"type": "float"
15+
},
16+
"filter": {
17+
"attributes": {
18+
"category": "size"
19+
}
1820
}
19-
}
20-
},{
21-
"destination": "StyleDictionarySize.m",
22-
"format": "ios/static.m",
23-
"type": "float",
24-
"className": "StyleDictionarySize",
25-
"filter": {
26-
"attributes": {
27-
"category": "size"
21+
},
22+
{
23+
"destination": "StyleDictionarySize.m",
24+
"format": "ios/static.m",
25+
"options": {
26+
"className": "StyleDictionarySize",
27+
"type": "float"
28+
},
29+
"filter": {
30+
"attributes": {
31+
"category": "size"
32+
}
2833
}
29-
}
30-
},{
31-
"destination": "StyleDictionaryIcons.h",
32-
"format": "ios/strings.h",
33-
"className": "StyleDictionaryIcons",
34-
"filter": {
35-
"attributes": {
36-
"category": "content",
37-
"type": "icon"
34+
},
35+
{
36+
"destination": "StyleDictionaryIcons.h",
37+
"format": "ios/strings.h",
38+
"options": {
39+
"className": "StyleDictionaryIcons"
40+
},
41+
"filter": {
42+
"attributes": {
43+
"category": "content",
44+
"type": "icon"
45+
}
3846
}
39-
}
40-
},{
41-
"destination": "StyleDictionaryIcons.m",
42-
"format": "ios/strings.m",
43-
"className": "StyleDictionaryIcons",
44-
"filter": {
45-
"attributes": {
46-
"category": "content",
47-
"type": "icon"
47+
},
48+
{
49+
"destination": "StyleDictionaryIcons.m",
50+
"format": "ios/strings.m",
51+
"options": {
52+
"className": "StyleDictionaryIcons"
53+
},
54+
"filter": {
55+
"attributes": {
56+
"category": "content",
57+
"type": "icon"
58+
}
4859
}
49-
}
50-
},{
51-
"destination": "StyleDictionaryColor.h",
52-
"format": "ios/colors.h",
53-
"className": "StyleDictionaryColor",
54-
"type": "StyleDictionaryColorName",
55-
"filter": {
56-
"attributes": {
57-
"category": "color"
60+
},
61+
{
62+
"destination": "StyleDictionaryColor.h",
63+
"format": "ios/colors.h",
64+
"options": {
65+
"className": "StyleDictionaryColor",
66+
"type": "StyleDictionaryColorName"
67+
},
68+
"filter": {
69+
"attributes": {
70+
"category": "color"
71+
}
5872
}
59-
}
60-
},{
61-
"destination": "StyleDictionaryColor.m",
62-
"format": "ios/colors.m",
63-
"className": "StyleDictionaryColor",
64-
"type": "StyleDictionaryColorName",
65-
"filter": {
66-
"attributes": {
67-
"category": "color"
73+
},
74+
{
75+
"destination": "StyleDictionaryColor.m",
76+
"format": "ios/colors.m",
77+
"options": {
78+
"className": "StyleDictionaryColor",
79+
"type": "StyleDictionaryColorName"
80+
},
81+
"filter": {
82+
"attributes": {
83+
"category": "color"
84+
}
85+
}
86+
},
87+
{
88+
"destination": "StyleDictionaryProperties.h",
89+
"format": "ios/singleton.h",
90+
"options": {
91+
"className": "StyleDictionaryProperties"
92+
}
93+
},
94+
{
95+
"destination": "StyleDictionaryProperties.m",
96+
"format": "ios/singleton.m",
97+
"options": {
98+
"className": "StyleDictionaryProperties"
6899
}
69100
}
70-
},{
71-
"destination": "StyleDictionaryProperties.h",
72-
"format": "ios/singleton.h",
73-
"className": "StyleDictionaryProperties"
74-
},{
75-
"destination": "StyleDictionaryProperties.m",
76-
"format": "ios/singleton.m",
77-
"className": "StyleDictionaryProperties"
78-
}]
101+
]
79102
},
80103

81104
"android": {
82105
"transformGroup": "android",
83106
"buildPath": "android/styledictionary/src/main/res/values/",
84-
"files": [{
85-
"destination": "style_dictionary_colors.xml",
86-
"format": "android/colors"
87-
},{
88-
"destination": "style_dictionary_font_dimens.xml",
89-
"format": "android/fontDimens"
90-
},{
91-
"destination": "style_dictionary_dimens.xml",
92-
"format": "android/dimens"
93-
},{
94-
"destination": "style_dictionary_integers.xml",
95-
"format": "android/integers"
96-
},{
97-
"destination": "style_dictionary_strings.xml",
98-
"format": "android/strings"
99-
}]
107+
"files": [
108+
{
109+
"destination": "style_dictionary_colors.xml",
110+
"format": "android/colors"
111+
},
112+
{
113+
"destination": "style_dictionary_font_dimens.xml",
114+
"format": "android/fontDimens"
115+
},
116+
{
117+
"destination": "style_dictionary_dimens.xml",
118+
"format": "android/dimens"
119+
},
120+
{
121+
"destination": "style_dictionary_integers.xml",
122+
"format": "android/integers"
123+
},
124+
{
125+
"destination": "style_dictionary_strings.xml",
126+
"format": "android/strings"
127+
}
128+
]
100129
},
101130

102131
"android-asset": {
103132
"transformGroup": "android",
104133
"buildPath": "android/styledictionary/src/main/",
105-
"files": [{
106-
"destination": "assets/data/properties.json",
107-
"format": "json"
108-
}],
134+
"files": [
135+
{
136+
"destination": "assets/data/properties.json",
137+
"format": "json"
138+
}
139+
],
109140
"actions": ["copy_assets"]
110141
}
111142
}

Diff for: ‎lib/common/formats.js

+48-26
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const formats = {
7979
*/
8080
'css/variables': async function ({ dictionary, options = {}, file }) {
8181
const selector = options.selector ? options.selector : `:root`;
82-
const { outputReferences, outputReferenceFallbacks, usesDtcg } = options;
82+
const { outputReferences, outputReferenceFallbacks, usesDtcg, formatting } = options;
8383
const header = await fileHeader({ file });
8484
return (
8585
header +
@@ -89,6 +89,7 @@ const formats = {
8989
dictionary,
9090
outputReferences,
9191
outputReferenceFallbacks,
92+
formatting,
9293
usesDtcg,
9394
}) +
9495
`\n}\n`
@@ -114,7 +115,7 @@ const formats = {
114115
'scss/map-flat': async function ({ dictionary, options, file }) {
115116
const { allTokens } = dictionary;
116117
const header = await fileHeader({ file, commentStyle: 'long' });
117-
return scssMapFlat({ allTokens, file, options, header });
118+
return scssMapFlat({ allTokens, options, header });
118119
},
119120

120121
/**
@@ -142,13 +143,20 @@ const formats = {
142143
'scss/map-deep': async function ({ dictionary, options, file }) {
143144
const header = await fileHeader({ file, commentStyle: 'long' });
144145
// Default the "themeable" option to true for backward compatibility.
145-
const { outputReferences, themeable = true, usesDtcg } = options;
146+
const { outputReferences, themeable = true, formatting, usesDtcg } = options;
146147
return (
147148
'\n' +
148149
header +
149-
formattedVariables({ format: 'sass', dictionary, outputReferences, themeable, usesDtcg }) +
150+
formattedVariables({
151+
format: 'sass',
152+
dictionary,
153+
outputReferences,
154+
themeable,
155+
formatting,
156+
usesDtcg,
157+
}) +
150158
'\n' +
151-
scssMapDeep({ dictionary, file, options })
159+
scssMapDeep({ dictionary, options })
152160
);
153161
},
154162

@@ -166,11 +174,18 @@ const formats = {
166174
* ```
167175
*/
168176
'scss/variables': async function ({ dictionary, options, file }) {
169-
const { outputReferences, themeable = false, usesDtcg } = options;
177+
const { outputReferences, themeable = false, formatting, usesDtcg } = options;
170178
const header = await fileHeader({ file, commentStyle: 'short' });
171179
return (
172180
header +
173-
formattedVariables({ format: 'sass', dictionary, outputReferences, themeable, usesDtcg }) +
181+
formattedVariables({
182+
format: 'sass',
183+
dictionary,
184+
outputReferences,
185+
themeable,
186+
formatting,
187+
usesDtcg,
188+
}) +
174189
'\n'
175190
);
176191
},
@@ -203,10 +218,12 @@ const formats = {
203218
* ```
204219
*/
205220
'less/variables': async function ({ dictionary, options, file }) {
206-
const { outputReferences, usesDtcg } = options;
221+
const { outputReferences, formatting, usesDtcg } = options;
207222
const header = await fileHeader({ file, commentStyle: 'short' });
208223
return (
209-
header + formattedVariables({ format: 'less', dictionary, outputReferences, usesDtcg }) + '\n'
224+
header +
225+
formattedVariables({ format: 'less', dictionary, outputReferences, formatting, usesDtcg }) +
226+
'\n'
210227
);
211228
},
212229

@@ -238,12 +255,12 @@ const formats = {
238255
* ```
239256
*/
240257
'stylus/variables': async function ({ dictionary, options, file, platform }) {
241-
const { usesDtcg } = options;
258+
const { formatting, usesDtcg } = options;
242259
const outputReferences = !!platform.options?.outputReferences;
243260
const header = await fileHeader({ file, commentStyle: 'short' });
244261
return (
245262
header +
246-
formattedVariables({ format: 'stylus', dictionary, outputReferences, usesDtcg }) +
263+
formattedVariables({ format: 'stylus', dictionary, outputReferences, formatting, usesDtcg }) +
247264
'\n'
248265
);
249266
},
@@ -796,13 +813,14 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
796813
*/
797814
'compose/object': async function ({ dictionary, options, file }) {
798815
const { allTokens, tokens, unfilteredTokens } = dictionary;
799-
const { outputReferences, usesDtcg } = options;
816+
const { outputReferences, formatting, usesDtcg } = options;
800817
const formatProperty = createPropertyFormatter({
801818
outputReferences,
802819
dictionary,
803820
formatting: {
804821
suffix: '',
805822
commentStyle: 'none', // We will add the comment in the format template
823+
...formatting,
806824
},
807825
usesDtcg,
808826
});
@@ -816,7 +834,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
816834

817835
options = setComposeObjectProperties(options);
818836
const header = await fileHeader({ file, commentStyle: 'short' });
819-
return composeObject({ allTokens: sortedTokens, file, options, formatProperty, header });
837+
return composeObject({ allTokens: sortedTokens, options, formatProperty, header });
820838
},
821839

822840
// iOS templates
@@ -871,9 +889,9 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
871889
* @kind member
872890
* @todo Add example and usage
873891
*/
874-
'ios/singleton.h': async function ({ file }) {
892+
'ios/singleton.h': async function ({ file, options }) {
875893
const header = await fileHeader({ file, commentStyle: 'short' });
876-
return iosSingletonH({ file, header });
894+
return iosSingletonH({ file, options, header });
877895
},
878896

879897
/**
@@ -883,9 +901,9 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
883901
* @kind member
884902
* @todo Add example and usage
885903
*/
886-
'ios/static.h': async function ({ dictionary, file }) {
904+
'ios/static.h': async function ({ dictionary, file, options }) {
887905
const header = await fileHeader({ file, commentStyle: 'short' });
888-
return iosStaticH({ dictionary, file, header });
906+
return iosStaticH({ dictionary, file, options, header });
889907
},
890908

891909
/**
@@ -907,9 +925,9 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
907925
* @kind memberx
908926
* @todo Add example and usage
909927
*/
910-
'ios/colors.h': async function ({ dictionary, file }) {
928+
'ios/colors.h': async function ({ dictionary, options, file }) {
911929
const header = await fileHeader({ file, commentStyle: 'short' });
912-
return iosColorsH({ dictionary, file, header });
930+
return iosColorsH({ dictionary, file, options, header });
913931
},
914932

915933
/**
@@ -931,9 +949,9 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
931949
* @kind member
932950
* @todo Add example and usage
933951
*/
934-
'ios/strings.h': async function ({ dictionary, file }) {
952+
'ios/strings.h': async function ({ dictionary, file, options }) {
935953
const header = await fileHeader({ file, commentStyle: 'short' });
936-
return iosStringsH({ dictionary, file, header });
954+
return iosStringsH({ dictionary, file, options, header });
937955
},
938956

939957
/**
@@ -969,13 +987,14 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
969987
*/
970988
'ios-swift/class.swift': async function ({ dictionary, options, file, platform }) {
971989
const { allTokens, tokens, unfilteredTokens } = dictionary;
972-
const { outputReferences, usesDtcg } = options;
990+
const { outputReferences, formatting, usesDtcg } = options;
973991
options = setSwiftFileProperties(options, 'class', platform.transformGroup);
974992
const formatProperty = createPropertyFormatter({
975993
outputReferences,
976994
dictionary,
977995
formatting: {
978996
suffix: '',
997+
...formatting,
979998
},
980999
usesDtcg,
9811000
});
@@ -1010,13 +1029,14 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
10101029
*/
10111030
'ios-swift/enum.swift': async function ({ dictionary, options, file, platform }) {
10121031
const { allTokens, tokens, unfilteredTokens } = dictionary;
1013-
const { outputReferences, usesDtcg } = options;
1032+
const { outputReferences, formatting, usesDtcg } = options;
10141033
options = setSwiftFileProperties(options, 'enum', platform.transformGroup);
10151034
const formatProperty = createPropertyFormatter({
10161035
outputReferences,
10171036
dictionary,
10181037
formatting: {
10191038
suffix: '',
1039+
...formatting,
10201040
},
10211041
usesDtcg,
10221042
});
@@ -1062,13 +1082,14 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
10621082
*/
10631083
'ios-swift/any.swift': async function ({ dictionary, options, file, platform }) {
10641084
const { allTokens, tokens, unfilteredTokens } = dictionary;
1065-
const { outputReferences, usesDtcg } = options;
1085+
const { outputReferences, formatting, usesDtcg } = options;
10661086
options = setSwiftFileProperties(options, options.objectType, platform.transformGroup);
10671087
const formatProperty = createPropertyFormatter({
10681088
outputReferences,
10691089
dictionary,
10701090
formatting: {
10711091
suffix: '',
1092+
...formatting,
10721093
},
10731094
usesDtcg,
10741095
});
@@ -1283,10 +1304,11 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
12831304
*/
12841305
'flutter/class.dart': async function ({ dictionary, options, file }) {
12851306
const { allTokens, tokens, unfilteredTokens } = dictionary;
1286-
const { outputReferences, usesDtcg } = options;
1307+
const { outputReferences, formatting, usesDtcg } = options;
12871308
const formatProperty = createPropertyFormatter({
12881309
outputReferences,
12891310
dictionary,
1311+
formatting,
12901312
usesDtcg,
12911313
});
12921314

@@ -1297,7 +1319,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
12971319
sortedTokens = [...allTokens].sort(sortByName);
12981320
}
12991321
const header = await fileHeader({ file, commentStyle: 'short' });
1300-
return flutterClassDart({ allTokens: sortedTokens, file, formatProperty, header });
1322+
return flutterClassDart({ allTokens: sortedTokens, file, options, formatProperty, header });
13011323
},
13021324
};
13031325

Diff for: ‎lib/common/templates/compose/object.kt.template.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
/**
22
* @typedef {import('../../../../types/DesignToken.d.ts').TransformedToken} TransformedToken
33
* @typedef {import('../../../../types/Config.d.ts').Config} Config
4-
* @typedef {import('../../../../types/File.d.ts').File} File
54
* @typedef {import('../../../../types/Config.d.ts').LocalOptions} LocalOptions
65
*/
76

87
/**
98
* @param {{
109
* allTokens: TransformedToken[]
11-
* file: File
1210
* formatProperty: (token: TransformedToken) => string
1311
* options: Config & LocalOptions
1412
* header: string
1513
* }} opts
1614
*/
17-
export default ({ allTokens, file, formatProperty, options, header }) => `
15+
export default ({ allTokens, formatProperty, options, header }) => `
1816
${header}
1917
20-
package ${file.packageName ?? ''};
18+
package ${options.packageName ?? ''};
2119
2220
${options.import.map(/** @param {string} item */ (item) => `import ${item}`).join('\n')}
2321
24-
object ${file.className ?? ''} {
22+
object ${options.className ?? ''} {
2523
${allTokens
2624
.map(
2725
(token) =>

Diff for: ‎lib/common/templates/flutter/class.dart.template.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,21 @@
99
* @param {{
1010
* allTokens: TransformedToken[]
1111
* file: File
12+
* options: LocalOptions & Config
1213
* formatProperty: (token: TransformedToken) => string
1314
* header: string
1415
* }} opts
1516
*/
16-
export default ({ allTokens, file, formatProperty, header }) => `
17+
export default ({ allTokens, file, options, formatProperty, header }) => `
1718
//
1819
// ${file.destination}
1920
//
2021
${header}
2122
2223
import 'dart:ui';
2324
24-
class ${file.className ? `${file.className} ` : ''}{
25-
${file.className ?? ''}._();
25+
class ${options.className ? `${options.className} ` : ''}{
26+
${options.className ?? ''}._();
2627
2728
${allTokens.map((token) => `static const ${formatProperty(token)}`).join('\n ')}
2829
}`;

Diff for: ‎lib/common/templates/ios-swift/any.swift.template.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ${options.import.map(/** @param {string} item */ (item) => `import ${item}`).joi
2323
2424
${options.accessControl ? `${options.accessControl} ` : ''}${
2525
options.objectType ? `${options.objectType} ` : ''
26-
}${file.className ? `${file.className} ` : ''}{
26+
}${options.className ? `${options.className} ` : ''}{
2727
${allTokens
2828
.map(
2929
(token) =>

Diff for: ‎lib/common/templates/ios/colors.h.template.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
/**
22
* @typedef {import('../../../../types/DesignToken.d.ts').Dictionary} Dictionary
33
* @typedef {import('../../../../types/File.d.ts').File} File
4+
* @typedef {import('../../../../types/Config.d.ts').Config} Config
5+
* @typedef {import('../../../../types/Config.d.ts').LocalOptions} LocalOptions
46
*/
57

68
/**
79
* @param {{
810
* dictionary: Dictionary
911
* file: File
12+
* options: LocalOptions & Config
1013
* header: string
1114
* }} opts
1215
*/
13-
export default ({ dictionary, file, header }) => `
16+
export default ({ dictionary, options, file, header }) => `
1417
//
1518
// ${file.destination ?? ''}
1619
//
1720
${header}
1821
#import <UIKit/UIKit.h>
1922
20-
typedef NS_ENUM(NSInteger, ${file.type ?? ''}) {
23+
typedef NS_ENUM(NSInteger, ${options.type ?? ''}) {
2124
${dictionary.allTokens.map((token) => `${token.name}`).join(',\n')}
2225
};
2326
24-
@interface ${file.className ? `${file.className} ` : ''}: NSObject
27+
@interface ${options.className ? `${options.className} ` : ''}: NSObject
2528
+ (NSArray *)values;
26-
+ (UIColor *)color:(${file.type ?? ''})color;
29+
+ (UIColor *)color:(${options.type ?? ''})color;
2730
@end`;

Diff for: ‎lib/common/templates/ios/colors.m.template.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ export default ({ dictionary, file, options, header }) => `
1818
// ${file.destination ?? ''}
1919
//
2020
${header}
21-
#import "${file.className ?? ''}.h"
21+
#import "${options.className ?? ''}.h"
2222
23-
@implementation ${file.className ?? ''}
23+
@implementation ${options.className ?? ''}
2424
25-
+ (UIColor *)color:(${file.type ?? ''})colorEnum{
25+
+ (UIColor *)color:(${options.type ?? ''})colorEnum{
2626
return [[self values] objectAtIndex:colorEnum];
2727
}
2828

Diff for: ‎lib/common/templates/ios/singleton.h.template.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
/**
22
* @typedef {import('../../../../types/File.d.ts').File} File
3+
* @typedef {import('../../../../types/Config.d.ts').Config} Config
4+
* @typedef {import('../../../../types/Config.d.ts').LocalOptions} LocalOptions
35
*/
46

57
/**
68
* @param {{
79
* file: File
10+
* options: LocalOptions & Config
811
* header: string
912
* }} opts
1013
*/
11-
export default ({ file, header }) => `
14+
export default ({ file, options, header }) => `
1215
//
1316
// ${file.destination ?? ''}
1417
//
1518
${header}
1619
#import <Foundation/Foundation.h>
1720
#import <UIKit/UIKit.h>
1821
19-
@interface ${file.className ? `${file.className} ` : ''}: NSObject
22+
@interface ${options.className ? `${options.className} ` : ''}: NSObject
2023
2124
+ (NSDictionary *)properties;
2225
+ (NSDictionary *)getProperty:(NSString *)keyPath;

Diff for: ‎lib/common/templates/ios/singleton.m.template.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ export default ({ dictionary, options, file, header }) => `
5656
// ${file.destination ?? ''}
5757
//
5858
${header}
59-
#import "${file.className ?? ''}.h"
59+
#import "${options.className ?? ''}.h"
6060
61-
@implementation ${file.className ?? ''}
61+
@implementation ${options.className ?? ''}
6262
6363
+ (NSDictionary *)getProperty:(NSString *)keyPath {
6464
return [[self properties] valueForKeyPath:keyPath];

Diff for: ‎lib/common/templates/ios/static.h.template.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
/**
22
* @typedef {import('../../../../types/DesignToken.d.ts').Dictionary} Dictionary
33
* @typedef {import('../../../../types/File.d.ts').File} File
4+
* @typedef {import('../../../../types/Config.d.ts').Config} Config
5+
* @typedef {import('../../../../types/Config.d.ts').LocalOptions} LocalOptions
46
*/
57

68
/**
79
* @param {{
810
* dictionary: Dictionary
911
* file: File
12+
* options: LocalOptions & Config
1013
* header: string
1114
* }} opts
1215
*/
13-
export default ({ dictionary, file, header }) => `
16+
export default ({ dictionary, file, options, header }) => `
1417
// ${file.destination ?? ''}
1518
//
1619
${header}
1720
#import <Foundation/Foundation.h>
1821
1922
2023
${dictionary.allTokens
21-
.map((token) => `extern ${file.type ? `${file.type} ` : ''}const ${token.name};`)
24+
.map((token) => `extern ${options.type ? `${options.type} ` : ''}const ${token.name};`)
2225
.join('\n')}`;

Diff for: ‎lib/common/templates/ios/static.m.template.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ export default ({ dictionary, file, options, header }) => `
1818
// ${file.destination ?? ''}
1919
//
2020
${header}
21-
#import "${file.className ?? ''}.h"
21+
#import "${options.className ?? ''}.h"
2222
2323
2424
${dictionary.allTokens
2525
.map(
2626
(token) =>
27-
`${file.type ? `${file.type} ` : ''}const ${token.name} = ${
27+
`${options.type ? `${options.type} ` : ''}const ${token.name} = ${
2828
options.usesDtcg ? token.$value : token.value
2929
};`,
3030
)

Diff for: ‎lib/common/templates/ios/strings.h.template.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
/**
22
* @typedef {import('../../../../types/DesignToken.d.ts').Dictionary} Dictionary
33
* @typedef {import('../../../../types/File.d.ts').File} File
4+
* @typedef {import('../../../../types/Config.d.ts').Config} Config
5+
* @typedef {import('../../../../types/Config.d.ts').LocalOptions} LocalOptions
46
*/
57

68
/**
79
* @param {{
810
* dictionary: Dictionary
911
* file: File
12+
* options: LocalOptions & Config
1013
* header: string
1114
* }} opts
1215
*/
13-
export default ({ dictionary, file, header }) => `
16+
export default ({ dictionary, file, options, header }) => `
1417
//
1518
// ${file.destination ?? ''}
1619
//
@@ -20,6 +23,6 @@ ${header}
2023
2124
${dictionary.allTokens.map((token) => `extern NSString * const ${token.name};`).join('\n')}
2225
23-
@interface ${file.className ?? ''} : NSObject
26+
@interface ${options.className ?? ''} : NSObject
2427
+ (NSArray *)values;
2528
@end`;

Diff for: ‎lib/common/templates/ios/strings.m.template.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default ({ dictionary, file, options, header }) => `
4040
// ${file.destination ?? ''}
4141
//
4242
${header}
43-
#import "${file.className ?? ''}.h"
43+
#import "${options.className ?? ''}.h"
4444
4545
4646
${dictionary.allTokens
@@ -49,7 +49,7 @@ ${dictionary.allTokens
4949
)
5050
.join('\n')}
5151
52-
@implementation ${file.className ?? ''}
52+
@implementation ${options.className ?? ''}
5353
5454
+ (NSArray *)values {
5555
static NSArray* array;

Diff for: ‎lib/common/templates/scss/map-deep.template.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/**
22
* @typedef {import('../../../../types/DesignToken.d.ts').DesignTokens} DesignTokens
33
* @typedef {import('../../../../types/DesignToken.d.ts').Dictionary} Dictionary
4-
* @typedef {import('../../../../types/File.d.ts').File} File
54
* @typedef {import('../../../../types/Config.d.ts').Config} Config
65
* @typedef {import('../../../../types/Config.d.ts').LocalOptions} LocalOptions
76
*/
@@ -39,10 +38,9 @@ function processJsonNode(obj, options, depth = 0) {
3938
/**
4039
* @param {{
4140
* dictionary: Dictionary
42-
* file: File & { mapName?: string }
4341
* options: Config & LocalOptions
4442
* }} opts
4543
*/
46-
export default ({ dictionary, file, options }) => `
47-
$${file.mapName ?? 'tokens'}: ${processJsonNode(dictionary.tokens, options)};
44+
export default ({ dictionary, options }) => `
45+
$${options.mapName ?? 'tokens'}: ${processJsonNode(dictionary.tokens, options)};
4846
`;

Diff for: ‎lib/common/templates/scss/map-flat.template.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
/**
22
* @typedef {import('../../../../types/DesignToken.d.ts').TransformedToken} TransformedToken
3-
* @typedef {import('../../../../types/File.d.ts').File} File
43
* @typedef {import('../../../../types/Config.d.ts').Config} Config
54
* @typedef {import('../../../../types/Config.d.ts').LocalOptions} LocalOptions
65
*/
76

87
/**
98
* @param {{
109
* allTokens: TransformedToken[]
11-
* file: File
1210
* options: Config & LocalOptions
1311
* header: string
1412
* }} opts
1513
*/
16-
export default ({ allTokens, file, options, header }) => `
17-
${header}$${file.mapName ?? 'tokens'}: (
14+
export default ({ allTokens, options, header }) => `
15+
${header}$${options.mapName ?? 'tokens'}: (
1816
${allTokens
1917
.map(
2018
(token) =>

Diff for: ‎types/File.d.ts

-6
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ export interface FormattingOptions {
1818
export type FileHeader = (defaultMessage: string[]) => Promise<string[]> | string[];
1919

2020
export interface File {
21-
// TODO: these should be passed inside the LocalOptions options
22-
className?: string;
23-
packageName?: string;
24-
mapName?: string;
25-
type?: string;
26-
2721
destination: string;
2822
format?: string | Formatter;
2923
filter?: string | Partial<TransformedToken> | Matcher;

0 commit comments

Comments
 (0)
Please sign in to comment.