@rte-ds/core 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/badge/badge.utils.ts +1 -1
- package/components/badge/docs/Behaviors.scss +1 -1
- package/components/breadcrumbs/docs/Options.scss +1 -1
- package/components/breadcrumbs/docs/Usage.scss +1 -1
- package/components/grid/grid.stories.scss +1 -1
- package/components/select/docs/Options.scss +1 -1
- package/components/select/docs/OverviewOptions.scss +1 -1
- package/components/select/docs/Usage.scss +1 -1
- package/components/side-nav/nav-item/nav-item.utils.ts +1 -1
- package/components/tooltip/tooltip.utils.ts +1 -1
- package/css/rte-fonts.css +1 -1
- package/package.json +14 -1
- package/CHANGELOG.md +0 -320
- package/css-font-generator.ts +0 -51
- package/eslint.config.js +0 -1
- package/scripts/design-tokens/common.ts +0 -35
- package/scripts/design-tokens/generator.ts +0 -24
- package/scripts/design-tokens/primitives-generator.spec.ts +0 -84
- package/scripts/design-tokens/primitives-generator.ts +0 -66
- package/scripts/design-tokens/sourceFiles/primitives.json +0 -2075
- package/scripts/design-tokens/sourceFiles/tokens.json +0 -10561
- package/scripts/design-tokens/tokens-generator.spec.ts +0 -184
- package/scripts/design-tokens/tokens-generator.ts +0 -155
- package/scripts/design-tokens/tokens-generators/colors.ts +0 -142
- package/scripts/design-tokens/tokens-generators/layout.ts +0 -22
- package/scripts/design-tokens/tokens-generators/opacity.ts +0 -14
- package/scripts/design-tokens/tokens-generators/shadows.ts +0 -18
- package/scripts/design-tokens/tokens-generators/typography.ts +0 -58
- package/scripts/design-tokens/tokens-generators/zIndex.ts +0 -18
- package/tsconfig.json +0 -12
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TOOLTIP_GAP, TOOLTIP_GAP_ARROW } from "@
|
|
1
|
+
import { TOOLTIP_GAP, TOOLTIP_GAP_ARROW } from "@rte-ds/core/components/tooltip/tooltip.constants";
|
|
2
2
|
|
|
3
3
|
export function getTooltipGap(arrow: boolean, customGap: number = TOOLTIP_GAP): number {
|
|
4
4
|
return arrow ? TOOLTIP_GAP_ARROW + customGap : customGap;
|
package/css/rte-fonts.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@font-face{font-display:swap;font-family:"Nunito";font-style:normal;font-weight:300;src:url("@
|
|
1
|
+
@font-face{font-display:swap;font-family:"Nunito";font-style:normal;font-weight:300;src:url("@rte-ds/core/assets/fonts/nunito-light-300.woff2") format("woff2")}@font-face{font-display:swap;font-family:"Nunito";font-style:normal;font-weight:400;src:url("@rte-ds/core/assets/fonts/nunito-regular-400.woff2") format("woff2")}@font-face{font-display:swap;font-family:"Nunito";font-style:normal;font-weight:600;src:url("@rte-ds/core/assets/fonts/nunito-semi-bold-600.woff2") format("woff2")}@font-face{font-display:swap;font-family:"Nunito";font-style:normal;font-weight:700;src:url("@rte-ds/core/assets/fonts/nunito-bold-700.woff2") format("woff2")}
|
package/package.json
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rte-ds/core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"main": "index.js",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./css/*": "./css/*",
|
|
8
|
+
"./assets/fonts/*": "./assets/fonts/*"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"css",
|
|
12
|
+
"assets",
|
|
13
|
+
"components",
|
|
14
|
+
"common",
|
|
15
|
+
"constants",
|
|
16
|
+
"design-tokens"
|
|
17
|
+
],
|
|
5
18
|
"scripts": {
|
|
6
19
|
"lint": "eslint .",
|
|
7
20
|
"lint:fix": "eslint . --fix",
|
package/CHANGELOG.md
DELETED
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
# @design-system-rte/core
|
|
2
|
-
|
|
3
|
-
## 1.2.1
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- 1f8e40c: ## Changes
|
|
8
|
-
- (Core) add valid alias path for badge utils import
|
|
9
|
-
|
|
10
|
-
## 1.2.0
|
|
11
|
-
|
|
12
|
-
### Minor Changes
|
|
13
|
-
|
|
14
|
-
- 8c512ea: ## Changes
|
|
15
|
-
- (Select) add new documentation
|
|
16
|
-
- (Assistive-text) add width props
|
|
17
|
-
- (Select) improve style
|
|
18
|
-
- (Assistive-text) add angular component
|
|
19
|
-
- (Select) harmonise readonly and disable behavior + add stories scenario
|
|
20
|
-
- (Select) Add angular component
|
|
21
|
-
- extract common input props
|
|
22
|
-
- (Dropdown) add selected state to simple dropdown item
|
|
23
|
-
- extract required indicator in a component
|
|
24
|
-
|
|
25
|
-
- 921ffd7: ## Changes
|
|
26
|
-
- (Design-tokens) update script to generate tokens with the new architecture
|
|
27
|
-
- (Core) extract scripts out of design-tokens folder
|
|
28
|
-
- (Core) change global architecture for design tokens
|
|
29
|
-
|
|
30
|
-
- f5946ce: ## Changes
|
|
31
|
-
- (Breadcrumbs) Add Badge
|
|
32
|
-
- add angular missing dependencies
|
|
33
|
-
- (Badge) add utils function to check if it should display badge
|
|
34
|
-
- (Core) add badge holder interface to use
|
|
35
|
-
- (Dropdown) add Badge
|
|
36
|
-
|
|
37
|
-
- 0dbb025: ## Changes
|
|
38
|
-
- (Split-button) Add badge
|
|
39
|
-
- (Core) use parameter object for shouldDisplayBadge utils
|
|
40
|
-
- (Segmented Control) add badge
|
|
41
|
-
- (Breadcrumbs) Add Badge
|
|
42
|
-
- add angular missing dependencies
|
|
43
|
-
- (Badge) add utils function to check if it should display badge
|
|
44
|
-
- (Core) add badge holder interface to use
|
|
45
|
-
- (Dropdown) add Badge
|
|
46
|
-
|
|
47
|
-
- c6867f7: ## Changes
|
|
48
|
-
- (Segmented Control) add badge
|
|
49
|
-
- add angular missing dependencies
|
|
50
|
-
- (Badge) add utils function to check if it should display badge
|
|
51
|
-
- (Core) add badge holder interface to use
|
|
52
|
-
- (Dropdown) add Badge
|
|
53
|
-
|
|
54
|
-
- 251ae74: ## Changes
|
|
55
|
-
- (Split-button) Add badge
|
|
56
|
-
- (Badge) add utils function to check if it should display badge
|
|
57
|
-
- (Core) add badge holder interface to use
|
|
58
|
-
- (Dropdown) add Badge
|
|
59
|
-
|
|
60
|
-
- 38d9ec6: ## Changes
|
|
61
|
-
- (Badge) use IconSize constant and add xs value
|
|
62
|
-
|
|
63
|
-
- 2cff3de: ## Changes
|
|
64
|
-
- (Searchbar) add new documentation
|
|
65
|
-
- (Searchbar) change component structure so input inner border reacts correctly to focus & assistive text takes all the width of its container
|
|
66
|
-
- (Text Input) correct placeholder exposition and handling
|
|
67
|
-
- (Searchbar) add searchbar base functionality
|
|
68
|
-
|
|
69
|
-
- 29e0462: ## Changes
|
|
70
|
-
- (Design Docs) correct sub-storybook context detection
|
|
71
|
-
- (Angular Storybook) correct font resolutions from assets retrieved from core during webpack build
|
|
72
|
-
- (Storybook) add breadcrumbs - overview page
|
|
73
|
-
|
|
74
|
-
## 1.1.0
|
|
75
|
-
|
|
76
|
-
### Minor Changes
|
|
77
|
-
|
|
78
|
-
- aa4024c: ## Changes
|
|
79
|
-
- (Core) add Nunito font to serve to react and angular package
|
|
80
|
-
|
|
81
|
-
- ddb8b02: ## Changes
|
|
82
|
-
- (Core) add elevation mixins
|
|
83
|
-
|
|
84
|
-
## 1.0.0
|
|
85
|
-
|
|
86
|
-
### Major Changes
|
|
87
|
-
|
|
88
|
-
- adc4eb6: ## Changes
|
|
89
|
-
- (Public Release) Public Release
|
|
90
|
-
|
|
91
|
-
### Minor Changes
|
|
92
|
-
|
|
93
|
-
- 90fd2b4: ## Changes
|
|
94
|
-
- (Toast) extract getToastPriority logic to core + use computed to display actionButton + add custom icon to input
|
|
95
|
-
- (Toast) add angular component
|
|
96
|
-
- (Toast) add spacing from viewport + handle warning case in priority + add leftIcon and action button display boolean
|
|
97
|
-
- (Toast) add priority queue management
|
|
98
|
-
- (Toast) add basic react component
|
|
99
|
-
|
|
100
|
-
- 1b87a18: ## Changes
|
|
101
|
-
- (Button) set correct position to badge
|
|
102
|
-
- (Button) add badge
|
|
103
|
-
|
|
104
|
-
- f3d1179: ## Changes
|
|
105
|
-
- (Banner) remove show icon props + remove top and left radius corner
|
|
106
|
-
- (Banner) update design
|
|
107
|
-
|
|
108
|
-
## 0.21.0
|
|
109
|
-
|
|
110
|
-
### Minor Changes
|
|
111
|
-
|
|
112
|
-
- f22d3ee: ## Changes
|
|
113
|
-
- (Docs) create subcomponent for pages
|
|
114
|
-
|
|
115
|
-
- 8bca3e1: ## Changes
|
|
116
|
-
- (Card) mutualize testing common logic
|
|
117
|
-
- (Card) add card component
|
|
118
|
-
|
|
119
|
-
- 4a444d4: ## Changes
|
|
120
|
-
- (Side Navigation) add Divider support for navItems & navMenus
|
|
121
|
-
- (Side Navigation) add Badge support
|
|
122
|
-
- (Side Navigation) add footer items
|
|
123
|
-
- (Side Navigation) add NavItem selection for SideNav
|
|
124
|
-
- (Tooltip) add customizable gap
|
|
125
|
-
- (Side Navigation) correct accesibility standards for ul and li items
|
|
126
|
-
- (Side Navigation) add Nested Menus to SideNav
|
|
127
|
-
- (Side Navigation) implement simple side nav from base side nav
|
|
128
|
-
|
|
129
|
-
## 0.20.0
|
|
130
|
-
|
|
131
|
-
### Minor Changes
|
|
132
|
-
|
|
133
|
-
- a7d75ed: ## Changes
|
|
134
|
-
- (Modal) add support for filled / outlined appearance for title icon
|
|
135
|
-
- (Modal) add react modal component
|
|
136
|
-
- (Icon) add icon sizes constants
|
|
137
|
-
|
|
138
|
-
- cc64a7f: ## Changes
|
|
139
|
-
- (Icon-button) add badge to component
|
|
140
|
-
|
|
141
|
-
## 0.19.0
|
|
142
|
-
|
|
143
|
-
### Minor Changes
|
|
144
|
-
|
|
145
|
-
- f246255: ## Changes
|
|
146
|
-
- (Breadcrumbs) enable breadcrumbItem max width with ellipsis
|
|
147
|
-
|
|
148
|
-
- bb5af23: ## Changes
|
|
149
|
-
- (Divider) add brand appearance
|
|
150
|
-
|
|
151
|
-
- 196aaab: ## Changes
|
|
152
|
-
- (Split Button) enhance keyboard navigation
|
|
153
|
-
- (Split Button) add dropdown to right button
|
|
154
|
-
|
|
155
|
-
- 97d3bea: ## Changes
|
|
156
|
-
- (Link) add reverse variant
|
|
157
|
-
|
|
158
|
-
## 0.18.0
|
|
159
|
-
|
|
160
|
-
### Minor Changes
|
|
161
|
-
|
|
162
|
-
- 9e7b2cd: ## Changes
|
|
163
|
-
- (Dropdown) correct dropdown keyboard navigation
|
|
164
|
-
- (Breadcrumbs) integrate dropdown with breadcrumbs
|
|
165
|
-
|
|
166
|
-
## 0.17.0
|
|
167
|
-
|
|
168
|
-
### Minor Changes
|
|
169
|
-
|
|
170
|
-
- a901693: ## Changes
|
|
171
|
-
- (Banner) use click output instead of input actionCallback
|
|
172
|
-
- (Tokens) add zIndex tokens
|
|
173
|
-
|
|
174
|
-
- 00ec1aa: ## Changes
|
|
175
|
-
- (Tab) extract scroll methods in utils
|
|
176
|
-
- (Tab) add inverted case
|
|
177
|
-
- (Tab) handle wrapped behavior
|
|
178
|
-
- (Tab) add disabled state for tab items
|
|
179
|
-
- (Tab) add angular component
|
|
180
|
-
- (Tab) extract common props to core
|
|
181
|
-
|
|
182
|
-
- 0cb0e68: ## Changes
|
|
183
|
-
- (Popover) add popover
|
|
184
|
-
|
|
185
|
-
### Patch Changes
|
|
186
|
-
|
|
187
|
-
- a3838c6: ## Changes
|
|
188
|
-
- (Dropdown) correct angular integration between tab & dropdown
|
|
189
|
-
|
|
190
|
-
## 0.16.0
|
|
191
|
-
|
|
192
|
-
### Minor Changes
|
|
193
|
-
|
|
194
|
-
- 5e685f0: ## Changes
|
|
195
|
-
- (Loader) add loader component for react and angular
|
|
196
|
-
|
|
197
|
-
- 191f1e9: ## Changes
|
|
198
|
-
- (Segmented-control) added documentation for storybook
|
|
199
|
-
- (Loader) add Loader component stories and documentation
|
|
200
|
-
- (Textarea) add Storybook documentation and examples for Textarea component
|
|
201
|
-
- add TextInput component documentation and stories with accessibility guidelines and various interaction states
|
|
202
|
-
- (Switch) add Switch component stories and documentation
|
|
203
|
-
- (Divider) add Divider component stories and documentation
|
|
204
|
-
- (Chip) update story titles and add Chip documentation with images
|
|
205
|
-
- (Tag) add Tag documentation and stories
|
|
206
|
-
|
|
207
|
-
- 21cab4b: ## Changes
|
|
208
|
-
- (Breadcrumbs) add Breadcrumbs
|
|
209
|
-
- (Breadcrumbs) set initial breacrumbs structure for React and Core
|
|
210
|
-
|
|
211
|
-
## 0.15.0
|
|
212
|
-
|
|
213
|
-
### Minor Changes
|
|
214
|
-
|
|
215
|
-
- 4dead3f: ## Changes
|
|
216
|
-
- (Segmented Control) automatically toggle icon appearance on segment selection state
|
|
217
|
-
- (Segmented Control) extract focus handling logic into utils file
|
|
218
|
-
- (Segmented Control) add angular component
|
|
219
|
-
- add storybook interactions tests
|
|
220
|
-
- (Segmented Control) extract props types and constants to core
|
|
221
|
-
- (Segmented Control) add react component
|
|
222
|
-
|
|
223
|
-
- f2f7349: ## Changes
|
|
224
|
-
- (Switch) added switch component to Core with types and interface
|
|
225
|
-
|
|
226
|
-
- 7d41c21: ## Changes
|
|
227
|
-
- (Divider) implement Divider component types with orientation, thickness, appearance, and endPoint
|
|
228
|
-
|
|
229
|
-
- cbd90b0: ## Changes
|
|
230
|
-
- (Storybook-badge) add Badge component documentation
|
|
231
|
-
|
|
232
|
-
## 0.14.0
|
|
233
|
-
|
|
234
|
-
### Minor Changes
|
|
235
|
-
|
|
236
|
-
- db7edfd: ## Changes
|
|
237
|
-
- add border-divider token color
|
|
238
|
-
|
|
239
|
-
## 0.13.0
|
|
240
|
-
|
|
241
|
-
### Minor Changes
|
|
242
|
-
|
|
243
|
-
- 89289e7: ## Changes
|
|
244
|
-
- (textarea) simplify required and optional appearence
|
|
245
|
-
- (textarea) set better props handling + handle resizing logic on angular comp
|
|
246
|
-
- (textarea) add auto scroll to top on blur event
|
|
247
|
-
- add angular textarea component
|
|
248
|
-
- extract constants in core
|
|
249
|
-
- add react textarea component
|
|
250
|
-
|
|
251
|
-
- f6bb90d: ## Changes
|
|
252
|
-
- update Tag component to use computed properties for icon name and validation
|
|
253
|
-
- correct casing of compactSpacing property in Tag component and stories
|
|
254
|
-
- improve formatting and consistency in Tag component and interface
|
|
255
|
-
- add Tag component with status and decorative types, including styles and stories
|
|
256
|
-
|
|
257
|
-
## 0.12.0
|
|
258
|
-
|
|
259
|
-
### Minor Changes
|
|
260
|
-
|
|
261
|
-
- b824254: ## Changes
|
|
262
|
-
- enhance Badge component with improved class bindings and styling options
|
|
263
|
-
- implement Badge component in Angular
|
|
264
|
-
- add Badge interface
|
|
265
|
-
|
|
266
|
-
## 0.11.0
|
|
267
|
-
|
|
268
|
-
### Minor Changes
|
|
269
|
-
|
|
270
|
-
- ae703ee: ## Changes
|
|
271
|
-
- add keyboard test constants file
|
|
272
|
-
- add type to aria role mapping constant
|
|
273
|
-
- add keyboard event handling for backspace and delete keys
|
|
274
|
-
- add id property to text input component to get better accessibility
|
|
275
|
-
- update keyboard event handling in stories to use correct syntax
|
|
276
|
-
- extract chip props in interface
|
|
277
|
-
|
|
278
|
-
## 0.10.1
|
|
279
|
-
|
|
280
|
-
### Patch Changes
|
|
281
|
-
|
|
282
|
-
- 9fcc804: ## Changes
|
|
283
|
-
- add correct behaviour on click
|
|
284
|
-
|
|
285
|
-
## 0.10.0
|
|
286
|
-
|
|
287
|
-
### Minor Changes
|
|
288
|
-
|
|
289
|
-
- 0c0177e: ## Changes
|
|
290
|
-
- simplify aria attributes handling for TextInput
|
|
291
|
-
- correct right-icon default behavior & positioning in InputText
|
|
292
|
-
- correct content-success color
|
|
293
|
-
- correct display & behavior of rightIcon & assistiveText for TextInput
|
|
294
|
-
- add stories cases for TextInput
|
|
295
|
-
- add textInput behavior for left & right Icons and error handling
|
|
296
|
-
- add error and disabled props to TextInput component and update stories
|
|
297
|
-
- enhance TextInput component with new props and styles for better usability
|
|
298
|
-
- format TextInputProps for improved readability
|
|
299
|
-
- add TextInput types and prepared file for component
|
|
300
|
-
|
|
301
|
-
## 0.9.0
|
|
302
|
-
|
|
303
|
-
### Minor Changes
|
|
304
|
-
|
|
305
|
-
- f51dfca: ## Changes
|
|
306
|
-
- add cancel icon
|
|
307
|
-
|
|
308
|
-
## 0.8.0
|
|
309
|
-
|
|
310
|
-
### Minor Changes
|
|
311
|
-
|
|
312
|
-
- 7d6d633: ## Changes
|
|
313
|
-
- add gradient mixins
|
|
314
|
-
- add global themes variable to themes file
|
|
315
|
-
|
|
316
|
-
## 0.7.0
|
|
317
|
-
|
|
318
|
-
### Minor Changes
|
|
319
|
-
|
|
320
|
-
- 60c9c03: Update dependency from @design-system-rte/core
|
package/css-font-generator.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
import sass from "sass";
|
|
5
|
-
|
|
6
|
-
const outputDir = path.resolve(__dirname, "css");
|
|
7
|
-
|
|
8
|
-
if (!fs.existsSync(outputDir)) {
|
|
9
|
-
fs.mkdirSync(outputDir);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const fontFile = `
|
|
13
|
-
@font-face {
|
|
14
|
-
font-display: swap;
|
|
15
|
-
font-family: 'Nunito';
|
|
16
|
-
font-style: normal;
|
|
17
|
-
font-weight: 300;
|
|
18
|
-
src: url('@design-system-rte/core/assets/fonts/nunito-light-300.woff2') format('woff2');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@font-face {
|
|
22
|
-
font-display: swap;
|
|
23
|
-
font-family: 'Nunito';
|
|
24
|
-
font-style: normal;
|
|
25
|
-
font-weight: 400;
|
|
26
|
-
src: url('@design-system-rte/core/assets/fonts/nunito-regular-400.woff2') format('woff2');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@font-face {
|
|
30
|
-
font-display: swap;
|
|
31
|
-
font-family: 'Nunito';
|
|
32
|
-
font-style: normal;
|
|
33
|
-
font-weight: 600;
|
|
34
|
-
src: url('@design-system-rte/core/assets/fonts/nunito-semi-bold-600.woff2') format('woff2');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
@font-face {
|
|
38
|
-
font-display: swap;
|
|
39
|
-
font-family: 'Nunito';
|
|
40
|
-
font-style: normal;
|
|
41
|
-
font-weight: 700;
|
|
42
|
-
src: url('@design-system-rte/core/assets/fonts/nunito-bold-700.woff2') format('woff2');
|
|
43
|
-
}
|
|
44
|
-
`;
|
|
45
|
-
|
|
46
|
-
const fontResult = sass.compileString(fontFile, {
|
|
47
|
-
loadPaths: [path.resolve(__dirname)],
|
|
48
|
-
style: "compressed",
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
fs.writeFileSync(path.join(outputDir, "rte-fonts.css"), fontResult.css);
|
package/eslint.config.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "../../eslint.config.js";
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path, { resolve } from "path";
|
|
3
|
-
|
|
4
|
-
export interface TokenValue {
|
|
5
|
-
$type: string;
|
|
6
|
-
$scopes: string[];
|
|
7
|
-
$value: string | number;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const UNIT = "px";
|
|
11
|
-
export const INDENT = " ".repeat(2);
|
|
12
|
-
|
|
13
|
-
export enum PrivacyLevel {
|
|
14
|
-
PUBLIC = "public",
|
|
15
|
-
PRIVATE = "private",
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const rootDir = path.join(resolve(__dirname), "../../design-tokens");
|
|
19
|
-
const tokensDir = "tokens";
|
|
20
|
-
const primitivesDir = "primitives";
|
|
21
|
-
|
|
22
|
-
export const tokensOutputDir = path.join(rootDir, tokensDir);
|
|
23
|
-
export const primitivesOutputDir = path.join(rootDir, primitivesDir);
|
|
24
|
-
|
|
25
|
-
export function buildScssVariable(variableName: string[], value: string): string {
|
|
26
|
-
return `$${variableName.join("-")}: ${value};\n`.toLowerCase();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function generateScssFile(scss: string, filePath: string) {
|
|
30
|
-
fs.writeFileSync(filePath, scss);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function buildScssFileName(collection: string): string {
|
|
34
|
-
return `_${collection.toLowerCase()}.scss`;
|
|
35
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import { resolve } from "path";
|
|
3
|
-
|
|
4
|
-
import { generatePrimitivesScssFiles } from "./primitives-generator";
|
|
5
|
-
import { generateTokensScssFiles, TokenItem } from "./tokens-generator";
|
|
6
|
-
|
|
7
|
-
console.log("🔧 Generating design tokens...\n");
|
|
8
|
-
|
|
9
|
-
const currentDir = resolve(__dirname);
|
|
10
|
-
|
|
11
|
-
const inputPrimitivesSource = resolve(currentDir, "sourceFiles/primitives.json");
|
|
12
|
-
const inputTokensSource = resolve(currentDir, "sourceFiles/tokens.json");
|
|
13
|
-
|
|
14
|
-
const rawPrimitives = JSON.parse(fs.readFileSync(inputPrimitivesSource, "utf8"));
|
|
15
|
-
console.log("📦 Generating primitives... ");
|
|
16
|
-
generatePrimitivesScssFiles(rawPrimitives);
|
|
17
|
-
console.log("✅ Primitives generated successfully.\n");
|
|
18
|
-
|
|
19
|
-
const rawTokens: TokenItem[] = JSON.parse(fs.readFileSync(inputTokensSource, "utf8"));
|
|
20
|
-
console.log("📦 Generating tokens... ");
|
|
21
|
-
generateTokensScssFiles(rawTokens);
|
|
22
|
-
console.log("✅ Tokens generated successfully.\n");
|
|
23
|
-
|
|
24
|
-
console.log("✅ All design tokens generated successfully. ");
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
|
|
3
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
4
|
-
|
|
5
|
-
import { Collection, generatePrimitivesScssFiles } from "./primitives-generator";
|
|
6
|
-
|
|
7
|
-
vi.mock("fs");
|
|
8
|
-
|
|
9
|
-
describe("primitives-generator", () => {
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
vi.clearAllMocks();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("génère correctement les variables SCSS pour les couleurs", () => {
|
|
15
|
-
const colorCollection = [
|
|
16
|
-
{
|
|
17
|
-
collection: Collection.COLORS,
|
|
18
|
-
variables: {
|
|
19
|
-
bleu: {
|
|
20
|
-
100: { $value: "#abcdef" },
|
|
21
|
-
200: { $value: "#123456" },
|
|
22
|
-
},
|
|
23
|
-
rouge: {
|
|
24
|
-
500: { $value: "#ff0000" },
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
const writeSpy = vi.spyOn(fs, "writeFileSync");
|
|
31
|
-
|
|
32
|
-
vi.spyOn(fs, "existsSync").mockReturnValue(true);
|
|
33
|
-
|
|
34
|
-
vi.spyOn(fs, "readFileSync").mockReturnValue(colorCollection.toString());
|
|
35
|
-
|
|
36
|
-
generatePrimitivesScssFiles(colorCollection);
|
|
37
|
-
|
|
38
|
-
expect(writeSpy).toHaveBeenCalledWith(
|
|
39
|
-
expect.stringContaining("_colors.scss"),
|
|
40
|
-
expect.stringContaining("$bleu-100: #abcdef;"),
|
|
41
|
-
);
|
|
42
|
-
expect(writeSpy).toHaveBeenCalledWith(
|
|
43
|
-
expect.stringContaining("_colors.scss"),
|
|
44
|
-
expect.stringContaining("$rouge-500: #ff0000;"),
|
|
45
|
-
);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("génère correctement les variables SCSS pour la typo", () => {
|
|
49
|
-
const typoCollection = [
|
|
50
|
-
{
|
|
51
|
-
collection: Collection.TYPOGRAPHY,
|
|
52
|
-
variables: {
|
|
53
|
-
"font-weight": {
|
|
54
|
-
bold: { $value: "700" },
|
|
55
|
-
},
|
|
56
|
-
"font-family": {
|
|
57
|
-
main: { $value: "Nunito" },
|
|
58
|
-
},
|
|
59
|
-
"font-size": {
|
|
60
|
-
small: { $value: "12" },
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
];
|
|
65
|
-
|
|
66
|
-
const writeSpy = vi.spyOn(fs, "writeFileSync");
|
|
67
|
-
vi.spyOn(fs, "existsSync").mockReturnValue(true);
|
|
68
|
-
|
|
69
|
-
generatePrimitivesScssFiles(typoCollection);
|
|
70
|
-
|
|
71
|
-
expect(writeSpy).toHaveBeenCalledWith(
|
|
72
|
-
expect.stringContaining("_typography.scss"),
|
|
73
|
-
expect.stringContaining("$font-weight-bold: 700;"),
|
|
74
|
-
);
|
|
75
|
-
expect(writeSpy).toHaveBeenCalledWith(
|
|
76
|
-
expect.stringContaining("_typography.scss"),
|
|
77
|
-
expect.stringContaining('$font-family-main: "Nunito";'),
|
|
78
|
-
);
|
|
79
|
-
expect(writeSpy).toHaveBeenCalledWith(
|
|
80
|
-
expect.stringContaining("_typography.scss"),
|
|
81
|
-
expect.stringContaining("$font-size-small: 12px;"),
|
|
82
|
-
);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
import { generateScssFile, primitivesOutputDir, UNIT } from "./common";
|
|
5
|
-
|
|
6
|
-
export enum Collection {
|
|
7
|
-
COLORS = "Primitive : Colors",
|
|
8
|
-
TYPOGRAPHY = "Primitive : Type",
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface CollectionItem {
|
|
12
|
-
collection: Collection;
|
|
13
|
-
variables: Record<string, Record<string, { $value: string }>>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (!fs.existsSync(primitivesOutputDir)) {
|
|
17
|
-
fs.mkdirSync(primitivesOutputDir);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function generatePrimitivesScssFiles(json: CollectionItem[]) {
|
|
21
|
-
for (const tokenItem of json) {
|
|
22
|
-
let scss = "// This file is auto-generated. Do not edit directly.\n\n";
|
|
23
|
-
let filename = "";
|
|
24
|
-
switch (tokenItem.collection) {
|
|
25
|
-
case Collection.COLORS:
|
|
26
|
-
filename = "_colors.scss";
|
|
27
|
-
scss += extractColors(tokenItem);
|
|
28
|
-
generateScssFile(scss, path.join(primitivesOutputDir, filename));
|
|
29
|
-
break;
|
|
30
|
-
|
|
31
|
-
case Collection.TYPOGRAPHY:
|
|
32
|
-
filename = "_typography.scss";
|
|
33
|
-
scss += extractTypography(tokenItem);
|
|
34
|
-
generateScssFile(scss, path.join(primitivesOutputDir, filename));
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function extractColors(colorCollection: CollectionItem): string {
|
|
41
|
-
let scss = "";
|
|
42
|
-
for (const color in colorCollection.variables) {
|
|
43
|
-
for (const colorValue in colorCollection.variables[color]) {
|
|
44
|
-
const colorVariable = colorCollection.variables[color][colorValue];
|
|
45
|
-
scss += `$${color}-${colorValue}: ${colorVariable.$value};\n`.toLowerCase();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return scss;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function extractTypography(typographyCollection: CollectionItem): string {
|
|
52
|
-
let scss = "";
|
|
53
|
-
for (const category in typographyCollection.variables) {
|
|
54
|
-
for (const subCategory in typographyCollection.variables[category]) {
|
|
55
|
-
const typographyVariable = typographyCollection.variables[category][subCategory];
|
|
56
|
-
if (category === "font-weight") {
|
|
57
|
-
scss += `$${category}-${subCategory}: ${typographyVariable.$value};\n`.toLowerCase();
|
|
58
|
-
} else if (category === "font-family") {
|
|
59
|
-
scss += `$${category}-${subCategory}: "${typographyVariable.$value}";\n`;
|
|
60
|
-
} else {
|
|
61
|
-
scss += `$${category}-${subCategory}: ${typographyVariable.$value}${UNIT};\n`.toLowerCase();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return scss;
|
|
66
|
-
}
|