Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: updating style-dictionary and tokens studio version #52

Merged
merged 6 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file modified .yarn/install-state.gz
Binary file not shown.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@linode/design-language-system",
"version": "2.5.1",
"version": "2.6.0",
"type": "module",
"module": "dist/index.js",
"exports": {
Expand Down Expand Up @@ -46,11 +46,11 @@
},
"homepage": "https://github.com/linode/design-language-system#readme",
"dependencies": {
"@tokens-studio/sd-transforms": "^0.15.2",
"@tokens-studio/sd-transforms": "1.2.0",
"react": "^17.0.2",
"react-copy-to-clipboard": "^5.1.0",
"react-dom": "^17.0.2",
"style-dictionary": "4.0.0-prerelease.25"
"style-dictionary": "4.0.1"
},
"devDependencies": {
"@storybook/addon-essentials": "^8.1.10",
Expand Down
4 changes: 2 additions & 2 deletions style-dictionary/build.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import StyleDictionary from 'style-dictionary';
import { promises } from 'fs';
import { registerTransforms, permutateThemes } from '@tokens-studio/sd-transforms';
import { register, permutateThemes } from '@tokens-studio/sd-transforms';
import { registerJavascriptNested } from './formats/registerJavascriptNested.ts';
import { registerTypescriptNestedDefinitions } from './formats/registerTypescriptNestedDefinitions.ts';
import { registerJsonFlat } from './formats/registerJsonFlat.ts';
Expand All @@ -12,7 +12,7 @@ const content = buffer.toString('utf-8');
const $themes = JSON.parse(content);

// https://github.com/tokens-studio/sd-transforms
registerTransforms(StyleDictionary);
register(StyleDictionary);

registerJavascriptNested();
registerTypescriptNestedDefinitions();
Expand Down
15 changes: 11 additions & 4 deletions style-dictionary/configs/getStyleDictionaryConfig.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Config } from "style-dictionary/types";

import type { StyleDictionaryOptions } from '../types.ts';

import { expandTypesMap } from '@tokens-studio/sd-transforms';
const PREFIX = 'token';

export function getStyleDictionaryConfig(
Expand All @@ -19,9 +19,14 @@ export function getStyleDictionaryConfig(
return {
// If we want to show collisions, we can change `include` to `source`.
include: theme.selectedTokenSets.map(tokenset => `tokens/${tokenset}.json`),
preprocessors: ["tokens-studio"],
expand: {
typesMap: expandTypesMap,
},
platforms: {
js: {
transforms: ['name/pascal', 'size/px', 'color/hex', 'ts/shadow/css/shorthand', 'ts/typography/css/shorthand'],
transformGroup: 'tokens-studio',
transforms: ['name/pascal', 'size/px', 'color/hex', 'shadow/css/shorthand', 'typography/css/shorthand'],
buildPath,
prefix: `${PREFIX}-`,
files: [
Expand All @@ -44,7 +49,8 @@ export function getStyleDictionaryConfig(
]
},
scss: {
transforms: ['name/kebab', 'time/seconds', 'size/px', 'color/css', 'ts/shadow/css/shorthand', 'ts/typography/css/shorthand'],
transformGroup: 'tokens-studio',
transforms: ['name/kebab', 'time/seconds', 'size/px', 'color/css', 'shadow/css/shorthand', 'typography/css/shorthand'],
buildPath,
prefix: `${PREFIX}-`,
files: [
Expand All @@ -55,7 +61,8 @@ export function getStyleDictionaryConfig(
]
},
css: {
transforms: ['name/kebab', 'time/seconds', 'size/px', 'color/css', 'ts/shadow/css/shorthand', 'ts/typography/css/shorthand'],
transformGroup: 'tokens-studio',
transforms: ['name/kebab', 'time/seconds', 'size/px', 'color/css', 'shadow/css/shorthand', 'typography/css/shorthand'],
buildPath,
prefix: `${PREFIX}-`,
files: [
Expand Down
2 changes: 1 addition & 1 deletion style-dictionary/formats/registerJavascriptNested.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { convertTokensToFlatObject } from '../utilities/convertTokensToFlatObjec
export const registerJavascriptNested = () =>
StyleDictionary.registerFormat({
name: 'javascript/nested',
formatter(formatterArguments) {
format(formatterArguments) {
const tokens = formatterArguments.dictionary.tokens;
const transformedTokens = convertTokensToFlatObject(tokens);
const transformedOutput = generateNestedOutput({
Expand Down
2 changes: 1 addition & 1 deletion style-dictionary/formats/registerJsonFlat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import StyleDictionary from 'style-dictionary';
export const registerJsonFlat = () =>
StyleDictionary.registerFormat({
name: 'json/flat',
formatter: function (formatterArguments) {
format: function (formatterArguments) {
return JSON.stringify(formatterArguments.dictionary.allTokens, null, 2);
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { convertTokensToFlatObject } from '../utilities/convertTokensToFlatObjec
export const registerTypescriptNestedDefinitions = () =>
StyleDictionary.registerFormat({
name: 'typescript/nested/definitions',
formatter(formatterArguments) {
format(formatterArguments) {
const tokens = formatterArguments.dictionary.tokens;
const transformedTokens = convertTokensToFlatObject(tokens);
const transformedOutput = generateNestedOutput({
Expand Down
4 changes: 2 additions & 2 deletions tokens/components/badge/badge.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@
},
"violet": {
"background": {
"value": "{global.color.violet.30}",
"value": "{alias.accent.violet.secondary}",
"type": "color"
},
"text": {
"value": "{global.color.violet.90}",
"value": "{alias.accent.violet.primary}",
"type": "color"
}
},
Expand Down
Loading