Skip to content

Commit 7a690af

Browse files
pixlwaverobintown
andauthored
Bundle and export the color palette generation tools (#191)
* Extract the Leonardo theme generation into its own file. * Use Vite to serve and bundle the color tools * Copy the bundled sources to mobile. * Remove colour studio CI job. The build is already building it :D --------- Co-authored-by: Robin <[email protected]>
1 parent b15eef6 commit 7a690af

File tree

21 files changed

+822
-6424
lines changed

21 files changed

+822
-6424
lines changed

.github/workflows/automation.yaml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,3 @@ jobs:
6262
echo "$(git status)"
6363
exit 1
6464
fi
65-
66-
build-colour-studio:
67-
name: Build color system generator
68-
runs-on: ubuntu-latest
69-
steps:
70-
- name: Checkout code
71-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
72-
- name: Set up cache
73-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
74-
with:
75-
node-version: "lts/*"
76-
cache: yarn
77-
- name: Install dependencies
78-
run: yarn install --frozen-lockfile
79-
working-directory: scripts/colour-studio
80-
- name: Build generated files
81-
run: yarn build
82-
working-directory: scripts/colour-studio

Package.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ let package = Package(
99
.library(name: "CompoundDesignTokens", targets: ["CompoundDesignTokens"])
1010
],
1111
targets: [
12-
.target(name: "CompoundDesignTokens", path: "assets/ios/swift")
12+
.target(name: "CompoundDesignTokens",
13+
path: "assets/ios/swift",
14+
resources: [.copy("Resources/theme.iife.js")])
1315
]
1416
)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Tokens are exported to three platforms
2424

2525
- [Development](./docs/development.md)
2626
- [Icons](./docs/icons.md)
27+
- [Colors](./docs/colors.md)
2728
- [Release](./docs/release.md)
2829
- [Synchronise with Figma](https://compound.element.io/?path=/docs/design-get-started--docs)
2930

assets/android/res/theme.iife.js

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Foundation
2+
3+
public extension CompoundDesignTokens {
4+
static let bundle = Bundle.module
5+
}

assets/ios/swift/Resources/theme.iife.js

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.3.2/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.3.3/schema.json",
33
"files": {
44
"includes": ["**", "!**/assets", "!**/tokens", "!**/icons/$icons.json"]
55
},

build.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Please see LICENSE files in the repository root for full details.
88
*/
99

1010
import type { Platform, Theme } from "./src/@types/index";
11+
import { copyThemeDist } from "./src/copyThemeDist";
1112
import * as setupStyleDictionary from "./src/setupStyleDictionary";
1213
import { generateCssIndex } from "./src/utils/generateCssIndex";
1314
import generateIconComponents from "./src/utils/generateIconComponents";
@@ -18,6 +19,7 @@ const platforms: Platform[] = ["web", "android", "ios"];
1819

1920
await normalizeTokens();
2021
await generateIconComponents();
22+
await copyThemeDist();
2123
generateCssIndex();
2224

2325
for (const platform of platforms) {

docs/colors.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# 🎨 Colors
2+
3+
All of Compound's color tokens are generated from a handful of *key colors* using a script based on Leonardo Color by Adobe. This repository includes a web applet which can be used to visualize the generated color palette and experiment with custom key colors. To launch it, run:
4+
5+
```
6+
yarn dev:colors
7+
```
8+
9+
Additionally when built, the design tokens package provides a set of JS utilities for generating color scales from custom key colors on the fly in apps, just like those seen in the web applet.

package.json

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
"description": "Compound design tokens",
55
"sideEffects": false,
66
"scripts": {
7-
"build": "tsx ./build.ts",
7+
"build": "vite build && tsx ./build.ts",
88
"sync:icons": "tsx src/syncIcons.ts",
99
"dev": "http-server .",
10+
"dev:colors": "vite --open src/colors/applet.html",
1011
"format": "yarn exec biome -- format",
1112
"lint": "yarn exec biome -- lint",
1213
"check": "yarn exec biome -- check",
@@ -28,18 +29,18 @@
2829
"./*": "./*",
2930
"./assets/web/js": "./assets/web/js/index.js",
3031
"./assets/web/js/*": {
31-
"import": "./assets/web/js/*.js",
32-
"types": "./assets/web/js/*.d.ts"
32+
"types": "./assets/web/js/*.d.ts",
33+
"import": "./assets/web/js/*.js"
3334
},
3435
"./assets/web/icons": {
36+
"types": "./assets/web/icons/index.d.ts",
3537
"import": "./assets/web/icons/index.js",
36-
"require": "./assets/web/icons/index.cjs",
37-
"types": "./assets/web/icons/index.d.ts"
38+
"require": "./assets/web/icons/index.cjs"
3839
},
3940
"./assets/web/icons/*": {
41+
"types": "./assets/web/icons/*.d.ts",
4042
"import": "./assets/web/icons/*.js",
41-
"require": "./assets/web/icons/*.cjs",
42-
"types": "./assets/web/icons/*.d.ts"
43+
"require": "./assets/web/icons/*.cjs"
4344
}
4445
},
4546
"author": "",
@@ -53,6 +54,7 @@
5354
"url": "https://github.com/element-hq/compound-design-tokens"
5455
},
5556
"devDependencies": {
57+
"@adobe/leonardo-contrast-colors": "^1.0.0",
5658
"@babel/core": "^7.24.7",
5759
"@babel/generator": "^7.24.7",
5860
"@babel/plugin-transform-react-jsx": "^7.24.7",
@@ -67,6 +69,8 @@
6769
"@types/fs-extra": "^11.0.4",
6870
"@types/lodash-es": "^4.17.12",
6971
"@types/node": "^24.0.0",
72+
"apca-w3": "^0.1.9",
73+
"chroma-js": "^3.0.0",
7074
"fast-glob": "^3.3.2",
7175
"fs-extra": "^11.3.1",
7276
"http-server": "^14.1.1",
@@ -77,6 +81,7 @@
7781
"tsx": "^4.15.6",
7882
"typescript": "^5.4.5",
7983
"undici": "^7.2.0",
84+
"vite": "^7.1.12",
8085
"zod": "^4.0.0"
8186
},
8287
"dependencies": {},

0 commit comments

Comments
 (0)