@kaizen/design-tokens 10.3.7 → 10.3.8

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaizen/design-tokens",
3
3
  "description": "Tokens used in the Kaizen Design System",
4
- "version": "10.3.7",
4
+ "version": "10.3.8",
5
5
  "homepage": "https://github.com/cultureamp/kaizen-design-system/tree/main/packages/design-tokens",
6
6
  "repository": {
7
7
  "type": "git",
@@ -14,10 +14,7 @@
14
14
  "tokens",
15
15
  "sass",
16
16
  "less",
17
- "src",
18
- "dist",
19
- "!**/*.spec.*",
20
- "!docs"
17
+ "dist"
21
18
  ],
22
19
  "main": "dist/index.js",
23
20
  "private": false,
@@ -25,12 +22,12 @@
25
22
  "sideEffects": false,
26
23
  "scripts": {
27
24
  "test": "cd ../../ && yarn jest ./packages/design-tokens",
28
- "build": "yarn clean && yarn prepublish",
25
+ "build": "yarn prepublish",
29
26
  "build:json": "yarn ts-node --files ./bin/buildCssVarTokens.ts",
30
27
  "build:ts": "tsc --project tsconfig.dist.json",
31
28
  "build:less": "json-to-flat-sass './tokens/*.json' 'less' --extension 'less' --caseType 'kebab' && prettier less/* --write",
32
29
  "build:sass": "json-to-flat-sass './tokens/*.json' 'sass' --extension 'scss' --caseType 'kebab' && prettier sass/* --write",
33
- "clean": "rimraf 'dist'",
30
+ "clean": "rimraf dist",
34
31
  "prepublish": "yarn build:json && yarn build:less && yarn build:sass && yarn build:ts"
35
32
  },
36
33
  "devDependencies": {
@@ -1,78 +0,0 @@
1
- import { makeCssVariableDefinitionsMap } from "./lib/makeCssVariableDefinitionsMap"
2
- import { Theme as BaseTheme } from "./types"
3
- /**
4
- * Use this class to set and apply themes, and to access or subscribe to the currently active one.
5
- * This class fulfills the idea of theming and runtime theme switching by relying on CSS variables,
6
- * and the ability to update them in JavaScript - a framework agnostic method.
7
- *
8
- * It works by converting a Theme interface to a flattened map of CSS variable keys and values, then calling `document.documentElement.style.setProperty(key, value)`.
9
- */
10
- export class ThemeManager<Theme extends BaseTheme = BaseTheme> {
11
- private themeChangeListeners = [] as Array<(theme: Theme) => void>
12
- private theme: Theme
13
- private rootElement: HTMLElement | null = null
14
- private rootElementId: string
15
-
16
- constructor(
17
- theme: Theme,
18
- rootElementId: string = "",
19
- /* This allows you to stop the class from applying the theme automatically during construction. Defaults to true */
20
- apply: boolean = true
21
- ) {
22
- /*
23
- For some reason, storybook likes this way of defining class properties better.
24
- If you use `constructor( private theme: Theme, ...)` - theme becomes undefined within the class's methods.
25
- */
26
- this.theme = theme
27
- this.rootElementId = rootElementId
28
- if (apply) this.applyCurrentTheme()
29
- }
30
-
31
- public getRootElement = (): HTMLElement | null => this.rootElement
32
- public getRootElementId = (): string => this.rootElementId
33
- public getCurrentTheme = (): Theme => this.theme
34
-
35
- public setRootElement = (element: HTMLElement): void => {
36
- this.rootElement = element
37
- }
38
- public setRootElementId = (rootElementId: string): string =>
39
- (this.rootElementId = rootElementId)
40
- public setAndApplyTheme = (theme: Theme, force?: boolean): void => {
41
- if (!force) {
42
- if (this.theme === theme) return
43
- }
44
- this.theme = theme
45
- this.applyCurrentTheme()
46
- this.notifyThemeChangeListeners(theme)
47
- }
48
-
49
- public addThemeChangeListener = (listener: (theme: Theme) => void): void => {
50
- this.themeChangeListeners.push(listener)
51
- }
52
- public removeThemeChangeListener = (
53
- listener: (theme: Theme) => void
54
- ): void => {
55
- this.themeChangeListeners = this.themeChangeListeners.filter(
56
- l => l !== listener
57
- )
58
- }
59
- public applyCurrentTheme = (): void => {
60
- if (typeof window !== "undefined") {
61
- this.setRootElement(
62
- document.getElementById(this.rootElementId) ?? document.documentElement
63
- )
64
- const cssVariableDefinitions = makeCssVariableDefinitionsMap(this.theme)
65
- Object.entries(cssVariableDefinitions).forEach(([key, value]) => {
66
- this.rootElement?.style.setProperty(key, value)
67
- })
68
- }
69
- }
70
-
71
- private notifyThemeChangeListeners = (theme: Theme): void => {
72
- this.themeChangeListeners.forEach(listener => listener(theme))
73
- }
74
- }
75
-
76
- // I would like to expose this, but instantiating ThemeManager in some situations or runtimes (such as nodejs) cause exceptions.
77
- // For now it is not exposed, but we might come back to it, as it makes sense to have a singleton ThemeManager in almost all cases
78
- /* export const defaultThemeManager = new ThemeManager(defaultTheme) */
package/src/index.ts DELETED
@@ -1,9 +0,0 @@
1
- // These are exposed at the top level because it seems like they are the most useful and relevent to usage of design tokens.
2
- export * from "./themes"
3
- export * from "./types"
4
- export * from "./ThemeManager"
5
- export * from "./react"
6
-
7
- export { makeCssVariableDefinitionsMap } from "./lib/makeCssVariableDefinitionsMap"
8
- export { makeCSSVariableTheme } from "./lib/makeCssVariableTheme"
9
- export { mapLeafsOfObject } from "./lib/mapLeafsOfObject"
@@ -1,17 +0,0 @@
1
- export const themeForTesting = {
2
- border: {
3
- dashed: {
4
- borderWidth: "2px",
5
- red: "red",
6
- },
7
- },
8
- color: {
9
- gray: { 100: "#eee", 200: "#ccc" },
10
- purple: { 100: "#eee", 200: "#ccc" },
11
- blue: { 100: "#eee", 200: "#ccc" },
12
- red: { 100: "#eee", 200: "#ccc" },
13
- yellow: { 100: "#eee", 200: "#ccc" },
14
- orange: { 100: "#eee", 200: "#ccc" },
15
- green: { 100: "#eee", 200: "#ccc" },
16
- },
17
- } as const
@@ -1,56 +0,0 @@
1
- import colorString from "color-string"
2
- import { objectPathToCssVarIdentifier } from "./cssVariables"
3
-
4
- /**
5
- * Use this to generate an object containing `${key}: value`, `${key}-rgb: r, g, b`, and/or `${key}-id: --color-blah-XXX`.
6
- * This is for adding extra neighbouring properties to a theme.
7
- * For example:
8
- * Input:
9
- * path: [color, purple, 100]
10
- * key: 100
11
- * value: #f0f1f4
12
- * printValue: (path, v) => `var(--some-key, ${v})`
13
- * options: {augmentWithId: true}
14
- *
15
- * Output: {
16
- * "100": "var(--some-key, #f0f1f4)",
17
- * "100-rgb": "var(--some-key, 240, 241, 244)",
18
- * "100-id": "--color-purple-100"
19
- * "100-rgb-id": "--color-purple-100-rgb"
20
- * }
21
- */
22
- export const addExtraThemeEntries = (
23
- path: string[],
24
- key: string,
25
- value: unknown,
26
- printValue: <I>(path: string[], value: I) => string,
27
- {
28
- augmentWithId,
29
- }: {
30
- /** Setting this to true will add `${key}-id` and ${key}-rgb-id` */
31
- augmentWithId: boolean
32
- }
33
- ): Record<string, string> => {
34
- const colorRgb = typeof value === "string" ? colorString.get.rgb(value) : null
35
- const result = {
36
- [key]: printValue(path, value),
37
- }
38
-
39
- // Add the -rgb key containing the RGB triple of the color (if it is a color)
40
- if (colorRgb) {
41
- // If the value is a color, always convert to lowercase
42
- result[key] = printValue(path, value).toLowerCase()
43
-
44
- const rgbPath = [...path, "rgb"]
45
- const rgbTriple = printValue(rgbPath, colorRgb.slice(0, 3).join(", "))
46
- result[`${key}-rgb`] = rgbTriple
47
- if (augmentWithId) {
48
- result[`${key}-rgb-id`] = objectPathToCssVarIdentifier(rgbPath)
49
- }
50
- }
51
- if (augmentWithId) {
52
- result[`${key}-id`] = objectPathToCssVarIdentifier(path)
53
- }
54
-
55
- return result
56
- }
@@ -1,29 +0,0 @@
1
- import kebab from "lodash.kebabcase"
2
-
3
- /**
4
- * Given an object path (an array of strings) and a value, return a CSS var() function that represents it.
5
- *
6
- * Example:
7
- * Input:
8
- * path: [color, wisteria, 100]
9
- * value: #f0f1f4
10
- *
11
- * Output:
12
- * "var(--color-wisteria-100, #f0f1f4)"
13
- *
14
- */
15
- export const objectPathToCssVarFunction = (
16
- path: string[],
17
- value: unknown
18
- ): string => `var(${objectPathToCssVarIdentifier(path)}, ${value})`
19
-
20
- /**
21
- * Given an object path (an array of strings), return a CSS variable identifier.
22
- *
23
- * Example:
24
- * Input: [color, wisteria, 100]
25
- *
26
- * Output: "--color-wisteria-100"
27
- */
28
- export const objectPathToCssVarIdentifier = (path: string[]): string =>
29
- `--${path.map(kebab).join("-")}`
@@ -1,55 +0,0 @@
1
- import { addExtraThemeEntries } from "./addExtraThemeEntries"
2
- import { objectPathToCssVarIdentifier } from "./cssVariables"
3
- import { mapLeafsOfObject } from "./mapLeafsOfObject"
4
-
5
- /**
6
-
7
- * Make a map of CSS variables -> values in a consistent way.
8
- * Use this to, for example, create a CSS file that declares each theme variable on the `:root` pseudo element.
9
- * Or for example when you're defining CSS variables using `rootElement.style.setProperty` within ThemeManager.
10
- *
11
- * It is paramount that this function defines every variable that {@link makeCssVariableTheme} expects to be defined.
12
- * Otherwise, it's possible that a CSS variable token (something that looks like var(--color-purple-100-rgb)) won't have a matching defined
13
- * CSS variable like `--color-purple-100-rgb: 123, 123, 123;`
14
- *
15
- *
16
- * For example:
17
- * Input:
18
- * ```
19
- * {
20
- * color: {
21
- * whatever: {
22
- * 100: "#ff0022"
23
- * }
24
- * }
25
- * }
26
- * ```
27
- * Output:
28
- * ```
29
- * {
30
- * "--color-whatever-100": "#ff0022"
31
- * }
32
- */
33
- export function makeCssVariableDefinitionsMap(
34
- theme: Record<string | number, unknown>
35
- ): Record<string, string> {
36
- let accumulatedCssVariables = {} as Record<string, string>
37
-
38
- // Shamelessly using a map function like a forEach
39
- mapLeafsOfObject(theme, (path, value) => {
40
- // Key will be `--color-blah`
41
- const key = objectPathToCssVarIdentifier(path)
42
- const nextCssVariables = addExtraThemeEntries(
43
- path,
44
- key,
45
- value,
46
- (_, v) => `${v}`,
47
- { augmentWithId: false }
48
- )
49
- accumulatedCssVariables = {
50
- ...accumulatedCssVariables,
51
- ...nextCssVariables,
52
- }
53
- })
54
- return accumulatedCssVariables
55
- }
@@ -1,70 +0,0 @@
1
- import { DeepMapObjectLeafs } from "../types"
2
- import { addExtraThemeEntries } from "./addExtraThemeEntries"
3
- import { objectPathToCssVarFunction } from "./cssVariables"
4
- import { mapLeafsOfObject } from "./mapLeafsOfObject"
5
-
6
- /**
7
- * This function could use a new name during a breaking change
8
- *
9
- * Given a Theme (which is the source of truth and doesn't contain any computed properties), add extra necessary properties to the tree such as `-rgb` suffixed keys with R, G, B triple values, and
10
- * convert the leaf values of a theme to a value like `var(--parent1key-parent2key-leafkey)` - a CSS variable with an identifier that represents it's hierarchy.
11
- *
12
- * Example:
13
- * ```
14
- * {
15
- * color: {
16
- * purple: {
17
- * 100: "#f0f1f4"
18
- * }
19
- * }
20
- * }
21
- * ```
22
- * Transforms into:
23
- * ```
24
- * {
25
- * color: {
26
- * purple: {
27
- * 100: "var(--color-purple-100, "#f0f1f4")",
28
- * "100-rgb": "var(--color-purple-100-rgb, 240, 241, 244)",
29
- * "100-id": "--color-purple-100",
30
- * "100-rgb-id": "--color-purple-100-rgb"
31
- * }
32
- * }
33
- * }
34
- * ```
35
- *
36
- * See {@link addExtraThemeEntries} for how these extra entries are added.
37
- */
38
- export function makeCSSVariableTheme<
39
- ThemeType extends Record<string | number, unknown>
40
- >(
41
- theme: ThemeType,
42
- printValue = objectPathToCssVarFunction
43
- ): DeepMapObjectLeafs<ThemeType, string> {
44
- const augmentedTheme: Record<string, unknown> = {}
45
-
46
- const mapper = (leafPath: string[], value: unknown): void => {
47
- const leafKey = leafPath[leafPath.length - 1]
48
- const pathWithoutLast = leafPath.slice(0, leafPath.length - 1)
49
- const leafObject = pathWithoutLast.reduce(
50
- (child, segment) =>
51
- (child[segment] || (child[segment] = {})) as Record<string, unknown>,
52
- augmentedTheme as Record<string, unknown>
53
- )
54
- if (!leafKey) {
55
- throw new Error("leafKey is undefined")
56
- }
57
- const cssVariablesOfToken = addExtraThemeEntries(
58
- leafPath,
59
- leafKey,
60
- value,
61
- printValue,
62
- { augmentWithId: true }
63
- )
64
- Object.assign(leafObject, cssVariablesOfToken)
65
- }
66
-
67
- mapLeafsOfObject(theme, mapper)
68
-
69
- return augmentedTheme as DeepMapObjectLeafs<ThemeType, string>
70
- }
@@ -1,59 +0,0 @@
1
- import { DeepMapObjectLeafs } from "../types"
2
-
3
- /**
4
- * This allows you to map the leaf nodes of an object, and you're provided the path to that leaf as well as the value as parameters to your mapper function.
5
- * This function was build to support mapping theme values to their respective CSS variable identifiers.
6
- * For example:
7
- * ```ts
8
- * mapLeafsOfObject({
9
- * one: {
10
- * two: 4
11
- * }
12
- * }, (path, value) => value + 7)
13
- * ```
14
- * Results in:
15
- * ```
16
- * {
17
- * one: {
18
- * two: 11
19
- * }
20
- * }
21
- * ```
22
- */
23
- export function mapLeafsOfObject<
24
- Obj extends Record<string | number, unknown>,
25
- Value
26
- >(
27
- object: Obj,
28
- mapper: (pathToLeaf: string[], value: unknown) => Value
29
- ): DeepMapObjectLeafs<Obj, Value> {
30
- const recurser = <O extends Record<string | number, unknown>>(
31
- currentPath: string[],
32
- obj: O
33
- ): DeepMapObjectLeafs<O, Value> => {
34
- const handleEntry = (
35
- key: string,
36
- value: unknown
37
- ):
38
- | {
39
- [x: string]: unknown
40
- [x: number]: unknown
41
- }
42
- | Value => {
43
- const pathToKey = [...currentPath, key]
44
- if (typeof value === "object" && value !== null && value !== undefined) {
45
- return recurser(pathToKey, value as Record<string | number, unknown>)
46
- }
47
- return mapper(pathToKey, value)
48
- }
49
-
50
- return Object.entries(obj).reduce(
51
- (acc, [nextKey, nextValue]) => ({
52
- ...acc,
53
- [nextKey]: handleEntry(nextKey, nextValue),
54
- }),
55
- {} as DeepMapObjectLeafs<O, Value>
56
- )
57
- }
58
- return recurser([], object)
59
- }
@@ -1,3 +0,0 @@
1
- export const zenColorNamePattern =
2
- /ash|stone|slate|iron|wisteria|cluny|peach|yuzu|coral|seedling/
3
- export const heartColorNamePattern = /purple|blue|orange|yellow|red|green|gray/
@@ -1,83 +0,0 @@
1
- import React, { useState } from "react"
2
- import { ThemeManager, defaultTheme, Theme } from ".."
3
-
4
- export const ThemeContext = React.createContext<Theme>(defaultTheme)
5
-
6
- /**
7
- * Wrap your application in this provider using a ThemeManager, to synchronise it with a react context.
8
- * This allows child react elements to more easily use theme variables, using the {@link useTheme} hook.
9
- */
10
- /**
11
- * @deprecated ThemeProvider is deprecated. Please use KaizenProvider from "@kaizen/components" instead.
12
- */
13
- export const ThemeProvider = ({
14
- themeManager,
15
- ...props
16
- }: {
17
- themeManager?: ThemeManager
18
- children: React.ReactNode
19
- }): JSX.Element => {
20
- const [themeManagerInstance] = useState(
21
- () => themeManager || new ThemeManager(defaultTheme)
22
- )
23
-
24
- const [theme, setTheme] = React.useState<Theme>(
25
- themeManagerInstance.getCurrentTheme()
26
- )
27
- React.useEffect(() => {
28
- let cancelled = false
29
- const listener = (newTheme: Theme): void => {
30
- if (!cancelled) setTheme(newTheme)
31
- }
32
- themeManagerInstance.addThemeChangeListener(listener)
33
- return () => {
34
- cancelled = true
35
- themeManagerInstance.removeThemeChangeListener(listener)
36
- }
37
- }, [])
38
-
39
- return (
40
- <>
41
- <ThemeContext.Provider value={theme}>
42
- {props.children}
43
- </ThemeContext.Provider>
44
- <link
45
- rel="preload"
46
- href="https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-bold.woff2"
47
- as="font"
48
- type="font/woff2"
49
- crossOrigin="anonymous"
50
- />
51
- <link
52
- rel="preload"
53
- href="https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-demi-bold.woff2"
54
- as="font"
55
- type="font/woff2"
56
- crossOrigin="anonymous"
57
- />
58
- <link
59
- rel="preload"
60
- href="https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-medium.woff2"
61
- as="font"
62
- type="font/woff2"
63
- crossOrigin="anonymous"
64
- />
65
- <link
66
- rel="preload"
67
- href="https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-regular.woff2"
68
- as="font"
69
- type="font/woff2"
70
- crossOrigin="anonymous"
71
- />
72
- <link
73
- rel="preload"
74
- href="https://d1e7r7b0lb8p4d.cloudfront.net/fonts/tiempos/tiempos-headline-bold.woff2"
75
- as="font"
76
- type="font/woff2"
77
- crossOrigin="anonymous"
78
- />
79
- </>
80
- )
81
- }
82
-
83
- export const useTheme = (): Theme => React.useContext(ThemeContext)
@@ -1 +0,0 @@
1
- export * from "./ThemeProvider"
@@ -1,312 +0,0 @@
1
- import { Theme } from "../types"
2
-
3
- export const heartTheme: Theme = {
4
- themeKey: "heart",
5
- animation: {
6
- easingFunction: {
7
- easeInOut: "cubic-bezier(0.455, 0.03, 0.515, 0.955)",
8
- easeIn: "cubic-bezier(0.55, 0.085, 0.68, 0.53)",
9
- easeOut: "cubic-bezier(0.25, 0.46, 0.45, 0.94)",
10
- linear: "linear",
11
- bounceIn: "cubic-bezier(0.485, 0.155, 0.24, 1.245)",
12
- bounceOut: "cubic-bezier(0.485, 0.155, 0.515, 0.845)",
13
- bounceInOut: "cubic-bezier(0.76, -0.245, 0.24, 1.245)",
14
- },
15
- duration: {
16
- instant: "0ms",
17
- immediate: "100ms",
18
- rapid: "200ms",
19
- fast: "300ms",
20
- slow: "400ms",
21
- deliberate: "700ms",
22
- },
23
- },
24
- border: {
25
- solid: {
26
- borderWidth: "2px",
27
- borderRadius: "7px",
28
- borderStyle: "solid",
29
- borderColor: "#e1e2ea",
30
- },
31
- dashed: {
32
- borderWidth: "2px",
33
- borderRadius: "7px",
34
- borderStyle: "dashed",
35
- },
36
- borderless: {
37
- borderWidth: "2px",
38
- borderRadius: "7px",
39
- borderStyle: "solid",
40
- borderColor: "transparent",
41
- },
42
- focusRing: {
43
- borderWidth: "2px",
44
- borderRadius: "10px",
45
- borderStyle: "solid",
46
- },
47
- },
48
- color: {
49
- purple: {
50
- 100: "#f4edf8",
51
- 200: "#dfc9ea",
52
- 300: "#c9a5dd",
53
- 400: "#ae67b1",
54
- 500: "#844587",
55
- 600: "#5f3361",
56
- 700: "#4a234d",
57
- 800: "#2f2438",
58
- },
59
- blue: {
60
- 100: "#e6f6ff",
61
- 200: "#bde2f5",
62
- 300: "#73c0e8",
63
- 400: "#008bd6",
64
- 500: "#0168b3",
65
- 600: "#004970",
66
- 700: "#003157",
67
- },
68
- green: {
69
- 100: "#e8f8f4",
70
- 200: "#c4ede2",
71
- 300: "#8fdbc7",
72
- 400: "#5dcbad",
73
- 500: "#44a289",
74
- 600: "#2c7d67",
75
- 700: "#22594a",
76
- },
77
- yellow: {
78
- 100: "#fff9e4",
79
- 200: "#ffeeb3",
80
- 300: "#ffe36e",
81
- 400: "#ffca4d",
82
- 500: "#ffb600",
83
- 600: "#c68600",
84
- 700: "#876400",
85
- },
86
- red: {
87
- 100: "#fdeaee",
88
- 200: "#f9c2cb",
89
- 300: "#f597a8",
90
- 400: "#e0707d",
91
- 500: "#c93b55",
92
- 600: "#a82433",
93
- 700: "#6c1e20",
94
- },
95
- orange: {
96
- 100: "#fff0e8",
97
- 200: "#ffd1b9",
98
- 300: "#ffb08a",
99
- 400: "#ff9461",
100
- 500: "#e96c2f",
101
- 600: "#b74302",
102
- 700: "#903c00",
103
- },
104
- gray: {
105
- 100: "#f9f9f9",
106
- 200: "#f4f4f5",
107
- 300: "#eaeaec",
108
- 400: "#cdcdd0",
109
- 500: "#8c8c97",
110
- 600: "#524e56",
111
- },
112
- white: "#ffffff",
113
- },
114
- dataViz: {
115
- favorable: "#7dd5bd",
116
- unfavorable: "#e68d97",
117
- },
118
- layout: {
119
- contentMaxWidth: "1392px",
120
- contentMaxWidthWithSidebar: "1080px",
121
- contentSideMargin: "72px",
122
- mobileActionsDrawerHeight: "60px",
123
- navigationBarHeight: "72px",
124
- breakpoints: {
125
- medium: "768px",
126
- large: "1080px",
127
- },
128
- },
129
- shadow: {
130
- small: {
131
- boxShadow:
132
- "0px 3px 16px rgba(0, 0, 0, 0.06), 0px 1px 3px rgba(0, 0, 0, 0.1)",
133
- },
134
- large: {
135
- boxShadow:
136
- "0px 8px 40px rgba(0, 0, 0, 0.08), 0px 3px 9px rgba(0, 0, 0, 0.1)",
137
- },
138
- },
139
- spacing: {
140
- xs: "0.375rem",
141
- sm: "0.75rem",
142
- md: "1.5rem",
143
- lg: "2.25rem",
144
- xl: "3rem",
145
- xxl: "3.75rem",
146
- xxxl: "4.5rem",
147
- xxxxl: "5.25rem",
148
- xxxxxl: "6rem",
149
- 0: "0",
150
- 1: ".0625rem",
151
- 2: ".125rem",
152
- 4: ".25rem",
153
- 6: ".375rem",
154
- 8: ".5rem",
155
- 12: ".75rem",
156
- 16: "1rem",
157
- 24: "1.5rem",
158
- 32: "2rem",
159
- 40: "2.5rem",
160
- 48: "3rem",
161
- 56: "3.5rem",
162
- 64: "4rem",
163
- 72: "4.5rem",
164
- 80: "5rem",
165
- 96: "6rem",
166
- 112: "7rem",
167
- 128: "8rem",
168
- 160: "10rem",
169
- 200: "12.5rem",
170
- 240: "15rem",
171
- 280: "17.5rem",
172
- 320: "20rem",
173
- },
174
- typography: {
175
- dataLarge: {
176
- fontFamily: '"Inter", "Noto Sans", Helvetica, Arial, sans-serif',
177
- fontWeight: 700,
178
- fontSize: "5.25rem",
179
- lineHeight: "5.25rem",
180
- letterSpacing: "normal",
181
- },
182
- dataLargeUnits: {
183
- fontFamily: '"Inter", "Noto Sans", Helvetica, Arial, sans-serif',
184
- fontWeight: 700,
185
- fontSize: "2.625rem",
186
- lineHeight: "5.25rem",
187
- letterSpacing: "normal",
188
- },
189
- dataMedium: {
190
- fontFamily: '"Inter", "Noto Sans", Helvetica, Arial, sans-serif',
191
- fontWeight: 700,
192
- fontSize: "3rem",
193
- lineHeight: "5rem",
194
- letterSpacing: "normal",
195
- },
196
- dataMediumUnits: {
197
- fontFamily: '"Inter", "Noto Sans", Helvetica, Arial, sans-serif',
198
- fontWeight: 700,
199
- fontSize: "1.5rem",
200
- lineHeight: "5rem",
201
- letterSpacing: "normal",
202
- },
203
- dataSmall: {
204
- fontFamily: '"Inter", "Noto Sans", Helvetica, Arial, sans-serif',
205
- fontWeight: 700,
206
- fontSize: "1.5rem",
207
- lineHeight: "1.5rem",
208
- letterSpacing: "normal",
209
- },
210
- dataSmallUnits: {
211
- fontFamily: '"Inter", "Noto Sans", Helvetica, Arial, sans-serif',
212
- fontWeight: 700,
213
- fontSize: "1.125rem",
214
- lineHeight: "1.5rem",
215
- letterSpacing: "normal",
216
- },
217
- display0: {
218
- fontFamily: '"Tiempos Headline", Georgia, serif',
219
- fontWeight: 800,
220
- fontSize: "4.5rem",
221
- lineHeight: "5.25rem",
222
- letterSpacing: "0em",
223
- },
224
- heading1: {
225
- fontFamily: '"Inter", "Noto Sans", Helvetica, Arial, sans-serif',
226
- fontWeight: 700,
227
- fontSize: "2.125rem",
228
- lineHeight: "2.625rem",
229
- letterSpacing: "normal",
230
- },
231
- heading2: {
232
- fontFamily: '"Inter", "Noto Sans", Helvetica, Arial, sans-serif',
233
- fontWeight: 700,
234
- fontSize: "1.75rem",
235
- lineHeight: "2.25rem",
236
- letterSpacing: "normal",
237
- },
238
- heading3: {
239
- fontFamily: '"Inter", "Noto Sans", Helvetica, Arial, sans-serif',
240
- fontWeight: 700,
241
- fontSize: "1.375rem",
242
- lineHeight: "1.875rem",
243
- letterSpacing: "normal",
244
- },
245
- heading4: {
246
- fontFamily: '"Inter", "Noto Sans", Helvetica, Arial, sans-serif',
247
- fontWeight: 600,
248
- fontSize: "1.125rem",
249
- lineHeight: "1.5rem",
250
- letterSpacing: "normal",
251
- },
252
- heading5: {
253
- fontFamily: '"Inter", "Noto Sans", Helvetica, Arial, sans-serif',
254
- fontWeight: 600,
255
- fontSize: "1rem",
256
- lineHeight: "1.5rem",
257
- letterSpacing: "normal",
258
- },
259
- heading6: {
260
- fontFamily: '"Inter", "Noto Sans", Helvetica, Arial, sans-serif',
261
- fontWeight: 700,
262
- fontSize: "0.875rem",
263
- lineHeight: "1.5rem",
264
- letterSpacing: "normal",
265
- },
266
- paragraphIntroLede: {
267
- fontFamily: '"Inter", "Noto Sans", Helvetica, Arial, sans-serif',
268
- fontWeight: 400,
269
- fontSize: "1.25rem",
270
- lineHeight: "1.875rem",
271
- letterSpacing: "0",
272
- },
273
- paragraphBody: {
274
- fontFamily: '"Inter", "Noto Sans", Helvetica, Arial, sans-serif',
275
- fontWeight: 400,
276
- fontSize: "1rem",
277
- lineHeight: "1.5rem",
278
- letterSpacing: "normal",
279
- },
280
- paragraphSmall: {
281
- fontFamily: '"Inter", "Noto Sans", Helvetica, Arial, sans-serif',
282
- fontWeight: 400,
283
- fontSize: "0.875rem",
284
- lineHeight: "1.125rem",
285
- letterSpacing: "normal",
286
- },
287
- paragraphExtraSmall: {
288
- fontFamily: '"Inter", "Noto Sans", Helvetica, Arial, sans-serif',
289
- fontWeight: 400,
290
- fontSize: "0.75rem",
291
- lineHeight: "1.125rem",
292
- letterSpacing: "normal",
293
- },
294
- paragraphBold: {
295
- fontWeight: 600,
296
- },
297
- buttonPrimary: {
298
- fontFamily: '"Inter", "Noto Sans", Helvetica, Arial, sans-serif',
299
- fontWeight: 700,
300
- fontSize: "1.125rem",
301
- lineHeight: "1.5rem",
302
- letterSpacing: "normal",
303
- },
304
- buttonSecondary: {
305
- fontFamily: '"Inter", "Noto Sans", Helvetica, Arial, sans-serif',
306
- fontWeight: 500,
307
- fontSize: "1rem",
308
- lineHeight: "1.5rem",
309
- letterSpacing: "normal",
310
- },
311
- },
312
- }
@@ -1,3 +0,0 @@
1
- import { heartTheme } from "./heart"
2
- export { heartTheme } from "./heart"
3
- export const defaultTheme = heartTheme
package/src/types.ts DELETED
@@ -1,250 +0,0 @@
1
- import type { CSSProperties as ReactCSSProperties } from "react"
2
-
3
- /**
4
- * Use a custom type for CSS properties becauase we should eventually write a more strongly typed version using template literal types.
5
- * This could definitely be contributed back to the community too. An example starting point here https://github.com/ghoullier/awesome-template-literal-types#css-parser
6
- * For example:
7
- * ```ts
8
- * type Font = {
9
- * fontSize: `${number}rem`,
10
- *
11
- * }
12
- * type HexDigit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F ;
13
- * type Color = `rgba(${number}, ${number}, ${number}, ${number}) | #${HexDigit}${HexDigit}${HexDigit}` // You get the point
14
- *
15
- * ```
16
- * */
17
- type KaizenCSSProperties = ReactCSSProperties
18
-
19
- type Hex = string
20
- // Once TypeScript is upgraded in the repo, you can use Lowercase<>
21
- // type Hex = Lowercase<string>
22
-
23
- export type TypographyFont = {
24
- fontFamily: KaizenCSSProperties["fontFamily"]
25
- fontWeight: KaizenCSSProperties["fontWeight"]
26
- fontSize: KaizenCSSProperties["fontSize"]
27
- lineHeight: KaizenCSSProperties["lineHeight"]
28
- letterSpacing: KaizenCSSProperties["letterSpacing"]
29
- }
30
-
31
- export type ThemeKey = "heart" | "custom"
32
-
33
- export type Theme = {
34
- themeKey: ThemeKey
35
- border: {
36
- solid: {
37
- borderWidth: KaizenCSSProperties["borderWidth"]
38
- borderRadius: KaizenCSSProperties["borderRadius"]
39
- borderStyle: KaizenCSSProperties["borderStyle"]
40
- borderColor: KaizenCSSProperties["borderColor"]
41
- }
42
- dashed: {
43
- borderWidth: KaizenCSSProperties["borderWidth"]
44
- borderRadius: KaizenCSSProperties["borderRadius"]
45
- borderStyle: KaizenCSSProperties["borderStyle"]
46
- }
47
- borderless: {
48
- borderWidth: KaizenCSSProperties["borderWidth"]
49
- borderRadius: KaizenCSSProperties["borderRadius"]
50
- borderStyle: KaizenCSSProperties["borderStyle"]
51
- borderColor: KaizenCSSProperties["borderColor"]
52
- }
53
- focusRing: {
54
- borderWidth: KaizenCSSProperties["borderWidth"]
55
- borderRadius: KaizenCSSProperties["borderRadius"]
56
- borderStyle: KaizenCSSProperties["borderStyle"]
57
- }
58
- }
59
- animation: {
60
- easingFunction: {
61
- easeInOut: string
62
- easeIn: string
63
- easeOut: string
64
- linear: string
65
- bounceIn: string
66
- bounceOut: string
67
- bounceInOut: string
68
- }
69
- duration: {
70
- instant: string
71
- immediate: string
72
- rapid: string
73
- fast: string
74
- slow: string
75
- deliberate: string
76
- }
77
- }
78
- color: {
79
- purple: {
80
- "100": Hex
81
- "200": Hex
82
- "300": Hex
83
- "400": Hex
84
- "500": Hex
85
- "600": Hex
86
- "700": Hex
87
- "800": Hex
88
- }
89
- blue: {
90
- "100": Hex
91
- "200": Hex
92
- "300": Hex
93
- "400": Hex
94
- "500": Hex
95
- "600": Hex
96
- "700": Hex
97
- }
98
- green: {
99
- "100": Hex
100
- "200": Hex
101
- "300": Hex
102
- "400": Hex
103
- "500": Hex
104
- "600": Hex
105
- "700": Hex
106
- }
107
- yellow: {
108
- "100": Hex
109
- "200": Hex
110
- "300": Hex
111
- "400": Hex
112
- "500": Hex
113
- "600": Hex
114
- "700": Hex
115
- }
116
- red: {
117
- "100": Hex
118
- "200": Hex
119
- "300": Hex
120
- "400": Hex
121
- "500": Hex
122
- "600": Hex
123
- "700": Hex
124
- }
125
- orange: {
126
- "100": Hex
127
- "200": Hex
128
- "300": Hex
129
- "400": Hex
130
- "500": Hex
131
- "600": Hex
132
- "700": Hex
133
- }
134
- gray: {
135
- "100": Hex
136
- "200": Hex
137
- "300": Hex
138
- "400": Hex
139
- "500": Hex
140
- "600": Hex
141
- }
142
- white: Hex
143
- }
144
- dataViz: {
145
- favorable: Hex
146
- unfavorable: Hex
147
- }
148
- layout: {
149
- contentMaxWidth: string
150
- contentMaxWidthWithSidebar: string
151
- contentSideMargin: string
152
- mobileActionsDrawerHeight: string
153
- navigationBarHeight: string
154
- breakpoints: {
155
- medium: string
156
- large: string
157
- }
158
- }
159
- shadow: {
160
- small: {
161
- boxShadow: string
162
- }
163
- large: {
164
- boxShadow: string
165
- }
166
- }
167
- spacing: {
168
- xs: string
169
- sm: string
170
- md: string
171
- lg: string
172
- xl: string
173
- xxl: string
174
- xxxl: string
175
- xxxxl: string
176
- xxxxxl: string
177
- 0: string
178
- 1: string
179
- 2: string
180
- 4: string
181
- 6: string
182
- 8: string
183
- 12: string
184
- 16: string
185
- 24: string
186
- 32: string
187
- 40: string
188
- 48: string
189
- 56: string
190
- 64: string
191
- 72: string
192
- 80: string
193
- 96: string
194
- 112: string
195
- 128: string
196
- 160: string
197
- 200: string
198
- 240: string
199
- 280: string
200
- 320: string
201
- }
202
- typography: {
203
- dataLarge: TypographyFont
204
- dataLargeUnits: TypographyFont
205
- dataMedium: TypographyFont
206
- dataMediumUnits: TypographyFont
207
- dataSmall: TypographyFont
208
- dataSmallUnits: TypographyFont
209
- display0: TypographyFont
210
- heading1: TypographyFont
211
- heading2: TypographyFont
212
- heading3: TypographyFont
213
- heading4: TypographyFont
214
- heading5: TypographyFont
215
- heading6: TypographyFont
216
- paragraphIntroLede: TypographyFont
217
- paragraphBody: TypographyFont
218
- paragraphSmall: TypographyFont
219
- paragraphExtraSmall: TypographyFont
220
- paragraphBold: {
221
- fontWeight: KaizenCSSProperties["fontWeight"]
222
- }
223
- buttonPrimary: TypographyFont
224
- buttonSecondary: TypographyFont
225
- }
226
- }
227
-
228
- // Converts all leafs (values that aren't objects) of an object tree to LeafType.
229
- export type DeepMapObjectLeafs<T, LeafType> = T extends
230
- | string
231
- | number
232
- | bigint
233
- | boolean
234
- | symbol
235
- | null
236
- | undefined
237
- | ((...params: any[]) => any)
238
- ? LeafType
239
- : T extends Record<any, any>
240
- ? {
241
- [Key in keyof T]: DeepMapObjectLeafs<T[Key], LeafType>
242
- }
243
- : T
244
-
245
- /**
246
- * Apologies for the complex types.
247
- * This type represents the Theme type but with every leaf value in the tree mapped strictly to a string, rather than a number or a more complex type such as a string union.
248
- * The reason for this is to have a more accurate type for the generated hierarchy of design tokens which are represented as CSS custom properties, e.g. `var(--color-purple-800)`.
249
- */
250
- export type CSSVariableTheme = DeepMapObjectLeafs<Theme, string>