@wordpress/theme 0.1.0

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.
Files changed (168) hide show
  1. package/LICENSE.md +788 -0
  2. package/README.md +67 -0
  3. package/bin/build-tokens.js +83 -0
  4. package/bin/generate-primitive-tokens/index.ts +115 -0
  5. package/bin/terrazzo-plugin-ds-tokens-docs/index.ts +103 -0
  6. package/bin/terrazzo-plugin-figma-ds-token-manager/index.ts +210 -0
  7. package/bin/terrazzo-plugin-figma-ds-token-manager/lib.ts +1 -0
  8. package/bin/terrazzo-plugin-known-wpds-css-variables/index.ts +72 -0
  9. package/build/color-ramps/index.js +132 -0
  10. package/build/color-ramps/index.js.map +7 -0
  11. package/build/color-ramps/lib/cache-utils.js +57 -0
  12. package/build/color-ramps/lib/cache-utils.js.map +7 -0
  13. package/build/color-ramps/lib/constants.js +105 -0
  14. package/build/color-ramps/lib/constants.js.map +7 -0
  15. package/build/color-ramps/lib/find-color-with-constraints.js +141 -0
  16. package/build/color-ramps/lib/find-color-with-constraints.js.map +7 -0
  17. package/build/color-ramps/lib/index.js +264 -0
  18. package/build/color-ramps/lib/index.js.map +7 -0
  19. package/build/color-ramps/lib/ramp-configs.js +315 -0
  20. package/build/color-ramps/lib/ramp-configs.js.map +7 -0
  21. package/build/color-ramps/lib/taper-chroma.js +159 -0
  22. package/build/color-ramps/lib/taper-chroma.js.map +7 -0
  23. package/build/color-ramps/lib/types.js +17 -0
  24. package/build/color-ramps/lib/types.js.map +7 -0
  25. package/build/color-ramps/lib/utils.js +106 -0
  26. package/build/color-ramps/lib/utils.js.map +7 -0
  27. package/build/context.js +34 -0
  28. package/build/context.js.map +7 -0
  29. package/build/index.js +29 -0
  30. package/build/index.js.map +7 -0
  31. package/build/lock-unlock.js +35 -0
  32. package/build/lock-unlock.js.map +7 -0
  33. package/build/prebuilt/js/design-tokens.js +135 -0
  34. package/build/prebuilt/js/design-tokens.js.map +7 -0
  35. package/build/prebuilt/json/figma.json +1317 -0
  36. package/build/prebuilt/ts/design-tokens.js +354 -0
  37. package/build/prebuilt/ts/design-tokens.js.map +7 -0
  38. package/build/private-apis.js +36 -0
  39. package/build/private-apis.js.map +7 -0
  40. package/build/style.module.css.js +2 -0
  41. package/build/theme-provider.js +92 -0
  42. package/build/theme-provider.js.map +7 -0
  43. package/build/types/css-modules.d.js +2 -0
  44. package/build/types/css-modules.d.js.map +7 -0
  45. package/build/types.js +17 -0
  46. package/build/types.js.map +7 -0
  47. package/build/use-theme-provider-styles.js +230 -0
  48. package/build/use-theme-provider-styles.js.map +7 -0
  49. package/build-module/color-ramps/index.js +95 -0
  50. package/build-module/color-ramps/index.js.map +7 -0
  51. package/build-module/color-ramps/lib/cache-utils.js +31 -0
  52. package/build-module/color-ramps/lib/cache-utils.js.map +7 -0
  53. package/build-module/color-ramps/lib/constants.js +63 -0
  54. package/build-module/color-ramps/lib/constants.js.map +7 -0
  55. package/build-module/color-ramps/lib/find-color-with-constraints.js +112 -0
  56. package/build-module/color-ramps/lib/find-color-with-constraints.js.map +7 -0
  57. package/build-module/color-ramps/lib/index.js +235 -0
  58. package/build-module/color-ramps/lib/index.js.map +7 -0
  59. package/build-module/color-ramps/lib/ramp-configs.js +290 -0
  60. package/build-module/color-ramps/lib/ramp-configs.js.map +7 -0
  61. package/build-module/color-ramps/lib/taper-chroma.js +125 -0
  62. package/build-module/color-ramps/lib/taper-chroma.js.map +7 -0
  63. package/build-module/color-ramps/lib/types.js +1 -0
  64. package/build-module/color-ramps/lib/types.js.map +7 -0
  65. package/build-module/color-ramps/lib/utils.js +84 -0
  66. package/build-module/color-ramps/lib/utils.js.map +7 -0
  67. package/build-module/context.js +10 -0
  68. package/build-module/context.js.map +7 -0
  69. package/build-module/index.js +5 -0
  70. package/build-module/index.js.map +7 -0
  71. package/build-module/lock-unlock.js +10 -0
  72. package/build-module/lock-unlock.js.map +7 -0
  73. package/build-module/prebuilt/js/design-tokens.js +115 -0
  74. package/build-module/prebuilt/js/design-tokens.js.map +7 -0
  75. package/build-module/prebuilt/json/figma.json +1317 -0
  76. package/build-module/prebuilt/ts/design-tokens.js +334 -0
  77. package/build-module/prebuilt/ts/design-tokens.js.map +7 -0
  78. package/build-module/private-apis.js +12 -0
  79. package/build-module/private-apis.js.map +7 -0
  80. package/build-module/style.module.css.js +1 -0
  81. package/build-module/theme-provider.js +58 -0
  82. package/build-module/theme-provider.js.map +7 -0
  83. package/build-module/types/css-modules.d.js +1 -0
  84. package/build-module/types/css-modules.d.js.map +7 -0
  85. package/build-module/types.js +1 -0
  86. package/build-module/types.js.map +7 -0
  87. package/build-module/use-theme-provider-styles.js +200 -0
  88. package/build-module/use-theme-provider-styles.js.map +7 -0
  89. package/build-style/style.css +3 -0
  90. package/build-types/color-ramps/index.d.ts +44 -0
  91. package/build-types/color-ramps/index.d.ts.map +1 -0
  92. package/build-types/color-ramps/lib/cache-utils.d.ts +22 -0
  93. package/build-types/color-ramps/lib/cache-utils.d.ts.map +1 -0
  94. package/build-types/color-ramps/lib/constants.d.ts +38 -0
  95. package/build-types/color-ramps/lib/constants.d.ts.map +1 -0
  96. package/build-types/color-ramps/lib/find-color-with-constraints.d.ts +37 -0
  97. package/build-types/color-ramps/lib/find-color-with-constraints.d.ts.map +1 -0
  98. package/build-types/color-ramps/lib/index.d.ts +11 -0
  99. package/build-types/color-ramps/lib/index.d.ts.map +1 -0
  100. package/build-types/color-ramps/lib/ramp-configs.d.ts +7 -0
  101. package/build-types/color-ramps/lib/ramp-configs.d.ts.map +1 -0
  102. package/build-types/color-ramps/lib/taper-chroma.d.ts +32 -0
  103. package/build-types/color-ramps/lib/taper-chroma.d.ts.map +1 -0
  104. package/build-types/color-ramps/lib/types.d.ts +78 -0
  105. package/build-types/color-ramps/lib/types.d.ts.map +1 -0
  106. package/build-types/color-ramps/lib/utils.d.ts +38 -0
  107. package/build-types/color-ramps/lib/utils.d.ts.map +1 -0
  108. package/build-types/color-ramps/stories/index.story.d.ts +14 -0
  109. package/build-types/color-ramps/stories/index.story.d.ts.map +1 -0
  110. package/build-types/color-ramps/stories/ramp-table.d.ts +19 -0
  111. package/build-types/color-ramps/stories/ramp-table.d.ts.map +1 -0
  112. package/build-types/context.d.ts +10 -0
  113. package/build-types/context.d.ts.map +1 -0
  114. package/build-types/index.d.ts +2 -0
  115. package/build-types/index.d.ts.map +1 -0
  116. package/build-types/lock-unlock.d.ts +2 -0
  117. package/build-types/lock-unlock.d.ts.map +1 -0
  118. package/build-types/prebuilt/js/design-tokens.d.ts +3 -0
  119. package/build-types/prebuilt/js/design-tokens.d.ts.map +1 -0
  120. package/build-types/prebuilt/ts/design-tokens.d.ts +7 -0
  121. package/build-types/prebuilt/ts/design-tokens.d.ts.map +1 -0
  122. package/build-types/private-apis.d.ts +2 -0
  123. package/build-types/private-apis.d.ts.map +1 -0
  124. package/build-types/stories/index.story.d.ts +15 -0
  125. package/build-types/stories/index.story.d.ts.map +1 -0
  126. package/build-types/theme-provider.d.ts +3 -0
  127. package/build-types/theme-provider.d.ts.map +1 -0
  128. package/build-types/types.d.ts +42 -0
  129. package/build-types/types.d.ts.map +1 -0
  130. package/build-types/use-theme-provider-styles.d.ts +17 -0
  131. package/build-types/use-theme-provider-styles.d.ts.map +1 -0
  132. package/docs/ds-tokens.md +283 -0
  133. package/package.json +58 -0
  134. package/src/color-ramps/index.ts +155 -0
  135. package/src/color-ramps/lib/cache-utils.ts +56 -0
  136. package/src/color-ramps/lib/constants.ts +85 -0
  137. package/src/color-ramps/lib/find-color-with-constraints.ts +190 -0
  138. package/src/color-ramps/lib/index.ts +369 -0
  139. package/src/color-ramps/lib/ramp-configs.ts +309 -0
  140. package/src/color-ramps/lib/taper-chroma.ts +226 -0
  141. package/src/color-ramps/lib/types.ts +90 -0
  142. package/src/color-ramps/lib/utils.ts +161 -0
  143. package/src/color-ramps/stories/index.story.tsx +264 -0
  144. package/src/color-ramps/stories/ramp-table.tsx +212 -0
  145. package/src/color-ramps/test/__snapshots__/index.test.ts.snap +1280 -0
  146. package/src/color-ramps/test/index.test.ts +94 -0
  147. package/src/context.ts +19 -0
  148. package/src/index.ts +2 -0
  149. package/src/lock-unlock.ts +10 -0
  150. package/src/prebuilt/css/design-tokens.css +401 -0
  151. package/src/prebuilt/js/design-tokens.js +116 -0
  152. package/src/prebuilt/json/figma.json +1317 -0
  153. package/src/prebuilt/ts/design-tokens.ts +335 -0
  154. package/src/private-apis.ts +12 -0
  155. package/src/stories/index.story.tsx +426 -0
  156. package/src/style.module.css +3 -0
  157. package/src/theme-provider.tsx +87 -0
  158. package/src/types/css-modules.d.ts +4 -0
  159. package/src/types.ts +44 -0
  160. package/src/use-theme-provider-styles.ts +247 -0
  161. package/terrazzo.config.ts +102 -0
  162. package/tokens/border.json +34 -0
  163. package/tokens/color.json +877 -0
  164. package/tokens/elevation.json +201 -0
  165. package/tokens/spacing.json +45 -0
  166. package/tokens/typography.json +93 -0
  167. package/tsconfig.json +9 -0
  168. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lock-unlock.d.ts","sourceRoot":"","sources":["../src/lock-unlock.ts"],"names":[],"mappings":"AAKA,eAAO,MAAQ,IAAI,mDAAE,MAAM,iCAIzB,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const _default: string[];
2
+ export default _default;
3
+ //# sourceMappingURL=design-tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"design-tokens.d.ts","sourceRoot":"","sources":["../../../src/prebuilt/js/design-tokens.js"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file is generated by the @terrazzo/plugin-known-wpds-css-variables plugin.
3
+ * Do not edit this file directly.
4
+ */
5
+ declare const _default: Record<string, Record<string, string>>;
6
+ export default _default;
7
+ //# sourceMappingURL=design-tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"design-tokens.d.ts","sourceRoot":"","sources":["../../../src/prebuilt/ts/design-tokens.ts"],"names":[],"mappings":"AAAA;;;GAGG;wBA2UE,MAAM,CAAE,MAAM,EAAE,MAAM,CAAE,MAAM,EAAE,MAAM,CAAE,CAAE;AAzU/C,wBAyUgD"}
@@ -0,0 +1,2 @@
1
+ export declare const privateApis: {};
2
+ //# sourceMappingURL=private-apis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private-apis.d.ts","sourceRoot":"","sources":["../src/private-apis.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,WAAW,IAAK,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { Meta, StoryObj } from '@storybook/react';
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+ import { ThemeProvider } from '../theme-provider';
9
+ declare const meta: Meta<typeof ThemeProvider>;
10
+ export default meta;
11
+ export declare const Default: StoryObj<typeof ThemeProvider>;
12
+ export declare const WithPicker: StoryObj<typeof ThemeProvider>;
13
+ export declare const NestingAndInheriting: StoryObj<typeof ThemeProvider>;
14
+ export declare const AcrossIframes: StoryObj<typeof ThemeProvider>;
15
+ //# sourceMappingURL=index.story.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../src/stories/index.story.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAavD;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,aAAa,CAgBrC,CAAC;AACF,eAAe,IAAI,CAAC;AAyHpB,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAE,OAAO,aAAa,CAInD,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAE,OAAO,aAAa,CA+CtD,CAAC;AA6CF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAE,OAAO,aAAa,CAiDhE,CAAC;AA0EF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAE,OAAO,aAAa,CA6CzD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type ThemeProviderProps } from './types';
2
+ export declare const ThemeProvider: ({ children, color, isRoot, }: ThemeProviderProps) => import("react").JSX.Element;
3
+ //# sourceMappingURL=theme-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-provider.d.ts","sourceRoot":"","sources":["../src/theme-provider.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAgClD,eAAO,MAAM,aAAa,iCAIvB,kBAAkB,gCAmCpB,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { type ReactNode } from 'react';
5
+ export interface ThemeProviderSettings {
6
+ /**
7
+ * The set of color options to apply to the theme.
8
+ */
9
+ color?: {
10
+ /**
11
+ * The primary seed color to use for the theme.
12
+ *
13
+ * By default, it inherits from parent `ThemeProvider`,
14
+ * and fallbacks to statically built CSS.
15
+ */
16
+ primary?: string;
17
+ /**
18
+ * The background seed color to use for the theme.
19
+ *
20
+ * By default, it inherits from parent `ThemeProvider`,
21
+ * and fallbacks to statically built CSS.
22
+ */
23
+ bg?: string;
24
+ };
25
+ }
26
+ export interface ThemeProviderProps extends ThemeProviderSettings {
27
+ /**
28
+ * The children to render.
29
+ */
30
+ children?: ReactNode;
31
+ /**
32
+ * When a ThemeProvider is the root provider, it will apply its theming
33
+ * settings also to the root document element (e.g. the html element).
34
+ * This is useful, for example, to make sure that the `html` element can
35
+ * consume the right background color, or that overlays rendered inside a
36
+ * portal can inherit the correct color scheme.
37
+ *
38
+ * @default false
39
+ */
40
+ isRoot?: boolean;
41
+ }
42
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,qBAAqB;IACrC;;OAEG;IACH,KAAK,CAAC,EAAE;QACP;;;;;WAKG;QACH,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB;;;;;WAKG;QACH,EAAE,CAAC,EAAE,MAAM,CAAC;KACZ,CAAC;CACF;AAED,MAAM,WAAW,kBAAmB,SAAQ,qBAAqB;IAChE;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { CSSProperties } from 'react';
5
+ import type { ThemeProviderProps } from './types';
6
+ export declare function useThemeProviderStyles({ color, }?: {
7
+ color?: ThemeProviderProps['color'];
8
+ }): {
9
+ resolvedSettings: {
10
+ color: {
11
+ primary: string;
12
+ bg: string;
13
+ };
14
+ };
15
+ themeProviderStyles: CSSProperties;
16
+ };
17
+ //# sourceMappingURL=use-theme-provider-styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-theme-provider-styles.d.ts","sourceRoot":"","sources":["../src/use-theme-provider-styles.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAmB3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAiKlD,wBAAgB,sBAAsB,CAAE,EACvC,KAAU,GACV,GAAE;IACF,KAAK,CAAC,EAAE,kBAAkB,CAAE,OAAO,CAAE,CAAC;CACjC;;;;;;;;EA2DL"}
@@ -0,0 +1,283 @@
1
+ <!--
2
+ This file is generated by @terrazzo/terrazzo-plugin-ds-tokens-docs.
3
+ Do not edit directly.
4
+ -->
5
+
6
+ # DS Tokens reference
7
+
8
+ ## Semantic tokens
9
+
10
+ ### Border
11
+
12
+ | Variable name | Description |
13
+ | ------------------------------ | --------------------------- |
14
+ | `--wpds-border-radius-x-small` | Extra small radius |
15
+ | `--wpds-border-radius-small` | Small radius |
16
+ | `--wpds-border-radius-medium` | Medium radius |
17
+ | `--wpds-border-radius-large` | Large radius |
18
+ | `--wpds-border-width-focus` | Border width for focus ring |
19
+
20
+ ### Color
21
+
22
+ | Variable name | Description |
23
+ | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
24
+ | `--wpds-color-bg-surface-neutral` | Background color for surfaces with normal emphasis. |
25
+ | `--wpds-color-bg-surface-neutral-strong` | Background color for surfaces with strong emphasis. |
26
+ | `--wpds-color-bg-surface-neutral-weak` | Background color for surfaces with weak emphasis. |
27
+ | `--wpds-color-bg-surface-brand` | Background color for surfaces with brand tone and normal emphasis. |
28
+ | `--wpds-color-bg-surface-success` | Background color for surfaces with success tone and normal emphasis. |
29
+ | `--wpds-color-bg-surface-success-weak` | Background color for surfaces with success tone and weak emphasis. |
30
+ | `--wpds-color-bg-surface-info` | Background color for surfaces with info tone and normal emphasis. |
31
+ | `--wpds-color-bg-surface-info-weak` | Background color for surfaces with info tone and weak emphasis. |
32
+ | `--wpds-color-bg-surface-warning` | Background color for surfaces with warning tone and normal emphasis. |
33
+ | `--wpds-color-bg-surface-warning-weak` | Background color for surfaces with warning tone and weak emphasis. |
34
+ | `--wpds-color-bg-surface-error` | Background color for surfaces with error tone and normal emphasis. |
35
+ | `--wpds-color-bg-surface-error-weak` | Background color for surfaces with error tone and weak emphasis. |
36
+ | `--wpds-color-bg-interactive-neutral` | Background color for interactive elements with neutral tone and normal emphasis. |
37
+ | `--wpds-color-bg-interactive-neutral-active` | Background color for interactive elements with neutral tone and normal emphasis that are hovered, focused, or active. |
38
+ | `--wpds-color-bg-interactive-neutral-disabled` | Background color for interactive elements with neutral tone and normal emphasis, in their disabled state. |
39
+ | `--wpds-color-bg-interactive-neutral-strong` | Background color for interactive elements with neutral tone and strong emphasis. |
40
+ | `--wpds-color-bg-interactive-neutral-strong-active` | Background color for interactive elements with neutral tone and strong emphasis that are hovered, focused, or active. |
41
+ | `--wpds-color-bg-interactive-neutral-strong-disabled` | Background color for interactive elements with neutral tone and strong emphasis, in their disabled state. |
42
+ | `--wpds-color-bg-interactive-neutral-weak` | Background color for interactive elements with neutral tone and weak emphasis. |
43
+ | `--wpds-color-bg-interactive-neutral-weak-active` | Background color for interactive elements with neutral tone and weak emphasis that are hovered, focused, or active. |
44
+ | `--wpds-color-bg-interactive-neutral-weak-disabled` | Background color for interactive elements with neutral tone and weak emphasis, in their disabled state. |
45
+ | `--wpds-color-bg-interactive-brand` | Background color for interactive elements with brand tone and normal emphasis. |
46
+ | `--wpds-color-bg-interactive-brand-active` | Background color for interactive elements with brand tone and normal emphasis that are hovered, focused, or active. |
47
+ | `--wpds-color-bg-interactive-brand-disabled` | Background color for interactive elements with brand tone and normal emphasis, in their disabled state. |
48
+ | `--wpds-color-bg-interactive-brand-strong` | Background color for interactive elements with brand tone and strong emphasis. |
49
+ | `--wpds-color-bg-interactive-brand-strong-active` | Background color for interactive elements with brand tone and strong emphasis that are hovered, focused, or active. |
50
+ | `--wpds-color-bg-interactive-brand-strong-disabled` | Background color for interactive elements with brand tone and strong emphasis, in their disabled state. |
51
+ | `--wpds-color-bg-interactive-brand-weak` | Background color for interactive elements with brand tone and weak emphasis. |
52
+ | `--wpds-color-bg-interactive-brand-weak-active` | Background color for interactive elements with brand tone and weak emphasis that are hovered, focused, or active. |
53
+ | `--wpds-color-bg-interactive-brand-weak-disabled` | Background color for interactive elements with brand tone and weak emphasis, in their disabled state. |
54
+ | `--wpds-color-bg-track-neutral-weak` | Background color for tracks with a neutral tone and weak emphasis (eg. scrollbar track). |
55
+ | `--wpds-color-bg-track-neutral` | Background color for tracks with a neutral tone and normal emphasis (eg. slider or progressbar track). |
56
+ | `--wpds-color-bg-thumb-neutral-weak` | Background color for thumbs with a neutral tone and weak emphasis (eg. scrollbar thumb). |
57
+ | `--wpds-color-bg-thumb-neutral-weak-active` | Background color for thumbs with a neutral tone and weak emphasis (eg. scrollbar thumb) that are hovered, focused, or active. |
58
+ | `--wpds-color-bg-thumb-brand` | Background color for thumbs with a brand tone and normal emphasis (eg. slider thumb and filled track). |
59
+ | `--wpds-color-bg-thumb-brand-active` | Background color for thumbs with a brand tone and normal emphasis (eg. slider thumb and filled track) that are hovered, focused, or active. |
60
+ | `--wpds-color-bg-thumb-brand-disabled` | Background color for thumbs with a brand tone and normal emphasis (eg. slider thumb and filled track), in their disabled state. |
61
+ | `--wpds-color-fg-content-neutral` | Foreground color for content like text with normal emphasis. |
62
+ | `--wpds-color-fg-content-neutral-weak` | Foreground color for content like text with weak emphasis. |
63
+ | `--wpds-color-fg-interactive-neutral` | Foreground color for interactive elements with neutral tone and normal emphasis. |
64
+ | `--wpds-color-fg-interactive-neutral-active` | Foreground color for interactive elements with neutral tone and normal emphasis that are hovered, focused, or active. |
65
+ | `--wpds-color-fg-interactive-neutral-disabled` | Foreground color for interactive elements with neutral tone and normal emphasis, in their disabled state. |
66
+ | `--wpds-color-fg-interactive-neutral-strong` | Foreground color for interactive elements with neutral tone and strong emphasis. |
67
+ | `--wpds-color-fg-interactive-neutral-strong-active` | Foreground color for interactive elements with neutral tone and strong emphasis that are hovered, focused, or active. |
68
+ | `--wpds-color-fg-interactive-neutral-strong-disabled` | Foreground color for interactive elements with neutral tone and strong emphasis, in their disabled state. |
69
+ | `--wpds-color-fg-interactive-neutral-weak` | Foreground color for interactive elements with neutral tone and weak emphasis. |
70
+ | `--wpds-color-fg-interactive-neutral-weak-disabled` | Foreground color for interactive elements with neutral tone and weak emphasis, in their disabled state. |
71
+ | `--wpds-color-fg-interactive-brand` | Foreground color for interactive elements with brand tone and normal emphasis. |
72
+ | `--wpds-color-fg-interactive-brand-active` | Foreground color for interactive elements with brand tone and normal emphasis that are hovered, focused, or active. |
73
+ | `--wpds-color-fg-interactive-brand-disabled` | Foreground color for interactive elements with brand tone and normal emphasis, in their disabled state. |
74
+ | `--wpds-color-fg-interactive-brand-strong` | Foreground color for interactive elements with brand tone and strong emphasis. |
75
+ | `--wpds-color-fg-interactive-brand-strong-active` | Foreground color for interactive elements with brand tone and strong emphasis that are hovered, focused, or active. |
76
+ | `--wpds-color-fg-interactive-brand-strong-disabled` | Foreground color for interactive elements with brand tone and strong emphasis, in their disabled state. |
77
+ | `--wpds-color-stroke-surface-neutral` | Decorative stroke color used to define neutrally-toned surface boundaries with normal emphasis. |
78
+ | `--wpds-color-stroke-surface-neutral-weak` | Decorative stroke color used to define neutrally-toned surface boundaries with weak emphasis. |
79
+ | `--wpds-color-stroke-surface-neutral-strong` | Decorative stroke color used to define neutrally-toned surface boundaries with strong emphasis. |
80
+ | `--wpds-color-stroke-surface-brand` | Decorative stroke color used to define brand-toned surface boundaries with normal emphasis. |
81
+ | `--wpds-color-stroke-surface-brand-strong` | Decorative stroke color used to define neutrally-toned surface boundaries with strong emphasis. |
82
+ | `--wpds-color-stroke-surface-success` | Decorative stroke color used to define success-toned surface boundaries with normal emphasis. |
83
+ | `--wpds-color-stroke-surface-success-strong` | Decorative stroke color used to define success-toned surface boundaries with strong emphasis. |
84
+ | `--wpds-color-stroke-surface-info` | Decorative stroke color used to define info-toned surface boundaries with normal emphasis. |
85
+ | `--wpds-color-stroke-surface-info-strong` | Decorative stroke color used to define info-toned surface boundaries with strong emphasis. |
86
+ | `--wpds-color-stroke-surface-warning` | Decorative stroke color used to define warning-toned surface boundaries with normal emphasis. |
87
+ | `--wpds-color-stroke-surface-warning-strong` | Decorative stroke color used to define warning-toned surface boundaries with strong emphasis. |
88
+ | `--wpds-color-stroke-surface-error` | Decorative stroke color used to define error-toned surface boundaries with normal emphasis. |
89
+ | `--wpds-color-stroke-surface-error-strong` | Decorative stroke color used to define error-toned surface boundaries with strong emphasis. |
90
+ | `--wpds-color-stroke-interactive-neutral` | Accessible stroke color used for interactive neutrally-toned elements with normal emphasis. |
91
+ | `--wpds-color-stroke-interactive-neutral-active` | Accessible stroke color used for interactive neutrally-toned elements with normal emphasis that are hovered, focused, or active. |
92
+ | `--wpds-color-stroke-interactive-neutral-disabled` | Accessible stroke color used for interactive neutrally-toned elements with normal emphasis, in their disabled state. |
93
+ | `--wpds-color-stroke-interactive-neutral-strong` | Accessible stroke color used for interactive neutrally-toned elements with strong emphasis. |
94
+ | `--wpds-color-stroke-interactive-brand` | Accessible stroke color used for interactive brand-toned elements with normal emphasis. |
95
+ | `--wpds-color-stroke-interactive-brand-active` | Accessible stroke color used for interactive brand-toned elements with normal emphasis that are hovered, focused, or active. |
96
+ | `--wpds-color-stroke-interactive-brand-disabled` | Accessible stroke color used for interactive brand-toned elements with normal emphasis, in their disabled state. |
97
+ | `--wpds-color-stroke-interactive-error-strong` | Accessible stroke color used for interactive error-toned elements with strong emphasis. |
98
+ | `--wpds-color-stroke-focus-brand` | Accessible stroke color applied to focus rings. |
99
+
100
+ ### Elevation
101
+
102
+ | Variable name | Description |
103
+ | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
104
+ | `--wpds-elevation-x-small` | For sections and containers that group related content and controls, which may overlap other content. Example: Preview Frame. |
105
+ | `--wpds-elevation-small` | For components that provide contextual feedback without being intrusive. Generally non-interruptive. Example: Tooltips, Snackbar. |
106
+ | `--wpds-elevation-medium` | For components that offer additional actions. Example: Menus, Command Palette |
107
+ | `--wpds-elevation-large` | For components that confirm decisions or handle necessary interruptions. Example: Modals. |
108
+
109
+ ### Spacing
110
+
111
+ | Variable name | Description |
112
+ | ------------------- | ------------------- |
113
+ | `--wpds-spacing-05` | Extra small spacing |
114
+ | `--wpds-spacing-10` | Small spacing |
115
+ | `--wpds-spacing-15` | Medium spacing |
116
+ | `--wpds-spacing-20` | Large spacing |
117
+ | `--wpds-spacing-30` | Extra large spacing |
118
+ | `--wpds-spacing-40` | 2X large spacing |
119
+ | `--wpds-spacing-50` | 3X large spacing |
120
+ | `--wpds-spacing-60` | 4X large spacing |
121
+ | `--wpds-spacing-70` | 5X large spacing |
122
+ | `--wpds-spacing-80` | 6X large spacing |
123
+
124
+ ### Typography
125
+
126
+ | Variable name | Description |
127
+ | ---------------------------------- | ----------------------- |
128
+ | `--wpds-font-family-heading` | Headings font family |
129
+ | `--wpds-font-family-body` | Body font family |
130
+ | `--wpds-font-family-mono` | Monospace font family |
131
+ | `--wpds-font-size-x-small` | Extra small font size |
132
+ | `--wpds-font-size-small` | Small font size |
133
+ | `--wpds-font-size-medium` | Medium font size |
134
+ | `--wpds-font-size-large` | Large font size |
135
+ | `--wpds-font-size-x-large` | Extra large font size |
136
+ | `--wpds-font-size-2x-large` | 2X large font size |
137
+ | `--wpds-font-line-height-x-small` | Extra small line height |
138
+ | `--wpds-font-line-height-small` | Small line height |
139
+ | `--wpds-font-line-height-medium` | Medium line height |
140
+ | `--wpds-font-line-height-large` | Large line height |
141
+ | `--wpds-font-line-height-x-large` | Extra large line height |
142
+ | `--wpds-font-line-height-2x-large` | 2X large line height |
143
+
144
+ ## Primitive tokens
145
+
146
+ **🚨 Note: These tokens are only private implementation details of the Theme, and should never be referenced / consumed directly in the code.**
147
+
148
+ ### Color (private)
149
+
150
+ | Variable name | Description |
151
+ | ------------------------------------------------ | ----------- |
152
+ | `--wpds-color-private-primary-bg-fill1` | N/A |
153
+ | `--wpds-color-private-primary-fg-fill` | N/A |
154
+ | `--wpds-color-private-primary-bg-fill2` | N/A |
155
+ | `--wpds-color-private-primary-surface2` | N/A |
156
+ | `--wpds-color-private-primary-surface6` | N/A |
157
+ | `--wpds-color-private-primary-surface5` | N/A |
158
+ | `--wpds-color-private-primary-surface4` | N/A |
159
+ | `--wpds-color-private-primary-surface3` | N/A |
160
+ | `--wpds-color-private-primary-fg-surface4` | N/A |
161
+ | `--wpds-color-private-primary-fg-surface3` | N/A |
162
+ | `--wpds-color-private-primary-fg-surface2` | N/A |
163
+ | `--wpds-color-private-primary-fg-surface1` | N/A |
164
+ | `--wpds-color-private-primary-stroke3` | N/A |
165
+ | `--wpds-color-private-primary-stroke4` | N/A |
166
+ | `--wpds-color-private-primary-stroke2` | N/A |
167
+ | `--wpds-color-private-primary-stroke1` | N/A |
168
+ | `--wpds-color-private-primary-bg-fill-dark` | N/A |
169
+ | `--wpds-color-private-primary-fg-fill-dark` | N/A |
170
+ | `--wpds-color-private-primary-bg-fill-inverted2` | N/A |
171
+ | `--wpds-color-private-primary-bg-fill-inverted1` | N/A |
172
+ | `--wpds-color-private-primary-fg-fill-inverted` | N/A |
173
+ | `--wpds-color-private-primary-surface1` | N/A |
174
+ | `--wpds-color-private-info-bg-fill1` | N/A |
175
+ | `--wpds-color-private-info-fg-fill` | N/A |
176
+ | `--wpds-color-private-info-bg-fill2` | N/A |
177
+ | `--wpds-color-private-info-surface2` | N/A |
178
+ | `--wpds-color-private-info-surface6` | N/A |
179
+ | `--wpds-color-private-info-surface5` | N/A |
180
+ | `--wpds-color-private-info-surface4` | N/A |
181
+ | `--wpds-color-private-info-surface3` | N/A |
182
+ | `--wpds-color-private-info-fg-surface4` | N/A |
183
+ | `--wpds-color-private-info-fg-surface3` | N/A |
184
+ | `--wpds-color-private-info-fg-surface2` | N/A |
185
+ | `--wpds-color-private-info-fg-surface1` | N/A |
186
+ | `--wpds-color-private-info-stroke3` | N/A |
187
+ | `--wpds-color-private-info-stroke4` | N/A |
188
+ | `--wpds-color-private-info-stroke2` | N/A |
189
+ | `--wpds-color-private-info-stroke1` | N/A |
190
+ | `--wpds-color-private-info-bg-fill-dark` | N/A |
191
+ | `--wpds-color-private-info-fg-fill-dark` | N/A |
192
+ | `--wpds-color-private-info-bg-fill-inverted2` | N/A |
193
+ | `--wpds-color-private-info-bg-fill-inverted1` | N/A |
194
+ | `--wpds-color-private-info-fg-fill-inverted` | N/A |
195
+ | `--wpds-color-private-info-surface1` | N/A |
196
+ | `--wpds-color-private-success-bg-fill1` | N/A |
197
+ | `--wpds-color-private-success-fg-fill` | N/A |
198
+ | `--wpds-color-private-success-bg-fill2` | N/A |
199
+ | `--wpds-color-private-success-surface2` | N/A |
200
+ | `--wpds-color-private-success-surface6` | N/A |
201
+ | `--wpds-color-private-success-surface5` | N/A |
202
+ | `--wpds-color-private-success-surface4` | N/A |
203
+ | `--wpds-color-private-success-surface3` | N/A |
204
+ | `--wpds-color-private-success-fg-surface4` | N/A |
205
+ | `--wpds-color-private-success-fg-surface3` | N/A |
206
+ | `--wpds-color-private-success-fg-surface2` | N/A |
207
+ | `--wpds-color-private-success-fg-surface1` | N/A |
208
+ | `--wpds-color-private-success-stroke3` | N/A |
209
+ | `--wpds-color-private-success-stroke4` | N/A |
210
+ | `--wpds-color-private-success-stroke2` | N/A |
211
+ | `--wpds-color-private-success-stroke1` | N/A |
212
+ | `--wpds-color-private-success-bg-fill-dark` | N/A |
213
+ | `--wpds-color-private-success-fg-fill-dark` | N/A |
214
+ | `--wpds-color-private-success-bg-fill-inverted2` | N/A |
215
+ | `--wpds-color-private-success-bg-fill-inverted1` | N/A |
216
+ | `--wpds-color-private-success-fg-fill-inverted` | N/A |
217
+ | `--wpds-color-private-success-surface1` | N/A |
218
+ | `--wpds-color-private-warning-bg-fill1` | N/A |
219
+ | `--wpds-color-private-warning-fg-fill` | N/A |
220
+ | `--wpds-color-private-warning-bg-fill2` | N/A |
221
+ | `--wpds-color-private-warning-surface2` | N/A |
222
+ | `--wpds-color-private-warning-surface6` | N/A |
223
+ | `--wpds-color-private-warning-surface5` | N/A |
224
+ | `--wpds-color-private-warning-surface4` | N/A |
225
+ | `--wpds-color-private-warning-surface3` | N/A |
226
+ | `--wpds-color-private-warning-fg-surface4` | N/A |
227
+ | `--wpds-color-private-warning-fg-surface3` | N/A |
228
+ | `--wpds-color-private-warning-fg-surface2` | N/A |
229
+ | `--wpds-color-private-warning-fg-surface1` | N/A |
230
+ | `--wpds-color-private-warning-stroke3` | N/A |
231
+ | `--wpds-color-private-warning-stroke4` | N/A |
232
+ | `--wpds-color-private-warning-stroke2` | N/A |
233
+ | `--wpds-color-private-warning-stroke1` | N/A |
234
+ | `--wpds-color-private-warning-bg-fill-dark` | N/A |
235
+ | `--wpds-color-private-warning-fg-fill-dark` | N/A |
236
+ | `--wpds-color-private-warning-bg-fill-inverted2` | N/A |
237
+ | `--wpds-color-private-warning-bg-fill-inverted1` | N/A |
238
+ | `--wpds-color-private-warning-fg-fill-inverted` | N/A |
239
+ | `--wpds-color-private-warning-surface1` | N/A |
240
+ | `--wpds-color-private-error-bg-fill1` | N/A |
241
+ | `--wpds-color-private-error-fg-fill` | N/A |
242
+ | `--wpds-color-private-error-bg-fill2` | N/A |
243
+ | `--wpds-color-private-error-surface2` | N/A |
244
+ | `--wpds-color-private-error-surface6` | N/A |
245
+ | `--wpds-color-private-error-surface5` | N/A |
246
+ | `--wpds-color-private-error-surface4` | N/A |
247
+ | `--wpds-color-private-error-surface3` | N/A |
248
+ | `--wpds-color-private-error-fg-surface4` | N/A |
249
+ | `--wpds-color-private-error-fg-surface3` | N/A |
250
+ | `--wpds-color-private-error-fg-surface2` | N/A |
251
+ | `--wpds-color-private-error-fg-surface1` | N/A |
252
+ | `--wpds-color-private-error-stroke3` | N/A |
253
+ | `--wpds-color-private-error-stroke4` | N/A |
254
+ | `--wpds-color-private-error-stroke2` | N/A |
255
+ | `--wpds-color-private-error-stroke1` | N/A |
256
+ | `--wpds-color-private-error-bg-fill-dark` | N/A |
257
+ | `--wpds-color-private-error-fg-fill-dark` | N/A |
258
+ | `--wpds-color-private-error-bg-fill-inverted2` | N/A |
259
+ | `--wpds-color-private-error-bg-fill-inverted1` | N/A |
260
+ | `--wpds-color-private-error-fg-fill-inverted` | N/A |
261
+ | `--wpds-color-private-error-surface1` | N/A |
262
+ | `--wpds-color-private-bg-surface2` | N/A |
263
+ | `--wpds-color-private-bg-bg-fill1` | N/A |
264
+ | `--wpds-color-private-bg-fg-fill` | N/A |
265
+ | `--wpds-color-private-bg-bg-fill2` | N/A |
266
+ | `--wpds-color-private-bg-surface6` | N/A |
267
+ | `--wpds-color-private-bg-surface5` | N/A |
268
+ | `--wpds-color-private-bg-surface4` | N/A |
269
+ | `--wpds-color-private-bg-surface3` | N/A |
270
+ | `--wpds-color-private-bg-fg-surface4` | N/A |
271
+ | `--wpds-color-private-bg-fg-surface3` | N/A |
272
+ | `--wpds-color-private-bg-fg-surface2` | N/A |
273
+ | `--wpds-color-private-bg-fg-surface1` | N/A |
274
+ | `--wpds-color-private-bg-stroke3` | N/A |
275
+ | `--wpds-color-private-bg-stroke4` | N/A |
276
+ | `--wpds-color-private-bg-stroke2` | N/A |
277
+ | `--wpds-color-private-bg-stroke1` | N/A |
278
+ | `--wpds-color-private-bg-bg-fill-dark` | N/A |
279
+ | `--wpds-color-private-bg-fg-fill-dark` | N/A |
280
+ | `--wpds-color-private-bg-bg-fill-inverted2` | N/A |
281
+ | `--wpds-color-private-bg-bg-fill-inverted1` | N/A |
282
+ | `--wpds-color-private-bg-fg-fill-inverted` | N/A |
283
+ | `--wpds-color-private-bg-surface1` | N/A |
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@wordpress/theme",
3
+ "version": "0.1.0",
4
+ "description": "Theme and context provider for the WordPress Design System.",
5
+ "author": "The WordPress Contributors",
6
+ "license": "GPL-2.0-or-later",
7
+ "keywords": [
8
+ "wordpress",
9
+ "gutenberg",
10
+ "components"
11
+ ],
12
+ "homepage": "https://github.com/WordPress/gutenberg/tree/HEAD/packages/theme/README.md",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/WordPress/gutenberg.git",
16
+ "directory": "packages/theme"
17
+ },
18
+ "bugs": {
19
+ "url": "https://github.com/WordPress/gutenberg/issues"
20
+ },
21
+ "engines": {
22
+ "node": ">=18.12.0",
23
+ "npm": ">=8.19.2"
24
+ },
25
+ "main": "build/index.js",
26
+ "module": "build-module/index.js",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./build-types/index.d.ts",
30
+ "import": "./build-module/index.js",
31
+ "default": "./build/index.js"
32
+ },
33
+ "./design-tokens.css": "./src/prebuilt/css/design-tokens.css",
34
+ "./design-tokens.js": "./src/prebuilt/js/design-tokens.js",
35
+ "./package.json": "./package.json",
36
+ "./build-style/": "./build-style/"
37
+ },
38
+ "react-native": "src/index",
39
+ "wpScript": true,
40
+ "types": "build-types",
41
+ "sideEffects": false,
42
+ "dependencies": {
43
+ "@wordpress/element": "^6.34.0",
44
+ "@wordpress/private-apis": "^1.34.0",
45
+ "colorjs.io": "^0.5.2"
46
+ },
47
+ "peerDependencies": {
48
+ "react": "^18.0.0",
49
+ "react-dom": "^18.0.0"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "scripts": {
55
+ "build": "rimraf src/prebuilt docs && node bin/build-tokens.js && prettier --write tokens/color.json src/prebuilt docs"
56
+ },
57
+ "gitHead": "ceebff807958d2e8fc755b5a20473939c78b4d1d"
58
+ }
@@ -0,0 +1,155 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import Color from 'colorjs.io';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { buildRamp } from './lib/index';
10
+ import { clampAccentScaleReferenceLightness } from './lib/utils';
11
+ import { BG_RAMP_CONFIG, ACCENT_RAMP_CONFIG } from './lib/ramp-configs';
12
+ import type {
13
+ RampResult as InternalRampResult,
14
+ RampDirection,
15
+ Ramp,
16
+ } from './lib/types';
17
+ import { getCachedContrast } from './lib/cache-utils';
18
+ import { CONTRAST_COMBINATIONS } from './lib/constants';
19
+ export { DEFAULT_SEED_COLORS } from './lib/constants';
20
+
21
+ /**
22
+ * Creates a background ramp.
23
+ * @param params
24
+ * @param params.seed
25
+ * @param params.debug
26
+ */
27
+ export function buildBgRamp( {
28
+ seed,
29
+ debug,
30
+ }: {
31
+ seed: string;
32
+ debug?: boolean;
33
+ } ): InternalRampResult {
34
+ if ( typeof seed !== 'string' || seed.trim() === '' ) {
35
+ throw new Error( 'Seed color must be a non-empty string' );
36
+ }
37
+
38
+ return buildRamp( seed, BG_RAMP_CONFIG, { debug } );
39
+ }
40
+
41
+ const STEP_TO_PIN = 'surface2';
42
+ function getBgRampInfo( ramp: InternalRampResult ): {
43
+ mainDirection: RampDirection;
44
+ pinLightness: {
45
+ stepName: keyof Ramp;
46
+ value: number;
47
+ };
48
+ } {
49
+ return {
50
+ mainDirection: ramp.direction,
51
+ pinLightness: {
52
+ stepName: STEP_TO_PIN,
53
+ value: clampAccentScaleReferenceLightness(
54
+ new Color( ramp.ramp[ STEP_TO_PIN ].color ).oklch.l,
55
+ ramp.direction
56
+ ),
57
+ },
58
+ };
59
+ }
60
+
61
+ /**
62
+ * Creates an accent ramp (ie used by primary, success, info, warning and error
63
+ * ramps).
64
+ * @param params
65
+ * @param params.seed
66
+ * @param params.bgRamp
67
+ * @param params.debug
68
+ */
69
+ export function buildAccentRamp( {
70
+ seed,
71
+ bgRamp,
72
+ debug,
73
+ }: {
74
+ seed: string;
75
+ bgRamp?: InternalRampResult;
76
+ debug?: boolean;
77
+ } ): InternalRampResult {
78
+ if ( typeof seed !== 'string' || seed.trim() === '' ) {
79
+ throw new Error( 'Seed color must be a non-empty string' );
80
+ }
81
+
82
+ const bgRampInfo = bgRamp ? getBgRampInfo( bgRamp ) : undefined;
83
+ return buildRamp( seed, ACCENT_RAMP_CONFIG, {
84
+ ...bgRampInfo,
85
+ debug,
86
+ } );
87
+ }
88
+
89
+ /**
90
+ * Checks that all bg/fg combinations generated by the ramps meet contrast
91
+ * targets.
92
+ * @param params
93
+ * @param params.bgRamp
94
+ * @param params.accentRamps
95
+ */
96
+ export function checkAccessibleCombinations( {
97
+ bgRamp,
98
+ accentRamps = [],
99
+ }: {
100
+ bgRamp: InternalRampResult;
101
+ accentRamps?: InternalRampResult[];
102
+ } ) {
103
+ const unmetTargets: {
104
+ bgName: keyof Ramp;
105
+ bgColor: string;
106
+ fgName: keyof Ramp;
107
+ fgColor: string;
108
+ unmetContrast: number;
109
+ }[] = [];
110
+
111
+ // Assess combinations within each ramp
112
+ [ bgRamp, ...accentRamps ].forEach( ( ramp ) => {
113
+ CONTRAST_COMBINATIONS.forEach( ( { bgs, fgs, target } ) => {
114
+ for ( const bg of bgs ) {
115
+ for ( const fg of fgs ) {
116
+ const bgColor = new Color( ramp.ramp[ bg ].color );
117
+ const fgColor = new Color( ramp.ramp[ fg ].color );
118
+ if ( getCachedContrast( bgColor, fgColor ) < target ) {
119
+ unmetTargets.push( {
120
+ bgName: bg,
121
+ bgColor: bgColor.toString(),
122
+ fgName: fg,
123
+ fgColor: fgColor.toString(),
124
+ unmetContrast: target,
125
+ } );
126
+ }
127
+ }
128
+ }
129
+ } );
130
+ } );
131
+ // Assess each accent ramp's fg color against bg ramp
132
+ accentRamps.forEach( ( ramp ) => {
133
+ CONTRAST_COMBINATIONS.forEach( ( { bgs, fgs, target } ) => {
134
+ for ( const bg of bgs ) {
135
+ for ( const fg of fgs ) {
136
+ const bgColor = new Color( bgRamp.ramp[ bg ].color );
137
+ const fgColor = new Color( ramp.ramp[ fg ].color );
138
+ if ( getCachedContrast( bgColor, fgColor ) < target ) {
139
+ unmetTargets.push( {
140
+ bgName: bg,
141
+ bgColor: bgColor.toString(),
142
+ fgName: fg,
143
+ fgColor: fgColor.toString(),
144
+ unmetContrast: target,
145
+ } );
146
+ }
147
+ }
148
+ }
149
+ } );
150
+ } );
151
+
152
+ return unmetTargets;
153
+ }
154
+
155
+ export type RampResult = InternalRampResult;