@synergy-design-system/tokens 2.20.1 → 2.22.0
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/CHANGELOG.md +14 -0
- package/README.md +201 -2
- package/dist/js/index.d.ts +517 -522
- package/dist/js/index.js +259 -264
- package/dist/scss/_tokens.scss +203 -204
- package/dist/themes/dark.css +203 -206
- package/dist/themes/light.css +203 -206
- package/package.json +20 -8
- package/src/figma-tokens/_docs.json +41 -1
- package/src/figma-variables/output/sick2018-dark.json +1187 -0
- package/src/figma-variables/output/sick2018-light.json +1187 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [@synergy-design-system/tokens-v2.22.0](https://github.com/synergy-design-system/synergy-design-system/compare/tokens/2.21.0...tokens/2.22.0) (2025-08-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* ✨ Synchronize tokens via Figma API to github ([#929](https://github.com/synergy-design-system/synergy-design-system/issues/929)) ([51f6aeb](https://github.com/synergy-design-system/synergy-design-system/commit/51f6aeb2e9407c1d808ee0be02d279ada0e3cac7))
|
|
7
|
+
|
|
8
|
+
# [@synergy-design-system/tokens-v2.21.0](https://github.com/synergy-design-system/synergy-design-system/compare/tokens/2.20.1...tokens/2.21.0) (2025-07-09)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* ✨ Add restricted options to syn-combobox ([#914](https://github.com/synergy-design-system/synergy-design-system/issues/914)) ([d1b2e4d](https://github.com/synergy-design-system/synergy-design-system/commit/d1b2e4d0d63bf9f132fa179cc3954e9b21b4ea72))
|
|
14
|
+
|
|
1
15
|
# [@synergy-design-system/tokens-v2.20.1](https://github.com/synergy-design-system/synergy-design-system/compare/tokens/2.20.0...tokens/2.20.1) (2025-06-20)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -168,6 +168,13 @@ div {
|
|
|
168
168
|
}
|
|
169
169
|
```
|
|
170
170
|
|
|
171
|
+
### JSON files
|
|
172
|
+
|
|
173
|
+
Currently the raw .json tokens files are exported under `/src/figma-tokens/*/`.
|
|
174
|
+
|
|
175
|
+
> Note:
|
|
176
|
+
> These files are deprecated and will be removed in the new major version of Synergy, as the whole tokens structures are getting refactored.
|
|
177
|
+
|
|
171
178
|
---
|
|
172
179
|
|
|
173
180
|
## Optional: Configuring tokens in VSCode
|
|
@@ -184,16 +191,91 @@ Just make sure to add a valid path to the light theme in the `.vscode/settings.j
|
|
|
184
191
|
|
|
185
192
|
---
|
|
186
193
|
|
|
187
|
-
## Documentation
|
|
194
|
+
## Developer Documentation
|
|
195
|
+
|
|
196
|
+
### Architecture and Data Flow
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
Figma
|
|
200
|
+
↓
|
|
201
|
+
Figma REST API
|
|
202
|
+
↓
|
|
203
|
+
Raw JSON Files (src/figma-variables/)
|
|
204
|
+
↓
|
|
205
|
+
Transform Scripts (scripts/figma/)
|
|
206
|
+
↓
|
|
207
|
+
Style Dictionary compliant JSON Files (src/figma-variables/output)
|
|
208
|
+
↓
|
|
209
|
+
Style Dictionary Processing
|
|
210
|
+
↓
|
|
211
|
+
Build Output (dist/)
|
|
212
|
+
```
|
|
188
213
|
|
|
189
214
|
### Building the tokens
|
|
190
215
|
|
|
216
|
+
Tokens are a mix of [Figma Variables](https://help.figma.com/hc/en-us/articles/15339657135383-Guide-to-variables-in-Figma) and [Figma styles](https://help.figma.com/hc/en-us/articles/360039238753-Styles-in-Figma-Design). They are fetched from Figma via [Figma API](https://www.figma.com/developers/api).
|
|
217
|
+
|
|
218
|
+
To trigger a new fetching use `pnpm fetch:figma`, to update the tokens.
|
|
219
|
+
This scripts needs the figma access token and optionally the figma file id, so it knows, where it should fetch the tokens from. If not available, it fetches the tokens from the main (_bZFqk9urD3NlghGUKrkKCR_).
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# Required: Figma Personal Access Token
|
|
223
|
+
export FIGMA_TOKEN="your_figma_token_here"
|
|
224
|
+
|
|
225
|
+
# Optional: Specific Figma File/Branch ID (Default: Main Branch)
|
|
226
|
+
export FIGMA_FILE_ID="your_figma_file_id"
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
# Fetch all Figma data (Variables + Styles)
|
|
231
|
+
pnpm fetch:figma
|
|
232
|
+
|
|
233
|
+
# Only fetch variables and transform into Style Dictionary format
|
|
234
|
+
pnpm fetch:variables
|
|
235
|
+
|
|
236
|
+
# Only fetch styles
|
|
237
|
+
pnpm fetch:styles
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
#### Figma variables
|
|
241
|
+
|
|
242
|
+
The variables are created to support several modes.
|
|
243
|
+
Currently supported modes are:
|
|
244
|
+
|
|
245
|
+
- **sick2018-light**
|
|
246
|
+
- **sick2018-dark**
|
|
247
|
+
|
|
248
|
+
For each mode a json file is created, with the corresponding tokens and values.
|
|
249
|
+
|
|
250
|
+
#### Figma styles
|
|
251
|
+
|
|
252
|
+
For the styles a separate `styles.json` is created.
|
|
253
|
+
|
|
254
|
+
#### Output
|
|
255
|
+
|
|
191
256
|
Outputs of the tokens are created using [Style Dictionary](https://amzn.github.io/style-dictionary/).
|
|
192
257
|
You can trigger a build using `pnpm build` in the `tokens` package root. This will create the css themes (located in `dist/themes/light.css` and `dist/themes/dark.css`), as well as the JavaScript exports (located at `dist/js/index.js`) and scss variables (`dist/scss/_tokens.scss`).
|
|
193
258
|
|
|
194
259
|
---
|
|
195
260
|
|
|
196
|
-
###
|
|
261
|
+
### Project structure
|
|
262
|
+
|
|
263
|
+
#### `/src/figma-variables/`
|
|
264
|
+
|
|
265
|
+
- **`tokens.json`**: Raw data of Figma Variables and Collections, directly fetched from the Figma API
|
|
266
|
+
- **`output/`**: Transformed token files in Style Dictionary-compatible formats
|
|
267
|
+
- `sick2018-light.json`: Light Theme Tokens
|
|
268
|
+
- `sick2018-dark.json`: Dark Theme Tokens
|
|
269
|
+
- `styles.json`: Figma Styles (Typography, Shadows, etc.)
|
|
270
|
+
|
|
271
|
+
#### `/scripts/figma/`
|
|
272
|
+
|
|
273
|
+
- **`fetch-variables.js`**: Downloads Figma Variables via the REST API
|
|
274
|
+
- **`transform-tokens.js`**: Transforms Figma Variables into Style Dictionary format
|
|
275
|
+
- **`style-dict-outputter.js`**: Custom outputter for Figma Styles export
|
|
276
|
+
- **`helpers.js`**: Utility functions
|
|
277
|
+
|
|
278
|
+
#### `/scripts/add-missing-tokens.js`
|
|
197
279
|
|
|
198
280
|
**Purpose**:
|
|
199
281
|
This script is designed to inspect and append missing CSS variables based on a given prefix.
|
|
@@ -207,3 +289,120 @@ This script is designed to inspect and append missing CSS variables based on a g
|
|
|
207
289
|
- `extractVariables(data, prefix)`: Extracts variables from the provided data based on the prefix.
|
|
208
290
|
- `compareAndAppendVariables(sourceFilePath, targetFilePath, prefix)`: Compares source and target files for missing variables and appends them.
|
|
209
291
|
- `addMissingTokens(prefix)`: Main function that loops through target files and checks for missing variables.
|
|
292
|
+
|
|
293
|
+
### Github Action
|
|
294
|
+
|
|
295
|
+
The **Sync Figma variables to tokens** workflow (`.github/workflows/sync-figma-to-tokens.yml`) provides an automated way to synchronize design tokens from Figma to the codebase via GitHub Actions.
|
|
296
|
+
|
|
297
|
+
**Purpose**:
|
|
298
|
+
This workflow fetches the latest Figma variables and styles, transforms them into the appropriate token formats, runs tests to ensure integrity, and creates a pull request with the updated tokens.
|
|
299
|
+
|
|
300
|
+
**Trigger**:
|
|
301
|
+
The workflow is manually triggered using `workflow_dispatch` with configurable inputs.
|
|
302
|
+
|
|
303
|
+
**Input Parameters**:
|
|
304
|
+
|
|
305
|
+
- **`figma_file_id`** (required): The Figma file or branch ID to sync from
|
|
306
|
+
- Default: `"bZFqk9urD3NlghGUKrkKCR"` (main Synergy Design System file)
|
|
307
|
+
- Can be either a branch ID or the main file ID
|
|
308
|
+
- **`branch_name`** (required): Name for the new Git branch
|
|
309
|
+
- Default: `"feat/update-tokens-from-figma"`
|
|
310
|
+
- **`pull_request_name`** (required): Title for the pull request
|
|
311
|
+
- Default: `"feat: ✨ Update tokens from Figma"`
|
|
312
|
+
|
|
313
|
+
**Workflow Steps**:
|
|
314
|
+
|
|
315
|
+
1. **Repository Setup**: Checks out the repository with full history
|
|
316
|
+
2. **Environment Setup**: Installs pnpm, Node.js 22, and project dependencies
|
|
317
|
+
3. **Token Synchronization**: Runs `pnpm -C ./packages/tokens fetch:figma` to fetch and transform Figma data
|
|
318
|
+
4. **Quality Assurance**: Builds and tests the updated tokens to ensure integrity
|
|
319
|
+
5. **Pull Request Creation**: Creates a new branch and pull request with the changes
|
|
320
|
+
|
|
321
|
+
**Required Secrets**:
|
|
322
|
+
|
|
323
|
+
- **`FIGMA_TOKEN`**: Personal Access Token from Figma (required for API access)
|
|
324
|
+
|
|
325
|
+
**Permissions**:
|
|
326
|
+
|
|
327
|
+
The workflow requires the following permissions:
|
|
328
|
+
|
|
329
|
+
- `contents: write` - To create branches and commits
|
|
330
|
+
- `pull-requests: write` - To create pull requests
|
|
331
|
+
|
|
332
|
+
**Usage Example**:
|
|
333
|
+
|
|
334
|
+
1. Navigate to the Actions tab in the GitHub repository
|
|
335
|
+
2. Select "Sync Figma variables to tokens"
|
|
336
|
+
3. Click "Run workflow"
|
|
337
|
+
4. Configure the input parameters as needed
|
|
338
|
+
5. Click "Run workflow" to start the process
|
|
339
|
+
|
|
340
|
+
The workflow will automatically create a pull request with reviewers assigned (`kirchsuSICKAG`, `schilchSICKAG`) for review and approval.
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
|
|
344
|
+
### Updating Test Files
|
|
345
|
+
|
|
346
|
+
When adding new tokens or changing existing token values, the test reference files in `packages/tokens/test/` must be updated to maintain test integrity.
|
|
347
|
+
|
|
348
|
+
#### Test System Overview
|
|
349
|
+
|
|
350
|
+
The token package includes a test system that validates the consistency between the built token files and reference files:
|
|
351
|
+
|
|
352
|
+
- **`test/light.css`**: Reference file containing expected CSS variables for the light theme
|
|
353
|
+
- **`test/dark.css`**: Reference file containing expected CSS variables for the dark theme
|
|
354
|
+
- **`test/test-css-variables.js`**: Test script that compares built files against reference files
|
|
355
|
+
|
|
356
|
+
#### When to Update Test Files
|
|
357
|
+
|
|
358
|
+
Test files need to be updated in the following scenarios:
|
|
359
|
+
|
|
360
|
+
1. **Adding new tokens**: When new design tokens are added to Figma and fetched
|
|
361
|
+
2. **Changing token values**: When existing token values are modified in Figma
|
|
362
|
+
3. **Removing tokens**: When tokens are deprecated or removed from the design system
|
|
363
|
+
|
|
364
|
+
#### How to Update Test Files
|
|
365
|
+
|
|
366
|
+
After the new / updated tokens are fetched and build:
|
|
367
|
+
|
|
368
|
+
1. **Build the tokens**: Ensure the latest tokens are built
|
|
369
|
+
|
|
370
|
+
```bash
|
|
371
|
+
cd packages/tokens
|
|
372
|
+
pnpm build
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
2. **Run the comparison test**: This will show differences between built and reference files
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
pnpm compare
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
3. **Update reference files**: If the changes are intentional, copy the built files to the test directory or update the files manually with the changes
|
|
382
|
+
|
|
383
|
+
```bash
|
|
384
|
+
# Copy the newly built files to serve as new reference files
|
|
385
|
+
cp dist/themes/light.css test/light.css
|
|
386
|
+
cp dist/themes/dark.css test/dark.css
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
4. **Verify the update**: Run the test again to ensure everything matches
|
|
390
|
+
```bash
|
|
391
|
+
pnpm compare
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
#### Test Output
|
|
395
|
+
|
|
396
|
+
The test script provides detailed feedback:
|
|
397
|
+
|
|
398
|
+
- ✅ **Success**: When all variables match between built and reference files
|
|
399
|
+
- 🚫 **Missing variables**: Variables present in reference but missing in built files
|
|
400
|
+
- ➕ **Extra variables**: New variables in built files not present in reference
|
|
401
|
+
- 🔄 **Different values**: Variables with changed values between built and reference files
|
|
402
|
+
|
|
403
|
+
#### Important Notes
|
|
404
|
+
|
|
405
|
+
- Always review the test output carefully before updating reference files
|
|
406
|
+
- The reference files serve as a safeguard against unintended token changes
|
|
407
|
+
|
|
408
|
+
---
|