Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9af6920
chore(tokens) use typescript
myrta2302 Apr 29, 2025
0e9ab1f
Merge branch 'main' into 4499-use-typescript-in-the-tokens-package
myrta2302 May 30, 2025
b596540
type object-deepmerge
myrta2302 May 30, 2025
8929299
update object textoutput and deepmerge
myrta2302 May 30, 2025
4911fcb
methods.ts update
myrta2302 Jun 2, 2025
9e2ad2d
update all.ts and methods.ts
myrta2302 Jun 18, 2025
92cbdfe
updated replaceAllReferences function in methods.ts
myrta2302 Jun 27, 2025
cd4bfcc
update style-dictionary.ts
myrta2302 Jun 27, 2025
4c51611
remove meta interface change to LocalOptions
myrta2302 Jun 27, 2025
d76f3d3
type cleanup
myrta2302 Jun 27, 2025
f462532
update package.json and relative paths
myrta2302 Jun 27, 2025
00ff30d
update object-deepmerge.ts
myrta2302 Jun 27, 2025
77904de
Merge branch 'main' into 4499-use-typescript-in-the-tokens-package
myrta2302 Jun 27, 2025
509282b
add pnpm.-lock.yaml
myrta2302 Jun 27, 2025
a8b478f
fix code smell
myrta2302 Jun 27, 2025
7aac924
review comments update
myrta2302 Jul 7, 2025
551df5f
review comments update
myrta2302 Jul 7, 2025
9660451
Merge branch 'main' into 4499-use-typescript-in-the-tokens-package
myrta2302 Jul 18, 2025
74ec32f
update scripts
myrta2302 Jul 18, 2025
98b232a
Update pnpm-lock.yaml
myrta2302 Jul 18, 2025
c8e615b
Merge branch 'main' into 4499-use-typescript-in-the-tokens-package
myrta2302 Jul 18, 2025
f337485
Merge branch 'main' into 4499-use-typescript-in-the-tokens-package
myrta2302 Jul 21, 2025
89fb5c3
fix merge error
myrta2302 Jul 21, 2025
504a111
Merge branch 'main' into 4499-use-typescript-in-the-tokens-package
myrta2302 Jul 25, 2025
8e927ed
merge conflict update
myrta2302 Jul 25, 2025
8f2a440
Merge branch 'main' into 4499-use-typescript-in-the-tokens-package
myrta2302 Jul 25, 2025
9598986
Update pnpm-lock.yaml
myrta2302 Jul 25, 2025
73f48f6
Merge branch '4499-use-typescript-in-the-tokens-package' of https://g…
myrta2302 Jul 25, 2025
eb7f149
Merge branch 'main' into 4499-use-typescript-in-the-tokens-package
myrta2302 Aug 15, 2025
5a700d2
review comments update
myrta2302 Aug 15, 2025
2176689
code smell fix
myrta2302 Aug 15, 2025
373f335
Merge branch 'main' into 4499-use-typescript-in-the-tokens-package
myrta2302 Aug 18, 2025
96b0106
review comments update
myrta2302 Aug 22, 2025
74ae515
Update style-dictionary.ts
myrta2302 Aug 26, 2025
e0e2ea9
merge to tailwind 4 change
myrta2302 Aug 26, 2025
6f7a60a
Merge branch 'main' into 4499-use-typescript-in-the-tokens-package
myrta2302 Aug 26, 2025
c3a9ac0
add changeset
myrta2302 Aug 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions packages/tokens/_build/utils/object-deepmerge.js

This file was deleted.

8 changes: 6 additions & 2 deletions packages/tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"license": "Apache-2.0",
"private": false,
"type": "module",
"types": "dist/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/swisspost/design-system.git"
Expand All @@ -20,7 +21,7 @@
"linkDirectory": true
},
"scripts": {
"build": "pnpm clean && node ./build.js && pnpm copy-files",
"build": "pnpm clean && tsc -p . && node ./dist/build.js && pnpm copy-files",
"build:verbose": "node ./build.js --verbosity=verbose",
"clean": "rimraf dist",
"lint": "eslint",
Expand All @@ -30,11 +31,14 @@
"devDependencies": {
"@eslint/js": "9.18.0",
"@tokens-studio/sd-transforms": "1.2.9",
"@types/node": "22.10.5",
"copyfiles": "2.4.1",
"eslint": "9.18.0",
"globals": "16.0.0",
"rimraf": "6.0.1",
"style-dictionary": "4.3.0"
"style-dictionary": "4.3.0",
"typescript": "5.8.3",
"typescript-eslint": "8.20.0"
},
"keywords": [
"tokens",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { fileHeader } from 'style-dictionary/utils';
import { expandTypesMap } from '@tokens-studio/sd-transforms';
import StyleDictionary from '../style-dictionary.js';
import StyleDictionary, { type Config } from 'style-dictionary';
import { getSetName, getSet, getTokenValue, registerConfigMethod } from '../methods.js';

import { LocalOptions } from 'style-dictionary/types';
/**
* Registers a config getter method to generate output files for all code relevant tokens in the tokens.json.
*/
Expand All @@ -19,7 +19,11 @@ registerConfigMethod((tokenSets, { sourcePath, buildPath }) => {
include: [`${sourcePath}_temp/source/**/*.json`],
platforms: {
scss: {
transforms: ['name/kebab', 'swisspost/scss-no-unitless-zero-values', 'swisspost/px-to-rem'],
transforms: [
'name/kebab',
'swisspost/scss-no-unitless-zero-values',
'swisspost/px-to-rem',
],
buildPath,
expand: {
include: ['typography'],
Expand Down Expand Up @@ -55,8 +59,9 @@ registerConfigMethod((tokenSets, { sourcePath, buildPath }) => {
*/
StyleDictionary.registerFilter({
name: 'swisspost/scss-filter',
filter: (token, { meta }) => {
return token.filePath.includes(`/output/${meta.filePath}`);
filter: (token, options) => {
const configOptions = options as Config & LocalOptions;
return token.filePath.includes(`/output/${configOptions.meta.filePath}`);
},
});

Expand All @@ -81,7 +86,7 @@ StyleDictionary.registerFormat({
return (
header +
meta.setNames
.map(setName => {
.map((setName: string) => {
const tokenSetName = getSetName(options, setName);
const tokenSet = getSet(options, dictionary, setName)
.map(token => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TOKENSET_NAMES } from '../constants.js';
registerConfigMethod((tokenSets, { sourcePath, buildPath }) => {
const paletteSet = tokenSets.output[TOKENSET_NAMES.Palettes];

if (!paletteSet) return;
if (!paletteSet) return [];

const { type, layer, filePath, sets } = paletteSet;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ StyleDictionary.registerFormat({
const tokenObj = token.path
.slice(token.path.indexOf(TOKENSET_PREFIX) + 1)
.reverse()
.reduce((res, p) => ({ [p]: res }), getTokenValue(options, token));
.reduce((res, p) => ({ [p]: res }), getTokenValue(options, token)) as object;

return objectDeepmerge(allTokens, tokenObj);
}, {});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,34 @@ import { registerConfigMethod, getTokenValue } from '../methods.js';
*/
registerConfigMethod((tokenSets, { sourcePath, buildPath }) => {
const { type, layer, filePath, sets } = tokenSets.output[TOKENSET_NAMES.Utilities];

return {
meta: {
type,
layer,
filePath,
setNames: Object.keys(sets),
},
source: [`${sourcePath}_temp/output/${filePath}`],
include: [`${sourcePath}_temp/source/**/*.json`],
platforms: {
utilities: {
transforms: ['name/kebab'],
buildPath,
files: [
{
destination: `_utilities-formatted.scss`,
filter: 'swisspost/source-tokens-filter',
format: 'swisspost/utility-format',
options: {
outputReferences: true,
return [
{
meta: {
type,
layer,
filePath,
setNames: Object.keys(sets),
},
source: [`${sourcePath}_temp/output/${filePath}`],
include: [`${sourcePath}_temp/source/**/*.json`],
platforms: {
utilities: {
transforms: ['name/kebab'],
buildPath,
files: [
{
destination: `_utilities-formatted.scss`,
filter: 'swisspost/source-tokens-filter',
format: 'swisspost/utility-format',
options: {
outputReferences: true,
},
},
},
],
],
},
},
},
};
];
});

/**
Expand All @@ -48,7 +49,7 @@ StyleDictionary.registerFormat({
const utilityTokens = new Map();

dictionary.allTokens.forEach(token => {
const { subitem, state } = token.attributes;
const { subitem, state } = token.attributes || {};

const previousStates = utilityTokens.get(subitem) ?? [];
const newState = `\n ${state}: ${getTokenValue(options, token)},`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ export const EXPLICIT_COMPONENT_LAYER_GROUPNAMES = [
];
export const EXPLICIT_FIGMAONLY_GROUPNAMES = ['figmaonly'];
export const EXPLICIT_FIGMAONLY_SETNAMES = ['figmaonly'];

export const TOKENSET_LAYERS = {
core: 'core',
semantic: 'semantic',
component: 'component',
};
semantic: 'semantic',
} as const;

export const TOKENSET_PREFIX = 'post';
export const CUSTOM_FORMAT_INDENT = ' ';

Expand Down
Loading