@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
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import StyleDictionary from "style-dictionary";
|
|
2
|
+
export const typescriptEsModule = {
|
|
3
|
+
name: "typescript/es-module",
|
|
4
|
+
formatter: ({ dictionary, file }) => {
|
|
5
|
+
const varName = file.destination.split(".ts")[0];
|
|
6
|
+
return (StyleDictionary.formatHelpers.fileHeader({
|
|
7
|
+
file,
|
|
8
|
+
commentStyle: "short",
|
|
9
|
+
}) + tokenTopNode(varName, dictionary.properties));
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
function isLeafNode(token) {
|
|
13
|
+
const tokenAsLeaf = token;
|
|
14
|
+
return Boolean(tokenAsLeaf.filePath &&
|
|
15
|
+
tokenAsLeaf.original &&
|
|
16
|
+
tokenAsLeaf.name &&
|
|
17
|
+
tokenAsLeaf.value);
|
|
18
|
+
}
|
|
19
|
+
function tokenTopNode(varName, properties) {
|
|
20
|
+
return `export const ${varName} = ${tokenTreeNode(properties)};`;
|
|
21
|
+
}
|
|
22
|
+
function tokenTreeNode(token) {
|
|
23
|
+
if (isLeafNode(token)) {
|
|
24
|
+
if (typeof token.value === "object") {
|
|
25
|
+
return JSON.stringify(token.value);
|
|
26
|
+
}
|
|
27
|
+
return `"${token.value}"`;
|
|
28
|
+
}
|
|
29
|
+
const obj = Object.entries(token)
|
|
30
|
+
.map(([key, val]) => {
|
|
31
|
+
return `"${key}": ${tokenTreeNode(val)},`;
|
|
32
|
+
})
|
|
33
|
+
.join("\n");
|
|
34
|
+
return `{\n${obj}\n}`;
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function toCamelCase(name: string, separator?: string): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function toCamelCase(name, separator = " ") {
|
|
2
|
+
return name
|
|
3
|
+
.split(separator)
|
|
4
|
+
.map((originalWord, index) => {
|
|
5
|
+
// map all-uppercase words to all-lowercase
|
|
6
|
+
const word = originalWord.toLocaleUpperCase() === originalWord
|
|
7
|
+
? originalWord.toLocaleLowerCase()
|
|
8
|
+
: originalWord;
|
|
9
|
+
return ((index === 0
|
|
10
|
+
? word.charAt(0).toLocaleLowerCase()
|
|
11
|
+
: word.charAt(0).toLocaleUpperCase()) + word.slice(1));
|
|
12
|
+
})
|
|
13
|
+
.join("");
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const isPxTokenType = (tokenType) => ["spacing", "borderWidth", "borderRadius"].includes(tokenType);
|
|
2
|
+
export const transformUnitlessToPx = (value) => `${value}px`;
|
|
3
|
+
export const figmaSizePx = {
|
|
4
|
+
name: "figma-size/px",
|
|
5
|
+
type: "value",
|
|
6
|
+
matcher: (token) => isPxTokenType(token.type),
|
|
7
|
+
transformer: (token) => {
|
|
8
|
+
return transformUnitlessToPx(token.value);
|
|
9
|
+
},
|
|
10
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const isRemTokenType = (tokenType) => ["fontSize", "fontSizes", "paragraphSpacing", "letterSpacing"].includes(tokenType);
|
|
2
|
+
export const transformUnitlessToRem = (value) => {
|
|
3
|
+
if (value === 0) {
|
|
4
|
+
return "0";
|
|
5
|
+
}
|
|
6
|
+
return `${value / 16}rem`;
|
|
7
|
+
};
|
|
8
|
+
export const figmaSizeRem = {
|
|
9
|
+
name: "figma-size/rem",
|
|
10
|
+
type: "value",
|
|
11
|
+
matcher: (token) => isRemTokenType(token.type),
|
|
12
|
+
transformer: (token) => {
|
|
13
|
+
const floatVal = token.value;
|
|
14
|
+
return transformUnitlessToRem(floatVal);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isRemTokenType, transformUnitlessToRem } from "./figmaSizeRem.js";
|
|
2
|
+
import { isLineHeightTokenType, transformToUnitlessLineHeight, } from "./lineHeightUnitless.js";
|
|
3
|
+
export const figmaTypography = {
|
|
4
|
+
name: "figma/typography",
|
|
5
|
+
type: "value",
|
|
6
|
+
matcher: (token) => token.type === "typography",
|
|
7
|
+
transformer: (token) => {
|
|
8
|
+
const obj = token.value;
|
|
9
|
+
return Object.fromEntries(Object.entries(obj).map(([key, val]) => {
|
|
10
|
+
if (isLineHeightTokenType(key)) {
|
|
11
|
+
return [key, transformToUnitlessLineHeight(val)];
|
|
12
|
+
}
|
|
13
|
+
if (isRemTokenType(key)) {
|
|
14
|
+
return [key, transformUnitlessToRem(val)];
|
|
15
|
+
}
|
|
16
|
+
return [key, val.toString()];
|
|
17
|
+
}));
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Named, Transform } from "style-dictionary";
|
|
2
|
+
export declare const isLineHeightTokenType: (tokenType: string) => tokenType is "lineHeight";
|
|
3
|
+
export declare function transformToUnitlessLineHeight(originalValue: string): string;
|
|
4
|
+
export declare const lineHeightUnitless: Named<Transform<unknown>>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const isLineHeightTokenType = (tokenType) => tokenType === "lineHeight";
|
|
2
|
+
export function transformToUnitlessLineHeight(originalValue) {
|
|
3
|
+
let newValue;
|
|
4
|
+
if (originalValue.endsWith("%")) {
|
|
5
|
+
newValue = parseFloat(originalValue.slice(0, -1)) / 100;
|
|
6
|
+
}
|
|
7
|
+
else if (originalValue.endsWith("em") && !originalValue.endsWith("rem")) {
|
|
8
|
+
newValue = parseFloat(originalValue.slice(0, -2));
|
|
9
|
+
}
|
|
10
|
+
return `${newValue ?? originalValue}`;
|
|
11
|
+
}
|
|
12
|
+
export const lineHeightUnitless = {
|
|
13
|
+
name: "line-height/unitless",
|
|
14
|
+
type: "value",
|
|
15
|
+
matcher: (token) => {
|
|
16
|
+
return (isLineHeightTokenType(token.type) ||
|
|
17
|
+
(token.attributes?.category === "typeface" &&
|
|
18
|
+
token.attributes.type === "line-height"));
|
|
19
|
+
},
|
|
20
|
+
transformer: (token) => {
|
|
21
|
+
const originalValue = token.value;
|
|
22
|
+
return transformToUnitlessLineHeight(originalValue);
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const shadowCss = {
|
|
2
|
+
// Adapted from https://github.com/six7/figma-tokens/issues/379#issuecomment-1246611910
|
|
3
|
+
// Changed to also work for dropShadow type
|
|
4
|
+
name: "shadow/css",
|
|
5
|
+
type: "value",
|
|
6
|
+
transitive: true,
|
|
7
|
+
matcher: (token) => token.type === "boxShadow",
|
|
8
|
+
transformer: (token) => {
|
|
9
|
+
// Allow both single and multi shadow tokens:
|
|
10
|
+
const shadows = Array.isArray(token.value)
|
|
11
|
+
? token.value
|
|
12
|
+
: [token.value];
|
|
13
|
+
const transformedShadows = shadows.map((shadow) => {
|
|
14
|
+
const { x, y, blur, spread, color, type } = shadow;
|
|
15
|
+
const inset = type === "innerShadow" ? "inset " : "";
|
|
16
|
+
return `${inset}${x}px ${y}px ${blur}px ${spread}px ${color}`;
|
|
17
|
+
});
|
|
18
|
+
return transformedShadows.join(", ");
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { tokens } from "./tokens.css.js";
|
|
2
|
+
type AllSemanticColors = keyof typeof tokens.color;
|
|
3
|
+
type PickAndRemovePrefix<Set, Prefix extends string> = Set extends `${Prefix}${infer X}` ? X : never;
|
|
4
|
+
type SupportedColors = PickAndRemovePrefix<AllSemanticColors, "on-">;
|
|
5
|
+
/** Easily set correct styles for background-color, color and border-color for a given color token
|
|
6
|
+
*
|
|
7
|
+
* Example:
|
|
8
|
+
* ```ts
|
|
9
|
+
* style([
|
|
10
|
+
* boxColors["primary-container"],
|
|
11
|
+
* { borderWidth: tokens.stroke.medium },
|
|
12
|
+
* ])
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare const boxColors: Record<SupportedColors, string>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { atoms } from "./atoms.css.js";
|
|
2
|
+
import { tokens } from "./tokens.css.js";
|
|
3
|
+
const supportedBoxColors = Object.keys(tokens.color)
|
|
4
|
+
.filter((x) => x.startsWith("on-"))
|
|
5
|
+
.map((x) => x.replace(/^on-/, ""));
|
|
6
|
+
const boxColorsInternal = (colorName) => atoms({
|
|
7
|
+
backgroundColor: colorName,
|
|
8
|
+
color: `on-${colorName}`,
|
|
9
|
+
borderColor: `on-${colorName}`,
|
|
10
|
+
});
|
|
11
|
+
/** Easily set correct styles for background-color, color and border-color for a given color token
|
|
12
|
+
*
|
|
13
|
+
* Example:
|
|
14
|
+
* ```ts
|
|
15
|
+
* style([
|
|
16
|
+
* boxColors["primary-container"],
|
|
17
|
+
* { borderWidth: tokens.stroke.medium },
|
|
18
|
+
* ])
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export const boxColors = Object.fromEntries(supportedBoxColors.map((colorName) => {
|
|
22
|
+
return [colorName, boxColorsInternal(colorName)];
|
|
23
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const audi: string;
|