@gnist/themes 0.0.1
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/README.md +253 -0
- package/dist/atoms.css.d.ts +140 -0
- package/dist/atoms.css.js +147 -0
- package/dist/build-utils/generate-themes.d.ts +1 -0
- package/dist/build-utils/generate-themes.js +94 -0
- package/dist/build-utils/theme-utils/formats/typescriptEsModule.d.ts +2 -0
- package/dist/build-utils/theme-utils/formats/typescriptEsModule.js +35 -0
- package/dist/build-utils/theme-utils/toCamelCase.d.ts +1 -0
- package/dist/build-utils/theme-utils/toCamelCase.js +14 -0
- package/dist/build-utils/theme-utils/transforms/figmaSizePx.d.ts +4 -0
- package/dist/build-utils/theme-utils/transforms/figmaSizePx.js +10 -0
- package/dist/build-utils/theme-utils/transforms/figmaSizeRem.d.ts +4 -0
- package/dist/build-utils/theme-utils/transforms/figmaSizeRem.js +16 -0
- package/dist/build-utils/theme-utils/transforms/figmaTypography.d.ts +2 -0
- package/dist/build-utils/theme-utils/transforms/figmaTypography.js +19 -0
- package/dist/build-utils/theme-utils/transforms/lineHeightUnitless.d.ts +4 -0
- package/dist/build-utils/theme-utils/transforms/lineHeightUnitless.js +24 -0
- package/dist/build-utils/theme-utils/transforms/shadowCss.d.ts +2 -0
- package/dist/build-utils/theme-utils/transforms/shadowCss.js +20 -0
- package/dist/colors.css.d.ts +16 -0
- package/dist/colors.css.js +23 -0
- package/dist/layers.css.d.ts +2 -0
- package/dist/layers.css.js +3 -0
- package/dist/themes/audi.css.d.ts +1 -0
- package/dist/themes/audi.css.js +4 -0
- package/dist/themes/audiTokens.d.ts +550 -0
- package/dist/themes/audiTokens.js +551 -0
- package/dist/themes/autoria.css.d.ts +1 -0
- package/dist/themes/autoria.css.js +4 -0
- package/dist/themes/autoriaTokens.d.ts +550 -0
- package/dist/themes/autoriaTokens.js +551 -0
- package/dist/themes/bilholdLight.css.d.ts +1 -0
- package/dist/themes/bilholdLight.css.js +4 -0
- package/dist/themes/bilholdLightTokens.d.ts +550 -0
- package/dist/themes/bilholdLightTokens.js +551 -0
- package/dist/themes/brandless.css.d.ts +1 -0
- package/dist/themes/brandless.css.js +4 -0
- package/dist/themes/brandlessTokens.d.ts +550 -0
- package/dist/themes/brandlessTokens.js +551 -0
- package/dist/themes/cupra.css.d.ts +1 -0
- package/dist/themes/cupra.css.js +4 -0
- package/dist/themes/cupraTokens.d.ts +550 -0
- package/dist/themes/cupraTokens.js +551 -0
- package/dist/themes/dahles.css.d.ts +1 -0
- package/dist/themes/dahles.css.js +4 -0
- package/dist/themes/dahlesTokens.d.ts +550 -0
- package/dist/themes/dahlesTokens.js +551 -0
- package/dist/themes/gumpen.css.d.ts +1 -0
- package/dist/themes/gumpen.css.js +4 -0
- package/dist/themes/gumpenTokens.d.ts +550 -0
- package/dist/themes/gumpenTokens.js +551 -0
- package/dist/themes/mollerBil.css.d.ts +1 -0
- package/dist/themes/mollerBil.css.js +4 -0
- package/dist/themes/mollerBilTokens.d.ts +550 -0
- package/dist/themes/mollerBilTokens.js +551 -0
- package/dist/themes/skodaDark.css.d.ts +1 -0
- package/dist/themes/skodaDark.css.js +4 -0
- package/dist/themes/skodaDarkTokens.d.ts +550 -0
- package/dist/themes/skodaDarkTokens.js +551 -0
- package/dist/themes/tools.css.d.ts +1 -0
- package/dist/themes/tools.css.js +4 -0
- package/dist/themes/toolsTokens.d.ts +550 -0
- package/dist/themes/toolsTokens.js +551 -0
- package/dist/themes/vw.css.d.ts +1 -0
- package/dist/themes/vw.css.js +4 -0
- package/dist/themes/vwTokens.d.ts +550 -0
- package/dist/themes/vwTokens.js +551 -0
- package/dist/themes.css.d.ts +11 -0
- package/dist/themes.css.js +11 -0
- package/dist/tokens.css.d.ts +550 -0
- package/dist/tokens.css.js +8 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/typography.css.d.ts +16 -0
- package/dist/typography.css.js +34 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# Themes for @gnist/design-system
|
|
2
|
+
|
|
3
|
+
`@gnist/themes` is a library containing themes, design tokens and atomic css used by `@gnist/design-system`,
|
|
4
|
+
but which can also be used on its own. It is based on [vanilla-extract](https://vanilla-extract.style/) under the hood,
|
|
5
|
+
and requires an extra compilation step. See [Setup](#setup) for details.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
This library exposes the following parts: themes, tokens, atoms, colors, and typography
|
|
10
|
+
|
|
11
|
+
### Themes
|
|
12
|
+
|
|
13
|
+
A theme is a css class which sets a number of variables. Developers can refer to these through [Tokens](#tokens).
|
|
14
|
+
|
|
15
|
+
Basic usage:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { bilholdLight } from "@gnist/themes/themes/bilholdLight.css.js";
|
|
19
|
+
|
|
20
|
+
// add the class to the <body> element either inline (e.g in a Next layout) or programatically
|
|
21
|
+
document.body.classList.add(bilholdLight);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
These themes currently exist and can be referred to in the way described above
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
audi
|
|
28
|
+
autoria
|
|
29
|
+
bilholdLight
|
|
30
|
+
brandless
|
|
31
|
+
cupra
|
|
32
|
+
dahles
|
|
33
|
+
gumpen
|
|
34
|
+
mollerBil
|
|
35
|
+
skodaDark
|
|
36
|
+
vw
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Tokens
|
|
40
|
+
|
|
41
|
+
Tokens allow you to programatically look up css variables based on our design token structure, in a type safe manner.
|
|
42
|
+
|
|
43
|
+
Example:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { tokens } from "@gnist/themes/tokens.css.js";
|
|
47
|
+
|
|
48
|
+
const color = tokens.color.primary; // "var(--moller-color-primary)"
|
|
49
|
+
const size = tokens.size.xxl; // "var(--moller-size-xxl)"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
More usefully, these can be interpolated directly in a `styled-components` or `vanilla-extract` style.
|
|
53
|
+
|
|
54
|
+
### Atoms
|
|
55
|
+
|
|
56
|
+
Atoms define a set of atomic css classes which can be looked up at runtime. This allows reuse of frequently used basic
|
|
57
|
+
styling across components and apps. As a bonus, things like colors, sizes and spacing are defined in terms of our design tokens.
|
|
58
|
+
|
|
59
|
+
The `atoms` function simply returns a string containing the css class names required.
|
|
60
|
+
|
|
61
|
+
**Note:** The current set of atoms is quite small. More atoms will be added as components are reimplemented.
|
|
62
|
+
You can also suggest useful atoms to the design system team on Slack or Teams!
|
|
63
|
+
|
|
64
|
+
Example:
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import { atoms } from "@gnist/themes/atoms.css.js";
|
|
68
|
+
|
|
69
|
+
export const DangerComponent = ({ children }: PropsWithChildren) => (
|
|
70
|
+
<div
|
|
71
|
+
className={atoms({
|
|
72
|
+
display: "flex",
|
|
73
|
+
backgroundColor: "error-container", // refers to a color token
|
|
74
|
+
paddingX: "xs", // refers to a spacing token
|
|
75
|
+
})}
|
|
76
|
+
>
|
|
77
|
+
{children}
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Colors
|
|
83
|
+
|
|
84
|
+
The `colors` module exports helpers for setting colors.
|
|
85
|
+
|
|
86
|
+
#### Box colors
|
|
87
|
+
|
|
88
|
+
`boxColors` simply retrieves the correct [atoms](#atoms) for setting `backgroundColor`, `color`, and `borderColor` for a given color type.
|
|
89
|
+
E.g. for the color `primary` we want `primary` background-color, and `on-primary` color & border-color.
|
|
90
|
+
|
|
91
|
+
Example:
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
import { style } from "@vanilla-extract/css";
|
|
95
|
+
import { tokens } from "@gnist/themes/tokens.css.js";
|
|
96
|
+
import { boxColors } from "@gnist/themes/colors.css.js";
|
|
97
|
+
|
|
98
|
+
const box = style([
|
|
99
|
+
boxColors["primary-container"],
|
|
100
|
+
{ borderWidth: tokens.stroke.medium },
|
|
101
|
+
]);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Typography
|
|
105
|
+
|
|
106
|
+
The `typography` module exports helpers for setting correct typography styles (`responsiveTypography` and `densityTypography`),
|
|
107
|
+
and a css class for setting global text styles.
|
|
108
|
+
|
|
109
|
+
#### Responsive typography
|
|
110
|
+
|
|
111
|
+
`responsiveTypography` helps you retrieve css classes for the typography styles that change between small/medium/large based on viewport size.
|
|
112
|
+
|
|
113
|
+
It is a record which lets you look up the class names to set for the given typography style. It uses [`atoms`](#atoms) under the hood.
|
|
114
|
+
|
|
115
|
+
Some examples:
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
import { style } from "@vanilla-extract/css";
|
|
119
|
+
import { atoms } from "@gnist/themes/atoms.css.js";
|
|
120
|
+
import { responsiveTypography } from "@gnist/themes/typography.css.js"
|
|
121
|
+
|
|
122
|
+
const someStyle = style([
|
|
123
|
+
atoms({ display: "flex", padding: "xs" }),
|
|
124
|
+
responsiveTypography.lead,
|
|
125
|
+
])
|
|
126
|
+
|
|
127
|
+
// or inline
|
|
128
|
+
<div className={responsiveTypography.description}>{children}</div>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
#### Density typography
|
|
132
|
+
|
|
133
|
+
`densityTypography` helps you create a recipe (for use with `@vanilla-extract/recipe`) for the given typography styles, which has the `density: "default" | "compact"` variants,
|
|
134
|
+
and sets the correct css classes. It uses [`atoms`](#atoms) under the hood.
|
|
135
|
+
|
|
136
|
+
It is a record which, when given a typography style, returns an object with the `variants` prop which is suitable for merging into a recipe.
|
|
137
|
+
|
|
138
|
+
Example:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
import { recipe } from "@vanilla-extract/recipes";
|
|
142
|
+
import { atoms } from "@gnist/themes/atoms.css.js";
|
|
143
|
+
import { densityTypography } from "@gnist/themes/typography.css.js";
|
|
144
|
+
|
|
145
|
+
const action = recipe({
|
|
146
|
+
base: atoms({ display: "block" }),
|
|
147
|
+
...densityTypography.action,
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
const className = recipe({ density: "default" });
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Combining with other variants:
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
import { recipe } from "@vanilla-extract/recipes";
|
|
157
|
+
import { atoms } from "@gnist/themes/atoms.css.js";
|
|
158
|
+
import { densityTypography } from "@gnist/themes/typography.css.js";
|
|
159
|
+
|
|
160
|
+
const box = recipe({
|
|
161
|
+
base: [atoms({ display: "block" })],
|
|
162
|
+
variants: {
|
|
163
|
+
color: {
|
|
164
|
+
primary: boxColors["primary-container"],
|
|
165
|
+
secondary: boxColors["secondary-container"],
|
|
166
|
+
},
|
|
167
|
+
...densityTypography.notice.variants,
|
|
168
|
+
},
|
|
169
|
+
defaultVariants: { color: "primary", density: "default" },
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const className = box({ color: "secondary", density: "compact" });
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
#### Global text styles
|
|
176
|
+
|
|
177
|
+
These should be added to the root element (e.g. `<body>`) in order to set the default typography styles and colors.
|
|
178
|
+
Technically, this is a list of class names.
|
|
179
|
+
|
|
180
|
+
Usually, you would also apply the theme to this same element, as variables need to be defined for the styles to work.
|
|
181
|
+
|
|
182
|
+
Example of setting both:
|
|
183
|
+
|
|
184
|
+
```tsx
|
|
185
|
+
import { bilholdLight } from "@gnist/themes/themes.css.js";
|
|
186
|
+
import { globalTextStyles } from "@gnist/themes/typography.css.js";
|
|
187
|
+
|
|
188
|
+
document.body.classList.add(bilholdLight);
|
|
189
|
+
globalTextStyles.forEach((c) => {
|
|
190
|
+
document.body.classList.add(c);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
// In a Next layout you could rather do something like this
|
|
194
|
+
//...more layout
|
|
195
|
+
<body className={classNames(bilholdLight, globalTextStyles)}>{children}</body>;
|
|
196
|
+
//...more layout
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Setup
|
|
200
|
+
|
|
201
|
+
The library is based on [vanilla-extract](), which allows pre-compiling the styles to static css files. However, in our
|
|
202
|
+
case we defer compilation to the consuming application. This allows the consumer to compose the tokens and atoms defined
|
|
203
|
+
here in their own `vanilla-extract` based styles.
|
|
204
|
+
|
|
205
|
+
This means a compilation step for `vanilla-extract` must be added to your build configuration.
|
|
206
|
+
|
|
207
|
+
### Vite
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
npm install -D @vanilla-extract/vite-plugin @vanilla-extract/esbuild-plugin
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Your `vite.config.ts` might look like this:
|
|
214
|
+
|
|
215
|
+
```ts
|
|
216
|
+
import { defineConfig } from "vite";
|
|
217
|
+
import react from "@vitejs/plugin-react";
|
|
218
|
+
import { vanillaExtractPlugin } from "@vanilla-extract/vite-plugin";
|
|
219
|
+
import { vanillaExtractPlugin as veEsbuildPlugin } from "@vanilla-extract/esbuild-plugin";
|
|
220
|
+
|
|
221
|
+
// https://vitejs.dev/config/
|
|
222
|
+
export default defineConfig({
|
|
223
|
+
plugins: [react(), vanillaExtractPlugin()],
|
|
224
|
+
optimizeDeps: {
|
|
225
|
+
esbuildOptions: {
|
|
226
|
+
// Handle vanilla-extract .css.js files during Vite dev mode optimization
|
|
227
|
+
// This prevents error "Styles were unable to be assigned to a file." in dev mode
|
|
228
|
+
// See https://github.com/vanilla-extract-css/vanilla-extract/discussions/1051
|
|
229
|
+
plugins: [veEsbuildPlugin({ runtime: true })],
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
});
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Next.js
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
npm install -D @vanilla-extract/next-plugin
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Your `next.config.mjs` might look like this
|
|
242
|
+
|
|
243
|
+
```js
|
|
244
|
+
import { createVanillaExtractPlugin } from "@vanilla-extract/next-plugin";
|
|
245
|
+
const withVanillaExtract = createVanillaExtractPlugin();
|
|
246
|
+
|
|
247
|
+
/** @type {import('next').NextConfig} */
|
|
248
|
+
const nextConfig = {
|
|
249
|
+
// ...your configuration here...
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
export default withVanillaExtract(nextConfig);
|
|
253
|
+
```
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
export declare const textContainer: string;
|
|
2
|
+
export declare const atoms: ((props: {
|
|
3
|
+
display?: "none" | "block" | "inline" | "flex" | "grid" | "inline-flex" | {
|
|
4
|
+
mobile?: "none" | "block" | "inline" | "flex" | "grid" | "inline-flex" | undefined;
|
|
5
|
+
tablet?: "none" | "block" | "inline" | "flex" | "grid" | "inline-flex" | undefined;
|
|
6
|
+
desktop?: "none" | "block" | "inline" | "flex" | "grid" | "inline-flex" | undefined;
|
|
7
|
+
} | undefined;
|
|
8
|
+
flexDirection?: "column" | "row" | {
|
|
9
|
+
mobile?: "column" | "row" | undefined;
|
|
10
|
+
tablet?: "column" | "row" | undefined;
|
|
11
|
+
desktop?: "column" | "row" | undefined;
|
|
12
|
+
} | undefined;
|
|
13
|
+
justifyContent?: "space-around" | "space-between" | "stretch" | "center" | "flex-end" | "flex-start" | {
|
|
14
|
+
mobile?: "space-around" | "space-between" | "stretch" | "center" | "flex-end" | "flex-start" | undefined;
|
|
15
|
+
tablet?: "space-around" | "space-between" | "stretch" | "center" | "flex-end" | "flex-start" | undefined;
|
|
16
|
+
desktop?: "space-around" | "space-between" | "stretch" | "center" | "flex-end" | "flex-start" | undefined;
|
|
17
|
+
} | undefined;
|
|
18
|
+
alignItems?: "stretch" | "center" | "flex-end" | "flex-start" | {
|
|
19
|
+
mobile?: "stretch" | "center" | "flex-end" | "flex-start" | undefined;
|
|
20
|
+
tablet?: "stretch" | "center" | "flex-end" | "flex-start" | undefined;
|
|
21
|
+
desktop?: "stretch" | "center" | "flex-end" | "flex-start" | undefined;
|
|
22
|
+
} | undefined;
|
|
23
|
+
marginTop?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | {
|
|
24
|
+
mobile?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
25
|
+
tablet?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
26
|
+
desktop?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
27
|
+
} | undefined;
|
|
28
|
+
marginBottom?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | {
|
|
29
|
+
mobile?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
30
|
+
tablet?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
31
|
+
desktop?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
32
|
+
} | undefined;
|
|
33
|
+
marginLeft?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | {
|
|
34
|
+
mobile?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
35
|
+
tablet?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
36
|
+
desktop?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
37
|
+
} | undefined;
|
|
38
|
+
marginRight?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | {
|
|
39
|
+
mobile?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
40
|
+
tablet?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
41
|
+
desktop?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
42
|
+
} | undefined;
|
|
43
|
+
paddingTop?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | {
|
|
44
|
+
mobile?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
45
|
+
tablet?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
46
|
+
desktop?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
47
|
+
} | undefined;
|
|
48
|
+
paddingBottom?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | {
|
|
49
|
+
mobile?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
50
|
+
tablet?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
51
|
+
desktop?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
52
|
+
} | undefined;
|
|
53
|
+
paddingLeft?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | {
|
|
54
|
+
mobile?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
55
|
+
tablet?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
56
|
+
desktop?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
57
|
+
} | undefined;
|
|
58
|
+
paddingRight?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | {
|
|
59
|
+
mobile?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
60
|
+
tablet?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
61
|
+
desktop?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
62
|
+
} | undefined;
|
|
63
|
+
gap?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | {
|
|
64
|
+
mobile?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
65
|
+
tablet?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
66
|
+
desktop?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
67
|
+
} | undefined;
|
|
68
|
+
rowGap?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | {
|
|
69
|
+
mobile?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
70
|
+
tablet?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
71
|
+
desktop?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
72
|
+
} | undefined;
|
|
73
|
+
columnGap?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | {
|
|
74
|
+
mobile?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
75
|
+
tablet?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
76
|
+
desktop?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
77
|
+
} | undefined;
|
|
78
|
+
margin?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | {
|
|
79
|
+
mobile?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
80
|
+
tablet?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
81
|
+
desktop?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
82
|
+
} | undefined;
|
|
83
|
+
marginX?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | {
|
|
84
|
+
mobile?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
85
|
+
tablet?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
86
|
+
desktop?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
87
|
+
} | undefined;
|
|
88
|
+
marginY?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | {
|
|
89
|
+
mobile?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
90
|
+
tablet?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
91
|
+
desktop?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
92
|
+
} | undefined;
|
|
93
|
+
padding?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | {
|
|
94
|
+
mobile?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
95
|
+
tablet?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
96
|
+
desktop?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
97
|
+
} | undefined;
|
|
98
|
+
paddingX?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | {
|
|
99
|
+
mobile?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
100
|
+
tablet?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
101
|
+
desktop?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
102
|
+
} | undefined;
|
|
103
|
+
paddingY?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | {
|
|
104
|
+
mobile?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
105
|
+
tablet?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
106
|
+
desktop?: "none" | "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | undefined;
|
|
107
|
+
} | undefined;
|
|
108
|
+
} & {
|
|
109
|
+
backgroundColor?: "disabled" | "background" | "outline" | "primary" | "secondary" | "tertiary" | "tertiary-variant" | "error" | "warning" | "success" | "info" | "interactive" | "on-primary" | "primary-container" | "on-primary-container" | "on-secondary" | "secondary-container" | "on-secondary-container" | "on-tertiary" | "tertiary-container" | "on-tertiary-container" | "on-tertiary-variant" | "on-background" | "inverse-background" | "on-inverse-background" | "surface" | "on-surface" | "on-disabled" | "text-variant" | "inverse-text-variant" | "loader" | "on-loader" | "surface-variant" | "on-surface-variant" | "on-error" | "error-container" | "on-error-container" | "on-warning" | "warning-container" | "on-warning-container" | "on-success" | "success-container" | "on-success-container" | "on-info" | "info-container" | "on-info-container" | "highlight" | undefined;
|
|
110
|
+
borderColor?: "disabled" | "background" | "outline" | "primary" | "secondary" | "tertiary" | "tertiary-variant" | "error" | "warning" | "success" | "info" | "interactive" | "on-primary" | "primary-container" | "on-primary-container" | "on-secondary" | "secondary-container" | "on-secondary-container" | "on-tertiary" | "tertiary-container" | "on-tertiary-container" | "on-tertiary-variant" | "on-background" | "inverse-background" | "on-inverse-background" | "surface" | "on-surface" | "on-disabled" | "text-variant" | "inverse-text-variant" | "loader" | "on-loader" | "surface-variant" | "on-surface-variant" | "on-error" | "error-container" | "on-error-container" | "on-warning" | "warning-container" | "on-warning-container" | "on-success" | "success-container" | "on-success-container" | "on-info" | "info-container" | "on-info-container" | "highlight" | undefined;
|
|
111
|
+
color?: "disabled" | "background" | "outline" | "primary" | "secondary" | "tertiary" | "tertiary-variant" | "error" | "warning" | "success" | "info" | "interactive" | "on-primary" | "primary-container" | "on-primary-container" | "on-secondary" | "secondary-container" | "on-secondary-container" | "on-tertiary" | "tertiary-container" | "on-tertiary-container" | "on-tertiary-variant" | "on-background" | "inverse-background" | "on-inverse-background" | "surface" | "on-surface" | "on-disabled" | "text-variant" | "inverse-text-variant" | "loader" | "on-loader" | "surface-variant" | "on-surface-variant" | "on-error" | "error-container" | "on-error-container" | "on-warning" | "warning-container" | "on-warning-container" | "on-success" | "success-container" | "on-success-container" | "on-info" | "info-container" | "on-info-container" | "highlight" | undefined;
|
|
112
|
+
} & {
|
|
113
|
+
borderTopLeftRadius?: "none" | "button" | "checkbox" | "overlay" | "medium" | "large" | "small" | "x-large" | "xx-large" | "full" | "card" | "input" | "picker" | "feedback" | undefined;
|
|
114
|
+
borderTopRightRadius?: "none" | "button" | "checkbox" | "overlay" | "medium" | "large" | "small" | "x-large" | "xx-large" | "full" | "card" | "input" | "picker" | "feedback" | undefined;
|
|
115
|
+
borderBottomLeftRadius?: "none" | "button" | "checkbox" | "overlay" | "medium" | "large" | "small" | "x-large" | "xx-large" | "full" | "card" | "input" | "picker" | "feedback" | undefined;
|
|
116
|
+
borderBottomRightRadius?: "none" | "button" | "checkbox" | "overlay" | "medium" | "large" | "small" | "x-large" | "xx-large" | "full" | "card" | "input" | "picker" | "feedback" | undefined;
|
|
117
|
+
borderRadius?: "none" | "button" | "checkbox" | "overlay" | "medium" | "large" | "small" | "x-large" | "xx-large" | "full" | "card" | "input" | "picker" | "feedback" | undefined;
|
|
118
|
+
} & {
|
|
119
|
+
borderTopWidth?: "none" | "medium" | "large" | "small" | "x-small" | undefined;
|
|
120
|
+
borderBottomWidth?: "none" | "medium" | "large" | "small" | "x-small" | undefined;
|
|
121
|
+
borderLeftWidth?: "none" | "medium" | "large" | "small" | "x-small" | undefined;
|
|
122
|
+
borderRightWidth?: "none" | "medium" | "large" | "small" | "x-small" | undefined;
|
|
123
|
+
borderWidth?: "none" | "medium" | "large" | "small" | "x-small" | undefined;
|
|
124
|
+
} & {
|
|
125
|
+
boxShadow?: "none" | "medium" | "low" | "high" | undefined;
|
|
126
|
+
} & {
|
|
127
|
+
width?: "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | "4xl" | undefined;
|
|
128
|
+
height?: "base" | "xxs" | "xs" | "s" | "m" | "l" | "xl" | "xxl" | "3xl" | "4xl" | undefined;
|
|
129
|
+
} & {
|
|
130
|
+
typography?: "display-medium" | "display-large" | "display-small" | "link-medium" | "link-large" | "link-small" | "heading1-medium" | "heading1-large" | "heading1-small" | "heading2-medium" | "heading2-large" | "heading2-small" | "heading3-medium" | "heading3-large" | "heading3-small" | "lead-medium" | "lead-large" | "lead-small" | "body-medium" | "body-large" | "body-small" | "detail-medium" | "detail-large" | "detail-small" | {
|
|
131
|
+
mobile?: "display-medium" | "display-large" | "display-small" | "link-medium" | "link-large" | "link-small" | "heading1-medium" | "heading1-large" | "heading1-small" | "heading2-medium" | "heading2-large" | "heading2-small" | "heading3-medium" | "heading3-large" | "heading3-small" | "lead-medium" | "lead-large" | "lead-small" | "body-medium" | "body-large" | "body-small" | "detail-medium" | "detail-large" | "detail-small" | undefined;
|
|
132
|
+
tablet?: "display-medium" | "display-large" | "display-small" | "link-medium" | "link-large" | "link-small" | "heading1-medium" | "heading1-large" | "heading1-small" | "heading2-medium" | "heading2-large" | "heading2-small" | "heading3-medium" | "heading3-large" | "heading3-small" | "lead-medium" | "lead-large" | "lead-small" | "body-medium" | "body-large" | "body-small" | "detail-medium" | "detail-large" | "detail-small" | undefined;
|
|
133
|
+
desktop?: "display-medium" | "display-large" | "display-small" | "link-medium" | "link-large" | "link-small" | "heading1-medium" | "heading1-large" | "heading1-small" | "heading2-medium" | "heading2-large" | "heading2-small" | "heading3-medium" | "heading3-large" | "heading3-small" | "lead-medium" | "lead-large" | "lead-small" | "body-medium" | "body-large" | "body-small" | "detail-medium" | "detail-large" | "detail-small" | undefined;
|
|
134
|
+
} | undefined;
|
|
135
|
+
} & {
|
|
136
|
+
position?: "fixed" | "absolute" | "relative" | "static" | "sticky" | undefined;
|
|
137
|
+
}) => string) & {
|
|
138
|
+
properties: Set<"color" | "position" | "alignItems" | "backgroundColor" | "borderBottomLeftRadius" | "borderBottomRightRadius" | "borderBottomWidth" | "borderLeftWidth" | "borderRightWidth" | "borderTopLeftRadius" | "borderTopRightRadius" | "borderTopWidth" | "boxShadow" | "columnGap" | "display" | "flexDirection" | "height" | "justifyContent" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "rowGap" | "width" | "padding" | "borderColor" | "borderRadius" | "borderWidth" | "gap" | "margin" | "typography" | "marginX" | "marginY" | "paddingX" | "paddingY">;
|
|
139
|
+
};
|
|
140
|
+
export type Atoms = Parameters<typeof atoms>[0];
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { globalStyle, style } from "@vanilla-extract/css";
|
|
2
|
+
import { createSprinkles, defineProperties } from "@vanilla-extract/sprinkles";
|
|
3
|
+
import { typography } from "./layers.css.js";
|
|
4
|
+
import { tokens } from "./tokens.css.js";
|
|
5
|
+
export const textContainer = style({});
|
|
6
|
+
globalStyle(`${textContainer} p, ${textContainer} ul, ${textContainer} ol`, {
|
|
7
|
+
marginTop: tokens.type.small.body.paragraphSpacing,
|
|
8
|
+
"@media": {
|
|
9
|
+
"screen and (min-width: 768px)": {
|
|
10
|
+
marginTop: tokens.type.medium.body.paragraphSpacing,
|
|
11
|
+
},
|
|
12
|
+
"screen and (min-width: 1024px)": {
|
|
13
|
+
marginTop: tokens.type.large.body.paragraphSpacing,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
const spacing = tokens.spacing;
|
|
18
|
+
const responsiveProperties = defineProperties({
|
|
19
|
+
conditions: {
|
|
20
|
+
mobile: {},
|
|
21
|
+
tablet: { "@media": "screen and (min-width: 768px)" },
|
|
22
|
+
desktop: { "@media": "screen and (min-width: 1024px)" },
|
|
23
|
+
},
|
|
24
|
+
defaultCondition: "mobile",
|
|
25
|
+
properties: {
|
|
26
|
+
display: ["none", "grid", "flex", "block", "inline", "inline-flex"],
|
|
27
|
+
flexDirection: ["row", "column"],
|
|
28
|
+
justifyContent: [
|
|
29
|
+
"stretch",
|
|
30
|
+
"flex-start",
|
|
31
|
+
"center",
|
|
32
|
+
"flex-end",
|
|
33
|
+
"space-around",
|
|
34
|
+
"space-between",
|
|
35
|
+
],
|
|
36
|
+
alignItems: ["stretch", "flex-start", "center", "flex-end"],
|
|
37
|
+
marginTop: spacing,
|
|
38
|
+
marginBottom: spacing,
|
|
39
|
+
marginLeft: spacing,
|
|
40
|
+
marginRight: spacing,
|
|
41
|
+
paddingTop: spacing,
|
|
42
|
+
paddingBottom: spacing,
|
|
43
|
+
paddingLeft: spacing,
|
|
44
|
+
paddingRight: spacing,
|
|
45
|
+
gap: spacing,
|
|
46
|
+
rowGap: spacing,
|
|
47
|
+
columnGap: spacing,
|
|
48
|
+
},
|
|
49
|
+
shorthands: {
|
|
50
|
+
margin: ["marginTop", "marginBottom", "marginLeft", "marginRight"],
|
|
51
|
+
marginX: ["marginLeft", "marginRight"],
|
|
52
|
+
marginY: ["marginTop", "marginBottom"],
|
|
53
|
+
padding: ["paddingTop", "paddingBottom", "paddingLeft", "paddingRight"],
|
|
54
|
+
paddingX: ["paddingLeft", "paddingRight"],
|
|
55
|
+
paddingY: ["paddingTop", "paddingBottom"],
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
const color = tokens.color;
|
|
59
|
+
const colorProperties = defineProperties({
|
|
60
|
+
properties: {
|
|
61
|
+
backgroundColor: color,
|
|
62
|
+
borderColor: color,
|
|
63
|
+
color: color,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
const radius = { ...tokens.radius, ...tokens["border-radius"] };
|
|
67
|
+
const radiusProperties = defineProperties({
|
|
68
|
+
properties: {
|
|
69
|
+
borderTopLeftRadius: radius,
|
|
70
|
+
borderTopRightRadius: radius,
|
|
71
|
+
borderBottomLeftRadius: radius,
|
|
72
|
+
borderBottomRightRadius: radius,
|
|
73
|
+
},
|
|
74
|
+
shorthands: {
|
|
75
|
+
borderRadius: [
|
|
76
|
+
"borderBottomLeftRadius",
|
|
77
|
+
"borderBottomRightRadius",
|
|
78
|
+
"borderTopLeftRadius",
|
|
79
|
+
"borderTopRightRadius",
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
const stroke = { none: "none", ...tokens.stroke };
|
|
84
|
+
const strokeProperties = defineProperties({
|
|
85
|
+
properties: {
|
|
86
|
+
borderTopWidth: stroke,
|
|
87
|
+
borderBottomWidth: stroke,
|
|
88
|
+
borderLeftWidth: stroke,
|
|
89
|
+
borderRightWidth: stroke,
|
|
90
|
+
},
|
|
91
|
+
shorthands: {
|
|
92
|
+
borderWidth: [
|
|
93
|
+
"borderTopWidth",
|
|
94
|
+
"borderBottomWidth",
|
|
95
|
+
"borderLeftWidth",
|
|
96
|
+
"borderRightWidth",
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
const elevation = tokens.elevation;
|
|
101
|
+
const elevationProperties = defineProperties({
|
|
102
|
+
properties: {
|
|
103
|
+
boxShadow: elevation,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
const size = tokens.size;
|
|
107
|
+
const sizeProperties = defineProperties({
|
|
108
|
+
properties: {
|
|
109
|
+
width: size,
|
|
110
|
+
height: size,
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
const type = tokens.type;
|
|
114
|
+
const sizes = ["small", "medium", "large"];
|
|
115
|
+
const responsiveTypes = Object.keys(type.small);
|
|
116
|
+
const sizeTypography = Object.fromEntries(sizes.flatMap((size) => responsiveTypes.map((responsiveType) => {
|
|
117
|
+
const { paragraphSpacing, textCase, ...validProps } = type[size][responsiveType];
|
|
118
|
+
const props = {
|
|
119
|
+
margin: 0,
|
|
120
|
+
...validProps,
|
|
121
|
+
textTransform: textCase,
|
|
122
|
+
selectors: {
|
|
123
|
+
[`${textContainer} &:not(:first-child)`]: {
|
|
124
|
+
marginTop: paragraphSpacing,
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
return [`${responsiveType}-${size}`, props];
|
|
129
|
+
})));
|
|
130
|
+
const responsiveTypeProperties = defineProperties({
|
|
131
|
+
"@layer": typography,
|
|
132
|
+
conditions: {
|
|
133
|
+
mobile: {},
|
|
134
|
+
tablet: { "@media": "screen and (min-width: 768px)" },
|
|
135
|
+
desktop: { "@media": "screen and (min-width: 1024px)" },
|
|
136
|
+
},
|
|
137
|
+
defaultCondition: "mobile",
|
|
138
|
+
properties: {
|
|
139
|
+
typography: sizeTypography,
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
const positionProperties = defineProperties({
|
|
143
|
+
properties: {
|
|
144
|
+
position: ["static", "relative", "absolute", "fixed", "sticky"],
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
export const atoms = createSprinkles(responsiveProperties, colorProperties, radiusProperties, strokeProperties, elevationProperties, sizeProperties, responsiveTypeProperties, positionProperties);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import childprocess from "child_process";
|
|
2
|
+
import fs from "fs/promises";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { argv } from "process";
|
|
5
|
+
import StyleDictionaryPackage from "style-dictionary";
|
|
6
|
+
import { typescriptEsModule } from "./theme-utils/formats/typescriptEsModule.js";
|
|
7
|
+
import { toCamelCase } from "./theme-utils/toCamelCase.js";
|
|
8
|
+
import { figmaSizePx } from "./theme-utils/transforms/figmaSizePx.js";
|
|
9
|
+
import { figmaSizeRem } from "./theme-utils/transforms/figmaSizeRem.js";
|
|
10
|
+
import { figmaTypography } from "./theme-utils/transforms/figmaTypography.js";
|
|
11
|
+
import { lineHeightUnitless } from "./theme-utils/transforms/lineHeightUnitless.js";
|
|
12
|
+
import { shadowCss } from "./theme-utils/transforms/shadowCss.js";
|
|
13
|
+
const outDir = argv[2] || "themes";
|
|
14
|
+
StyleDictionaryPackage.registerFormat(typescriptEsModule);
|
|
15
|
+
StyleDictionaryPackage.registerTransform(lineHeightUnitless);
|
|
16
|
+
StyleDictionaryPackage.registerTransform(shadowCss);
|
|
17
|
+
StyleDictionaryPackage.registerTransform(figmaSizePx);
|
|
18
|
+
StyleDictionaryPackage.registerTransform(figmaSizeRem);
|
|
19
|
+
StyleDictionaryPackage.registerTransform(figmaTypography);
|
|
20
|
+
const figmaThemes = [
|
|
21
|
+
"Brandless",
|
|
22
|
+
"Bilhold light",
|
|
23
|
+
"Moller Bil",
|
|
24
|
+
"Skoda dark",
|
|
25
|
+
"Gumpen",
|
|
26
|
+
"VW",
|
|
27
|
+
"Dahles",
|
|
28
|
+
"Autoria",
|
|
29
|
+
"Audi",
|
|
30
|
+
"Cupra",
|
|
31
|
+
"Tools",
|
|
32
|
+
];
|
|
33
|
+
function transformTokens(theme, platform) {
|
|
34
|
+
console.log(`Transform tokens for ${toCamelCase(theme)}-theme`);
|
|
35
|
+
const platformSuffix = platform !== "json" ? `-${platform}` : "";
|
|
36
|
+
const outputFile = path.join(process.cwd(), `${outDir}/${toCamelCase(theme)}${platformSuffix}.tokens.json`);
|
|
37
|
+
const input = theme === "Brandless" ? "Brandless" : `Brandless,"${theme}"`;
|
|
38
|
+
const command = `npx token-transformer ${platform === "css" ? "--expandTypography" : ""}`;
|
|
39
|
+
childprocess.execSync(`${command} ../../figma/tokens.json ${outputFile} ${input}`);
|
|
40
|
+
return outputFile;
|
|
41
|
+
}
|
|
42
|
+
function getStyleDictionaryConfig(theme, sourcePath) {
|
|
43
|
+
return {
|
|
44
|
+
source: [sourcePath],
|
|
45
|
+
platforms: {
|
|
46
|
+
web: {
|
|
47
|
+
transforms: [
|
|
48
|
+
"attribute/cti",
|
|
49
|
+
"name/cti/pascal",
|
|
50
|
+
"size/px",
|
|
51
|
+
"color/hex",
|
|
52
|
+
figmaSizePx.name,
|
|
53
|
+
figmaSizeRem.name,
|
|
54
|
+
shadowCss.name,
|
|
55
|
+
lineHeightUnitless.name,
|
|
56
|
+
figmaTypography.name,
|
|
57
|
+
],
|
|
58
|
+
buildPath: `${outDir}/`,
|
|
59
|
+
files: [
|
|
60
|
+
{
|
|
61
|
+
destination: `${toCamelCase(theme)}Tokens.ts`,
|
|
62
|
+
format: typescriptEsModule.name,
|
|
63
|
+
options: {
|
|
64
|
+
fileHeader: () => [
|
|
65
|
+
"Generated by style-dictionary. Do not edit directly.",
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function buildTheme(theme, platform) {
|
|
75
|
+
console.log(`Processing: [${theme}] for ${platform}`);
|
|
76
|
+
const styleDictionaryInputPath = transformTokens(theme, platform);
|
|
77
|
+
if (platform === "json") {
|
|
78
|
+
console.log(`Retaining style-dictionary file ${styleDictionaryInputPath}`);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
console.log("Running style-dictionary");
|
|
82
|
+
const StyleDictionary = StyleDictionaryPackage.extend(getStyleDictionaryConfig(theme, styleDictionaryInputPath));
|
|
83
|
+
StyleDictionary.buildPlatform(platform);
|
|
84
|
+
console.log(`Deleting temporary style-dictionary file ${styleDictionaryInputPath} ✔︎`);
|
|
85
|
+
void fs.rm(styleDictionaryInputPath);
|
|
86
|
+
}
|
|
87
|
+
console.log(`\n`);
|
|
88
|
+
}
|
|
89
|
+
console.log("Build started...\n");
|
|
90
|
+
figmaThemes.map((theme) => {
|
|
91
|
+
buildTheme(theme, "json");
|
|
92
|
+
buildTheme(theme, "web");
|
|
93
|
+
});
|
|
94
|
+
childprocess.execSync(`npx prettier "${outDir}/*.{ts,scss}" --write`);
|