Skip to content

Commit f4dfbf3

Browse files
committed
feat(themes): Added initial implementation of themes library
1 parent 2118f4a commit f4dfbf3

30 files changed

+2889
-235
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ FORCE_COLOR=1
3030

3131
STORM_FILE_BANNER="This code was developed by Storm Software (https://stormsoftware.org) and is licensed under the Apache License 2.0."
3232

33-
33+
STORM_LOG_LEVEL="all"
3434

3535
# Nx 18 enables using plugins to infer targets by default
3636
# This is disabled for existing workspaces to maintain compatibility

nx.json

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,6 @@
1717
"!{projectRoot}/cypress.config.[jt]s"
1818
]
1919
},
20-
"targetDefaults": {
21-
"nx-release-publish": {
22-
"cache": false,
23-
"inputs": ["default", "^production"],
24-
"dependsOn": ["^build"],
25-
"executor": "@storm-software/workspace-tools:npm-publish",
26-
"options": {
27-
"packageRoot": "dist/{projectRoot}",
28-
"registry": "https://registry.npmjs.org/"
29-
}
30-
}
31-
},
3220
"generators": {
3321
"@nx/react": {
3422
"application": {
@@ -42,6 +30,30 @@
4230
}
4331
}
4432
},
33+
"release": {
34+
"projects": ["packages/*"],
35+
"projectsRelationship": "independent",
36+
"releaseTagPattern": "{projectName}@{version}",
37+
"changelog": {
38+
"automaticFromRef": true,
39+
"projectChangelogs": {
40+
"createRelease": "github"
41+
}
42+
},
43+
"version": {
44+
"conventionalCommits": true,
45+
"generator": "@storm-software/workspace-tools:release-version"
46+
}
47+
},
48+
"plugins": [
49+
"@nx/plugin",
50+
"@nx/js",
51+
"@nx/jest",
52+
"@nx/eslint",
53+
"@nx/eslint-plugin",
54+
"@nx/esbuild",
55+
"@storm-software/workspace-tools"
56+
],
4557
"pluginsConfig": {
4658
"@nx/js": {
4759
"analyzeSourceFiles": true

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,13 @@
7373
"release": "npx storm-git release",
7474
"test": "echo Skipping all workspace testing..."
7575
},
76+
"prettier": "@storm-software/linting-tools/prettier/config.json",
7677
"dependencies": {
7778
"@biomejs/biome": "^1.5.1",
7879
"@nderscore/tamagui-typescript-plugin": "^0.6.0",
7980
"@nx/cypress": "18.0.4",
8081
"@nx/devkit": "18.0.4",
82+
"@nx/eslint-plugin": "^18.0.4",
8183
"@nx/jest": "18.0.4",
8284
"@nx/js": "18.0.4",
8385
"@nx/next": "18.0.4",
@@ -96,7 +98,7 @@
9698
"@swc/helpers": "0.5.3",
9799
"@testing-library/react": "14.0.0",
98100
"@types/jest": "29.5.12",
99-
"@types/node": "^20.10.5",
101+
"@types/node": "^20.11.20",
100102
"@types/react": "18.2.55",
101103
"@types/react-dom": "18.2.17",
102104
"babel-jest": "^29.4.1",
@@ -164,7 +166,8 @@
164166
"@storm-stack/nx-tools": "workspace:*",
165167
"@storm-stack/web-docs": "workspace:*",
166168
"@storm-stack/server-cache": "workspace:*",
167-
"@storm-stack/style-dictionary": "workspace:*"
169+
"@storm-stack/style-dictionary": "workspace:*",
170+
"@storm-stack/themes": "workspace:*"
168171
}
169172
},
170173
"triggerEmptyDevReleaseByIncrementingThisNumber": 0
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
{
22
"name": "@storm-stack/style-dictionary",
33
"version": "0.0.1",
4+
"private": false,
45
"description": "⚡ The storm-stack monorepo contains utility applications, tools, and various libraries to create modern and scalable web applications.",
56
"repository": {
67
"type": "github",
78
"url": "https://github.com/storm-software/storm-stack.git",
89
"directory": "packages/style-dictionary"
910
},
10-
"private": true,
1111
"type": "module",
1212
"publishConfig": {
1313
"access": "public"
1414
},
1515
"dependencies": {
16+
"@tokens-studio/sd-transforms": "^0.14.2",
1617
"style-dictionary": "^3.9.2"
1718
}
1819
}

packages/style-dictionary/src/config/config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ export default {
6262
// }],
6363
source: ["tokens/**/*.json"],
6464
platforms: {
65-
css: {
66-
transformGroup: "css",
65+
tamagui: {
66+
transformGroup: "storm/tamagui",
6767
buildPath: "build/",
6868
files: [
6969
{
70-
destination: "variables.css",
71-
format: "css/variables"
70+
format: "javascript/module-flat",
71+
destination: "design-tokens.js"
7272
}
7373
]
7474
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./register-tamagui";
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { EMPTY_STRING, NEWLINE_STRING } from "@storm-stack/utilities";
2+
import type StyleDictionary from "style-dictionary";
3+
import { type ColorPaletteGroup, DesignTokenGroupKind, DesignTokenTypes } from "../types";
4+
5+
export const registerTamaguiFormat = (sd: typeof StyleDictionary) => {
6+
sd.registerFormat({
7+
name: "storm/tamagui/color-palettes",
8+
formatter: ({ dictionary }) =>
9+
`export const ColorPalettes = { ${dictionary.allTokens
10+
.filter(
11+
(token) =>
12+
token?.$type === DesignTokenGroupKind.COLOR_PALETTE &&
13+
token?.type === DesignTokenGroupKind.COLOR_PALETTE
14+
)
15+
.map((token) => {
16+
const palettes = Object.values(token.value).filter(
17+
(child: any) =>
18+
child?.$type === DesignTokenGroupKind.COLOR_PALETTE &&
19+
child?.type === DesignTokenGroupKind.COLOR_PALETTE
20+
) as ColorPaletteGroup[];
21+
22+
return palettes
23+
.map(
24+
(palette) =>
25+
`${palette.name}: [ ${Object.keys(palette)
26+
.filter((key) => palette[key]?.type === DesignTokenTypes.COLOR)
27+
.sort()
28+
.map((key) => palette[key]?.value ?? EMPTY_STRING)
29+
.join(", ")} ]`
30+
)
31+
.join(`,${NEWLINE_STRING}`);
32+
})
33+
.join("\n")};`
34+
});
35+
};

packages/style-dictionary/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
*/
99

1010
export * from "./config";
11+
export * from "./transforms";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./register-tamagui";
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type StyleDictionary from "style-dictionary";
2+
3+
export const registerTamaguiTransformGroup = (sd: typeof StyleDictionary) => {
4+
sd.registerTransformGroup({
5+
name: "storm/tamagui",
6+
transforms: [
7+
"storm/transform/color-palette",
8+
"name/cti/snake",
9+
"ts/descriptionToComment",
10+
"ts/size/px",
11+
"ts/opacity",
12+
"ts/size/lineheight",
13+
"ts/typography/fontWeight",
14+
"ts/resolveMath",
15+
"ts/size/css/letterspacing",
16+
"ts/typography/css/fontFamily",
17+
"ts/typography/css/shorthand",
18+
"ts/border/css/shorthand",
19+
"ts/shadow/css/shorthand",
20+
"ts/color/css/hexrgba",
21+
"ts/color/modifiers"
22+
]
23+
});
24+
};

0 commit comments

Comments
 (0)