@wordpress/theme 0.2.1-next.16d95556a.0 → 0.3.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 (82) hide show
  1. package/bin/terrazzo-plugin-inline-alias-values/index.ts +43 -14
  2. package/build/color-ramps/index.js +16 -12
  3. package/build/color-ramps/index.js.map +2 -2
  4. package/build/color-ramps/lib/color-utils.js +5 -0
  5. package/build/color-ramps/lib/color-utils.js.map +2 -2
  6. package/build/color-ramps/lib/constants.js +1 -1
  7. package/build/color-ramps/lib/constants.js.map +1 -1
  8. package/build/color-ramps/lib/default-ramps.js +88 -88
  9. package/build/color-ramps/lib/default-ramps.js.map +1 -1
  10. package/build/color-ramps/lib/find-color-with-constraints.js +1 -1
  11. package/build/color-ramps/lib/find-color-with-constraints.js.map +2 -2
  12. package/build/color-ramps/lib/index.js +2 -2
  13. package/build/color-ramps/lib/index.js.map +2 -2
  14. package/build/color-ramps/lib/ramp-configs.js +2 -2
  15. package/build/color-ramps/lib/ramp-configs.js.map +1 -1
  16. package/build/color-ramps/lib/utils.js +4 -8
  17. package/build/color-ramps/lib/utils.js.map +2 -2
  18. package/build/prebuilt/js/design-tokens.js +5 -4
  19. package/build/prebuilt/js/design-tokens.js.map +2 -2
  20. package/build/prebuilt/json/figma.json +75 -59
  21. package/build/theme-provider.js +3 -1
  22. package/build/theme-provider.js.map +2 -2
  23. package/build/types.js.map +1 -1
  24. package/build-module/color-ramps/index.js +17 -13
  25. package/build-module/color-ramps/index.js.map +2 -2
  26. package/build-module/color-ramps/lib/color-utils.js +7 -1
  27. package/build-module/color-ramps/lib/color-utils.js.map +2 -2
  28. package/build-module/color-ramps/lib/constants.js +1 -1
  29. package/build-module/color-ramps/lib/constants.js.map +1 -1
  30. package/build-module/color-ramps/lib/default-ramps.js +88 -88
  31. package/build-module/color-ramps/lib/default-ramps.js.map +1 -1
  32. package/build-module/color-ramps/lib/find-color-with-constraints.js +2 -2
  33. package/build-module/color-ramps/lib/find-color-with-constraints.js.map +2 -2
  34. package/build-module/color-ramps/lib/index.js +1 -2
  35. package/build-module/color-ramps/lib/index.js.map +2 -2
  36. package/build-module/color-ramps/lib/ramp-configs.js +2 -2
  37. package/build-module/color-ramps/lib/ramp-configs.js.map +1 -1
  38. package/build-module/color-ramps/lib/utils.js +0 -3
  39. package/build-module/color-ramps/lib/utils.js.map +2 -2
  40. package/build-module/prebuilt/js/design-tokens.js +5 -4
  41. package/build-module/prebuilt/js/design-tokens.js.map +2 -2
  42. package/build-module/prebuilt/json/figma.json +75 -59
  43. package/build-module/theme-provider.js +3 -1
  44. package/build-module/theme-provider.js.map +2 -2
  45. package/build-types/color-ramps/index.d.ts +1 -0
  46. package/build-types/color-ramps/index.d.ts.map +1 -1
  47. package/build-types/color-ramps/lib/color-utils.d.ts +5 -0
  48. package/build-types/color-ramps/lib/color-utils.d.ts.map +1 -1
  49. package/build-types/color-ramps/lib/constants.d.ts +1 -1
  50. package/build-types/color-ramps/lib/constants.d.ts.map +1 -1
  51. package/build-types/color-ramps/lib/index.d.ts.map +1 -1
  52. package/build-types/color-ramps/lib/utils.d.ts +0 -5
  53. package/build-types/color-ramps/lib/utils.d.ts.map +1 -1
  54. package/build-types/color-ramps/stories/index.story.d.ts.map +1 -1
  55. package/build-types/stories/index.story.d.ts +1 -0
  56. package/build-types/stories/index.story.d.ts.map +1 -1
  57. package/build-types/theme-provider.d.ts +1 -1
  58. package/build-types/theme-provider.d.ts.map +1 -1
  59. package/build-types/types.d.ts +8 -0
  60. package/build-types/types.d.ts.map +1 -1
  61. package/docs/ds-tokens.md +8 -7
  62. package/package.json +4 -4
  63. package/src/color-ramps/index.ts +16 -11
  64. package/src/color-ramps/lib/color-utils.ts +11 -0
  65. package/src/color-ramps/lib/constants.ts +3 -3
  66. package/src/color-ramps/lib/default-ramps.ts +88 -88
  67. package/src/color-ramps/lib/find-color-with-constraints.ts +2 -2
  68. package/src/color-ramps/lib/index.ts +1 -2
  69. package/src/color-ramps/lib/ramp-configs.ts +2 -2
  70. package/src/color-ramps/lib/utils.ts +1 -8
  71. package/src/color-ramps/stories/index.story.tsx +7 -4
  72. package/src/prebuilt/css/design-tokens.css +81 -55
  73. package/src/prebuilt/js/design-tokens.js +5 -4
  74. package/src/prebuilt/json/figma.json +75 -59
  75. package/src/stories/index.story.tsx +23 -9
  76. package/src/theme-provider.tsx +2 -0
  77. package/src/types.ts +9 -0
  78. package/terrazzo.config.ts +21 -0
  79. package/tokens/color.json +88 -88
  80. package/tokens/dimension.json +44 -10
  81. package/tsconfig.bin.tsbuildinfo +1 -1
  82. package/tsconfig.src.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/constants.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,eAAO,MAAM,KAAK,0CAAuB,CAAC;AAC1C,eAAO,MAAM,KAAK,0CAAuB,CAAC;AAM1C,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAO9C,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAO9C,eAAO,MAAM,sCAAsC;;;;;;;;;CAGzC,CAAC;AAGX,eAAO,MAAM,gBAAgB,QAAO,CAAC;AAErC,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAE3C,eAAO,MAAM,qBAAqB,EAAE;IACnC,GAAG,EAAE,CAAE,MAAM,IAAI,CAAE,EAAE,CAAC;IACtB,GAAG,EAAE,CAAE,MAAM,IAAI,CAAE,EAAE,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CACf,EA+BA,CAAC;AAGF,eAAO,MAAM,mBAAmB;;;;;;;;CAQ/B,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/constants.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,eAAO,MAAM,KAAK,0CAAuB,CAAC;AAC1C,eAAO,MAAM,KAAK,0CAAuB,CAAC;AAM1C,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAO7C,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAO9C,eAAO,MAAM,sCAAsC;;;;;;;;;CAGzC,CAAC;AAGX,eAAO,MAAM,gBAAgB,QAAO,CAAC;AAErC,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAE3C,eAAO,MAAM,qBAAqB,EAAE;IACnC,GAAG,EAAE,CAAE,MAAM,IAAI,CAAE,EAAE,CAAC;IACtB,GAAG,EAAE,CAAE,MAAM,IAAI,CAAE,EAAE,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CACf,EA+BA,CAAC;AAGF,eAAO,MAAM,mBAAmB;;;;;;;;CAQ/B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/index.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,OAAO,yBAAyB,CAAC;AAYjC,OAAO,KAAK,EAEX,IAAI,EACJ,aAAa,EACb,UAAU,EACV,UAAU,EACV,MAAM,SAAS,CAAC;AA6KjB,wBAAgB,SAAS,CACxB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,UAAU,EAClB,EACC,aAAa,EACb,YAAY,EACZ,2BAAkC,GAClC,GAAE;IACF,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,YAAY,CAAC,EAAE;QACd,QAAQ,EAAE,MAAM,IAAI,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;KACd,CAAC;IACF,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACjC,GACJ,UAAU,CAgHZ"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/index.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,OAAO,yBAAyB,CAAC;AAWjC,OAAO,KAAK,EAEX,IAAI,EACJ,aAAa,EACb,UAAU,EACV,UAAU,EACV,MAAM,SAAS,CAAC;AA6KjB,wBAAgB,SAAS,CACxB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,UAAU,EAClB,EACC,aAAa,EACb,YAAY,EACZ,2BAAkC,GAClC,GAAE;IACF,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,YAAY,CAAC,EAAE;QACd,QAAQ,EAAE,MAAM,IAAI,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;KACd,CAAC;IACF,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACjC,GACJ,UAAU,CAgHZ"}
@@ -7,11 +7,6 @@ import { type ColorTypes } from 'colorjs.io/fn';
7
7
  */
8
8
  import './register-color-spaces';
9
9
  import type { Ramp, RampConfig, RampDirection } from './types';
10
- /**
11
- * Make sure that a color is valid in the p3 gamut, and converts it to oklch.
12
- * @param c
13
- */
14
- export declare const clampToGamut: (c: ColorTypes) => import("colorjs.io/fn").PlainColorObject;
15
10
  /**
16
11
  * Topologically sort steps based on their dependencies
17
12
  * @param config - The steps configuration object
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAA0B,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAExE;;GAEG;AACH,OAAO,yBAAyB,CAAC;AAUjC,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG/D;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAK,GAAG,UAAU,6CACa,CAAC;AAwCzD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAE,MAAM,EAAE,UAAU,GAAI,CAAE,MAAM,IAAI,CAAE,EAAE,CAuCvE;AACD;;;;;GAKG;AACH,wBAAgB,YAAY,CAC3B,QAAQ,EAAE,MAAM,IAAI,EACpB,MAAM,EAAE,UAAU,GAChB,CAAE,MAAM,IAAI,CAAE,EAAE,CAqBlB;AAED;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC5C,IAAI,EAAE,UAAU,EAChB,aAAa,CAAC,EAAE,OAAO,GACrB;IACF,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,aAAa,CAAC;CACrB,CASA;AAED,wBAAgB,oBAAoB,CAAE,MAAM,EAAE,MAAM,UAOnD;AAED;;;;;;;GAOG;AACH,wBAAgB,kCAAkC,CACjD,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,aAAa,UAIxB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAE,CAAC,EACjC,UAAU,EAAE,CAAE,CAAC,EAAE,MAAM,KAAM,CAAC,EAC9B,cAAc,EAAE,CAAE,CAAC,EAAE,CAAC,KAAM,MAAM,EAClC,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,GACpB,CAAC,CAqDH"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD;;GAEG;AACH,OAAO,yBAAyB,CAAC;AAUjC,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAyC/D;;;GAGG;AACH,wBAAgB,gBAAgB,CAAE,MAAM,EAAE,UAAU,GAAI,CAAE,MAAM,IAAI,CAAE,EAAE,CAuCvE;AACD;;;;;GAKG;AACH,wBAAgB,YAAY,CAC3B,QAAQ,EAAE,MAAM,IAAI,EACpB,MAAM,EAAE,UAAU,GAChB,CAAE,MAAM,IAAI,CAAE,EAAE,CAqBlB;AAED;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC5C,IAAI,EAAE,UAAU,EAChB,aAAa,CAAC,EAAE,OAAO,GACrB;IACF,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,aAAa,CAAC;CACrB,CASA;AAED,wBAAgB,oBAAoB,CAAE,MAAM,EAAE,MAAM,UAOnD;AAED;;;;;;;GAOG;AACH,wBAAgB,kCAAkC,CACjD,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,aAAa,UAIxB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAE,CAAC,EACjC,UAAU,EAAE,CAAE,CAAC,EAAE,MAAM,KAAM,CAAC,EAC9B,cAAc,EAAE,CAAE,CAAC,EAAE,CAAC,KAAM,MAAM,EAClC,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,GACpB,CAAC,CAqDH"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/stories/index.story.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AASvD,QAAA,MAAM,QAAQ,GAAK,OAAO;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B,gCAEA,CAAC;AAEF,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,QAAQ,CAmBhC,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAE,OAAO,QAAQ,CA4H9C,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAE,OAAO,QAAQ,CA4FzD,CAAC"}
1
+ {"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/stories/index.story.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AASvD,QAAA,MAAM,QAAQ,GAAK,OAAO;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B,gCAEA,CAAC;AAEF,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,QAAQ,CAmBhC,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAE,OAAO,QAAQ,CA+H9C,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAE,OAAO,QAAQ,CA4FzD,CAAC"}
@@ -6,6 +6,7 @@ import type { Meta, StoryObj } from '@storybook/react';
6
6
  * Internal dependencies
7
7
  */
8
8
  import { ThemeProvider } from '../theme-provider';
9
+ import '../prebuilt/css/design-tokens.css';
9
10
  declare const meta: Meta<typeof ThemeProvider>;
10
11
  export default meta;
11
12
  export declare const Default: StoryObj<typeof ThemeProvider>;
@@ -1 +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;AA2GpB,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"}
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;AAClD,OAAO,mCAAmC,CAAC;AAE3C,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,aAAa,CAgBrC,CAAC;AACF,eAAe,IAAI,CAAC;AA2GpB,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,CA8DhE,CAAC;AA0EF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAE,OAAO,aAAa,CA6CzD,CAAC"}
@@ -1,3 +1,3 @@
1
1
  import { type ThemeProviderProps } from './types';
2
- export declare const ThemeProvider: ({ children, color, isRoot, }: ThemeProviderProps) => import("react").JSX.Element;
2
+ export declare const ThemeProvider: ({ children, color, isRoot, density, }: ThemeProviderProps) => import("react").JSX.Element;
3
3
  //# sourceMappingURL=theme-provider.d.ts.map
@@ -1 +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,GAAK,8BAI5B,kBAAkB,gCAmCpB,CAAC"}
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,GAAK,uCAK5B,kBAAkB,gCAoCpB,CAAC"}
@@ -22,6 +22,14 @@ export interface ThemeProviderSettings {
22
22
  */
23
23
  bg?: string;
24
24
  };
25
+ /**
26
+ * The density of the theme. If left unspecified, the theme inherits from
27
+ * the density of the closest `ThemeProvider`, or uses the default density
28
+ * if there is no inherited density.
29
+ *
30
+ * @default undefined
31
+ */
32
+ density?: undefined | 'default' | 'compact' | 'comfortable';
25
33
  }
26
34
  export interface ThemeProviderProps extends ThemeProviderSettings {
27
35
  /**
@@ -1 +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"}
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;IAEF;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,aAAa,CAAC;CAC5D;AAED,MAAM,WAAW,kBAAmB,SAAQ,qBAAqB;IAChE;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB"}
package/docs/ds-tokens.md CHANGED
@@ -111,13 +111,14 @@ Do not edit directly.
111
111
 
112
112
  ### Dimension
113
113
 
114
- | Variable name | Description |
115
- | ------------------------------------------ | -------------------------------- |
116
- | `--wpds-dimension-base` | Base dimension unit |
117
- | `--wpds-dimension-padding-surface-x-small` | Extra small spacing for surfaces |
118
- | `--wpds-dimension-padding-surface-small` | Small spacing for surfaces |
119
- | `--wpds-dimension-padding-surface-medium` | Medium spacing for surfaces |
120
- | `--wpds-dimension-padding-surface-large` | Large spacing for surfaces |
114
+ | Variable name | Description |
115
+ | -------------------------------------- | ----------------------------------- |
116
+ | `--wpds-dimension-base` | Base dimension unit |
117
+ | `--wpds-dimension-padding-surface-2xs` | 2x extra small spacing for surfaces |
118
+ | `--wpds-dimension-padding-surface-xs` | Extra small spacing for surfaces |
119
+ | `--wpds-dimension-padding-surface-sm` | Small spacing for surfaces |
120
+ | `--wpds-dimension-padding-surface-md` | Medium spacing for surfaces |
121
+ | `--wpds-dimension-padding-surface-lg` | Large spacing for surfaces |
121
122
 
122
123
  ### Elevation
123
124
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/theme",
3
- "version": "0.2.1-next.16d95556a.0",
3
+ "version": "0.3.0",
4
4
  "description": "Theme and context provider for the WordPress Design System.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -43,8 +43,8 @@
43
43
  "build-module/color-ramps/lib/register-color-spaces.js"
44
44
  ],
45
45
  "dependencies": {
46
- "@wordpress/element": "^6.35.1-next.16d95556a.0",
47
- "@wordpress/private-apis": "^1.35.1-next.16d95556a.0",
46
+ "@wordpress/element": "^6.36.0",
47
+ "@wordpress/private-apis": "^1.36.0",
48
48
  "colorjs.io": "^0.5.2",
49
49
  "memize": "^2.1.0"
50
50
  },
@@ -64,5 +64,5 @@
64
64
  "build": "npm run build:tokens && npm run build:default-ramps",
65
65
  "postbuild": "prettier --write tokens/color.json src/prebuilt src/color-ramps/lib/default-ramps.ts docs"
66
66
  },
67
- "gitHead": "59a9383612bbe16e21af84d13b035bfbca7fe833"
67
+ "gitHead": "b35cf1a2dce04665e99fd6b9c2891c0b336361b9"
68
68
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { get, OKLCH, parse, serialize } from 'colorjs.io/fn';
4
+ import { get, OKLCH, parse } from 'colorjs.io/fn';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -89,6 +89,7 @@ export function checkAccessibleCombinations( {
89
89
  fgName: keyof Ramp;
90
90
  fgColor: string;
91
91
  unmetContrast: number;
92
+ achievedContrast: number;
92
93
  }[] = [];
93
94
 
94
95
  // Assess combinations within each ramp
@@ -96,15 +97,17 @@ export function checkAccessibleCombinations( {
96
97
  CONTRAST_COMBINATIONS.forEach( ( { bgs, fgs, target } ) => {
97
98
  for ( const bg of bgs ) {
98
99
  for ( const fg of fgs ) {
99
- const bgColor = parse( ramp.ramp[ bg ] );
100
- const fgColor = parse( ramp.ramp[ fg ] );
101
- if ( getContrast( bgColor, fgColor ) < target ) {
100
+ const bgColor = ramp.ramp[ bg ];
101
+ const fgColor = ramp.ramp[ fg ];
102
+ const achievedContrast = getContrast( bgColor, fgColor );
103
+ if ( achievedContrast < target ) {
102
104
  unmetTargets.push( {
103
105
  bgName: bg,
104
- bgColor: serialize( bgColor ),
106
+ bgColor,
105
107
  fgName: fg,
106
- fgColor: serialize( fgColor ),
108
+ fgColor,
107
109
  unmetContrast: target,
110
+ achievedContrast,
108
111
  } );
109
112
  }
110
113
  }
@@ -116,15 +119,17 @@ export function checkAccessibleCombinations( {
116
119
  CONTRAST_COMBINATIONS.forEach( ( { bgs, fgs, target } ) => {
117
120
  for ( const bg of bgs ) {
118
121
  for ( const fg of fgs ) {
119
- const bgColor = parse( bgRamp.ramp[ bg ] );
120
- const fgColor = parse( ramp.ramp[ fg ] );
121
- if ( getContrast( bgColor, fgColor ) < target ) {
122
+ const bgColor = bgRamp.ramp[ bg ];
123
+ const fgColor = ramp.ramp[ fg ];
124
+ const achievedContrast = getContrast( bgColor, fgColor );
125
+ if ( achievedContrast < target ) {
122
126
  unmetTargets.push( {
123
127
  bgName: bg,
124
- bgColor: serialize( bgColor ),
128
+ bgColor,
125
129
  fgName: fg,
126
- fgColor: serialize( fgColor ),
130
+ fgColor,
127
131
  unmetContrast: target,
132
+ achievedContrast,
128
133
  } );
129
134
  }
130
135
  }
@@ -3,9 +3,11 @@
3
3
  */
4
4
  import {
5
5
  to,
6
+ toGamut,
6
7
  serialize,
7
8
  contrastWCAG21,
8
9
  sRGB,
10
+ OKLCH,
9
11
  type ColorTypes,
10
12
  } from 'colorjs.io/fn';
11
13
 
@@ -32,3 +34,12 @@ export function getColorString( color: ColorTypes ): string {
32
34
  export function getContrast( colorA: ColorTypes, colorB: ColorTypes ): number {
33
35
  return contrastWCAG21( colorA, colorB );
34
36
  }
37
+
38
+ /**
39
+ * Make sure that a color is valid in the sRGB gamut and convert it to OKLCH.
40
+ * @param c
41
+ */
42
+ export function clampToGamut( c: ColorTypes ) {
43
+ // map into sRGB using CSS OKLCH method
44
+ return to( toGamut( c, { space: sRGB, method: 'css' } ), OKLCH );
45
+ }
@@ -14,9 +14,9 @@ export const BLACK = to( 'black', OKLCH );
14
14
 
15
15
  // Margin added to target contrasts to counter for algorithm approximations and rounding errors.
16
16
  // - the `CONTRAST_EPSILON` value is 0.004, so the real contrast can be lower by this amount.
17
- // - the max contrast between adjacent RGB values is 1.016, so half of the difference (0.008) can be rounding error.
18
- // - the sum is 0.012: the margin we add to ensure that the target contrast is met after all the rounding.
19
- export const UNIVERSAL_CONTRAST_TOPUP = 0.012;
17
+ // - the max contrast between adjacent RGB values is 1.016, so 0.016 is the maximum total rounding error between two values.
18
+ // - the sum is 0.02: the margin we add to ensure that the target contrast is met after all the rounding.
19
+ export const UNIVERSAL_CONTRAST_TOPUP = 0.02;
20
20
 
21
21
  // When enabling "lighter direction" bias, this is the amount by which
22
22
  // black text contrast needs to be greater than white text contrast.
@@ -13,19 +13,19 @@ export const DEFAULT_RAMPS: Record<
13
13
  surface2: '#f8f8f8',
14
14
  bgFill1: '#555',
15
15
  fgFill: '#f0f0f0',
16
- bgFill2: '#494949',
17
- surface6: '#d3d3d3',
18
- surface5: '#e3e3e3',
16
+ bgFill2: '#484848',
17
+ surface6: '#d2d2d2',
18
+ surface5: '#e2e2e2',
19
19
  surface4: '#eaeaea',
20
20
  surface3: '#fff',
21
21
  fgSurface4: '#1e1e1e',
22
- fgSurface3: '#6e6e6e',
23
- fgSurface2: '#8b8b8b',
24
- fgSurface1: '#ababab',
25
- stroke3: '#8b8b8b',
26
- stroke4: '#6d6d6d',
27
- stroke2: '#adadad',
28
- stroke1: '#cfcfcf',
22
+ fgSurface3: '#6d6d6d',
23
+ fgSurface2: '#8a8a8a',
24
+ fgSurface1: '#aaa',
25
+ stroke3: '#8a8a8a',
26
+ stroke4: '#6c6c6c',
27
+ stroke2: '#d8d8d8',
28
+ stroke1: '#e0e0e0',
29
29
  bgFillDark: '#1e1e1e',
30
30
  fgFillDark: '#f0f0f0',
31
31
  bgFillInverted2: '#1e1e1e',
@@ -39,26 +39,26 @@ export const DEFAULT_RAMPS: Record<
39
39
  ramp: {
40
40
  bgFill1: '#3858e9',
41
41
  fgFill: '#eff0f2',
42
- bgFill2: '#2e49da',
42
+ bgFill2: '#2e49d9',
43
43
  surface2: '#f6f8fc',
44
- surface6: '#c7d3ef',
45
- surface5: '#dce3f5',
46
- surface4: '#e5ebf7',
44
+ surface6: '#c7d2ee',
45
+ surface5: '#dbe2f4',
46
+ surface4: '#e4eaf7',
47
47
  surface3: '#fff',
48
- fgSurface4: '#080071',
48
+ fgSurface4: '#0b0070',
49
49
  fgSurface3: '#3858e9',
50
- fgSurface2: '#5881ff',
51
- fgSurface1: '#84a9ff',
50
+ fgSurface2: '#5b82ff',
51
+ fgSurface1: '#85a9ff',
52
52
  stroke3: '#3858e9',
53
53
  stroke4: '#2337c8',
54
- stroke2: '#6d83bf',
55
- stroke1: '#91a2cf',
54
+ stroke2: '#9aaad3',
55
+ stroke1: '#a2b1d6',
56
56
  bgFillDark: '#1b1e26',
57
57
  fgFillDark: '#eff0f2',
58
58
  bgFillInverted2: '#1b1e26',
59
- bgFillInverted1: '#12009f',
59
+ bgFillInverted1: '#13009f',
60
60
  fgFillInverted: '#eff0f2',
61
- surface1: '#edf0fa',
61
+ surface1: '#ecf0f9',
62
62
  },
63
63
  direction: 'darker',
64
64
  },
@@ -66,26 +66,26 @@ export const DEFAULT_RAMPS: Record<
66
66
  ramp: {
67
67
  bgFill1: '#0090ff',
68
68
  fgFill: '#1b1e23',
69
- bgFill2: '#0081ef',
69
+ bgFill2: '#007fed',
70
70
  surface2: '#f5f9fd',
71
- surface6: '#bed6f1',
72
- surface5: '#d5e5f6',
73
- surface4: '#e0ebf8',
71
+ surface6: '#bdd5f1',
72
+ surface5: '#d4e4f6',
73
+ surface4: '#dfebf8',
74
74
  surface3: '#fff',
75
- fgSurface4: '#001758',
76
- fgSurface3: '#006dd9',
77
- fgSurface2: '#008cfb',
78
- fgSurface1: '#53b1ff',
79
- stroke3: '#006dd9',
80
- stroke4: '#004eb8',
81
- stroke2: '#5d8fc6',
82
- stroke1: '#8aaed6',
75
+ fgSurface4: '#001b4f',
76
+ fgSurface3: '#006bd7',
77
+ fgSurface2: '#008bfa',
78
+ fgSurface1: '#59b0ff',
79
+ stroke3: '#006bd7',
80
+ stroke4: '#004fa9',
81
+ stroke2: '#94b5d9',
82
+ stroke1: '#9fbcdd',
83
83
  bgFillDark: '#1b1e23',
84
84
  fgFillDark: '#eff0f2',
85
85
  bgFillInverted2: '#1b1e23',
86
- bgFillInverted1: '#002675',
86
+ bgFillInverted1: '#002a69',
87
87
  fgFillInverted: '#eff0f2',
88
- surface1: '#eaf1fa',
88
+ surface1: '#e9f1fa',
89
89
  },
90
90
  direction: 'darker',
91
91
  },
@@ -93,26 +93,26 @@ export const DEFAULT_RAMPS: Record<
93
93
  ramp: {
94
94
  bgFill1: '#4ab866',
95
95
  fgFill: '#1b1f1c',
96
- bgFill2: '#37a857',
96
+ bgFill2: '#37a756',
97
97
  surface2: '#f0fcf2',
98
98
  surface6: '#7eea95',
99
- surface5: '#b7f2c1',
100
- surface4: '#cdf5d3',
99
+ surface5: '#b5f1bf',
100
+ surface4: '#cbf5d1',
101
101
  surface3: '#fff',
102
- fgSurface4: '#002b00',
103
- fgSurface3: '#008031',
104
- fgSurface2: '#2c9f4e',
105
- fgSurface1: '#54c16f',
106
- stroke3: '#008031',
107
- stroke4: '#006314',
108
- stroke2: '#61986b',
109
- stroke1: '#77ba84',
102
+ fgSurface4: '#002900',
103
+ fgSurface3: '#007f30',
104
+ fgSurface2: '#2b9e4e',
105
+ fgSurface1: '#53c06e',
106
+ stroke3: '#007f30',
107
+ stroke4: '#006013',
108
+ stroke2: '#7dc189',
109
+ stroke1: '#82c98f',
110
110
  bgFillDark: '#1b1f1c',
111
111
  fgFillDark: '#edf2ed',
112
112
  bgFillInverted2: '#1b1f1c',
113
- bgFillInverted1: '#003800',
113
+ bgFillInverted1: '#003701',
114
114
  fgFillInverted: '#edf2ed',
115
- surface1: '#ddf8e1',
115
+ surface1: '#dbf8df',
116
116
  },
117
117
  direction: 'darker',
118
118
  },
@@ -120,26 +120,26 @@ export const DEFAULT_RAMPS: Record<
120
120
  ramp: {
121
121
  bgFill1: '#f0d149',
122
122
  fgFill: '#1f1e1b',
123
- bgFill2: '#ddbe30',
123
+ bgFill2: '#dcbe2f',
124
124
  surface2: '#fdf9e7',
125
- surface6: '#ecd367',
126
- surface5: '#f5e399',
127
- surface4: '#f8ebb5',
125
+ surface6: '#ecd264',
126
+ surface5: '#f5e297',
127
+ surface4: '#f7eab3',
128
128
  surface3: '#fff',
129
- fgSurface4: '#291d00',
130
- fgSurface3: '#876b00',
131
- fgSurface2: '#a78900',
132
- fgSurface1: '#c9aa00',
133
- stroke3: '#876b00',
134
- stroke4: '#675000',
135
- stroke2: '#978c60',
136
- stroke1: '#b8ab75',
129
+ fgSurface4: '#281d00',
130
+ fgSurface3: '#836b00',
131
+ fgSurface2: '#a58700',
132
+ fgSurface1: '#c7a900',
133
+ stroke3: '#836b00',
134
+ stroke4: '#635000',
135
+ stroke2: '#bfb17a',
136
+ stroke1: '#c7b97f',
137
137
  bgFillDark: '#1f1e1b',
138
138
  fgFillDark: '#f6f1da',
139
139
  bgFillInverted2: '#1f1e1b',
140
- bgFillInverted1: '#3a2b00',
140
+ bgFillInverted1: '#392c00',
141
141
  fgFillInverted: '#f6f1da',
142
- surface1: '#faf1cd',
142
+ surface1: '#f9f0c8',
143
143
  },
144
144
  direction: 'darker',
145
145
  },
@@ -147,26 +147,26 @@ export const DEFAULT_RAMPS: Record<
147
147
  ramp: {
148
148
  bgFill1: '#f0b849',
149
149
  fgFill: '#1f1e1b',
150
- bgFill2: '#dea633',
150
+ bgFill2: '#dda633',
151
151
  surface2: '#fdf7ee',
152
- surface6: '#f1ce90',
153
- surface5: '#f6e0bb',
154
- surface4: '#f8e9cd',
152
+ surface6: '#f1ce8f',
153
+ surface5: '#f6e0b9',
154
+ surface4: '#f8e8cc',
155
155
  surface3: '#fff',
156
- fgSurface4: '#2f1800',
157
- fgSurface3: '#976300',
158
- fgSurface2: '#b78100',
159
- fgSurface1: '#d9a22e',
160
- stroke3: '#976300',
161
- stroke4: '#754900',
162
- stroke2: '#9f8860',
163
- stroke1: '#c2a776',
156
+ fgSurface4: '#2e1900',
157
+ fgSurface3: '#936400',
158
+ fgSurface2: '#b68000',
159
+ fgSurface1: '#d8a12c',
160
+ stroke3: '#936400',
161
+ stroke4: '#704a00',
162
+ stroke2: '#caae7c',
163
+ stroke1: '#d2b581',
164
164
  bgFillDark: '#1f1e1b',
165
165
  fgFillDark: '#f3f0e9',
166
166
  bgFillInverted2: '#1f1e1b',
167
- bgFillInverted1: '#432600',
167
+ bgFillInverted1: '#422800',
168
168
  fgFillInverted: '#f3f0e9',
169
- surface1: '#faefdc',
169
+ surface1: '#faeeda',
170
170
  },
171
171
  direction: 'darker',
172
172
  },
@@ -174,26 +174,26 @@ export const DEFAULT_RAMPS: Record<
174
174
  ramp: {
175
175
  bgFill1: '#cc1818',
176
176
  fgFill: '#f2efef',
177
- bgFill2: '#bc0001',
177
+ bgFill2: '#b90000',
178
178
  surface2: '#fdf6f5',
179
- surface6: '#f5c9c2',
180
- surface5: '#f9dcd8',
181
- surface4: '#fae5e2',
179
+ surface6: '#f5c8c1',
180
+ surface5: '#f9dbd7',
181
+ surface4: '#fae4e1',
182
182
  surface3: '#fff',
183
- fgSurface4: '#4a0000',
183
+ fgSurface4: '#470000',
184
184
  fgSurface3: '#cc1818',
185
- fgSurface2: '#f84d41',
186
- fgSurface1: '#ff8373',
185
+ fgSurface2: '#f74c40',
186
+ fgSurface1: '#ff8879',
187
187
  stroke3: '#cc1818',
188
- stroke4: '#a70000',
189
- stroke2: '#ca675c',
190
- stroke1: '#dc8e83',
188
+ stroke4: '#9d0000',
189
+ stroke2: '#de988e',
190
+ stroke1: '#e1a198',
191
191
  bgFillDark: '#231c1b',
192
192
  fgFillDark: '#f2efef',
193
193
  bgFillInverted2: '#231c1b',
194
- bgFillInverted1: '#680000',
194
+ bgFillInverted1: '#640000',
195
195
  fgFillInverted: '#f2efef',
196
- surface1: '#fcedea',
196
+ surface1: '#fbece9',
197
197
  },
198
198
  direction: 'darker',
199
199
  },
@@ -7,9 +7,9 @@ import { get, OKLCH, type ColorTypes } from 'colorjs.io/fn';
7
7
  * Internal dependencies
8
8
  */
9
9
  import './register-color-spaces';
10
- import { clampToGamut, solveWithBisect } from './utils';
10
+ import { solveWithBisect } from './utils';
11
11
  import { WHITE, BLACK, CONTRAST_EPSILON } from './constants';
12
- import { getContrast } from './color-utils';
12
+ import { clampToGamut, getContrast } from './color-utils';
13
13
  import { type TaperChromaOptions, taperChroma } from './taper-chroma';
14
14
 
15
15
  /**
@@ -15,10 +15,9 @@ import {
15
15
  * Internal dependencies
16
16
  */
17
17
  import './register-color-spaces';
18
- import { getContrast, getColorString } from './color-utils';
18
+ import { clampToGamut, getContrast, getColorString } from './color-utils';
19
19
  import { findColorMeetingRequirements } from './find-color-with-constraints';
20
20
  import {
21
- clampToGamut,
22
21
  sortByDependency,
23
22
  computeBetterFgColorDirection,
24
23
  adjustContrastTarget,
@@ -142,7 +142,7 @@ export const BG_RAMP_CONFIG: RampConfig = {
142
142
  contrast: {
143
143
  reference: 'stroke3',
144
144
  followDirection: 'opposite',
145
- target: 2.2,
145
+ target: 2.6,
146
146
  },
147
147
  taperChromaOptions: STROKE_TAPER_CHROMA,
148
148
  },
@@ -150,7 +150,7 @@ export const BG_RAMP_CONFIG: RampConfig = {
150
150
  contrast: {
151
151
  reference: 'stroke3',
152
152
  followDirection: 'opposite',
153
- target: 1.5,
153
+ target: 2.4,
154
154
  },
155
155
  taperChromaOptions: STROKE_TAPER_CHROMA,
156
156
  },
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { toGamut, to, P3, OKLCH, type ColorTypes } from 'colorjs.io/fn';
4
+ import { type ColorTypes } from 'colorjs.io/fn';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -19,13 +19,6 @@ import {
19
19
  import type { Ramp, RampConfig, RampDirection } from './types';
20
20
  import { getContrast } from './color-utils';
21
21
 
22
- /**
23
- * Make sure that a color is valid in the p3 gamut, and converts it to oklch.
24
- * @param c
25
- */
26
- export const clampToGamut = ( c: ColorTypes ) =>
27
- to( toGamut( c, { space: P3, method: 'css' } ), OKLCH ); // map into Display-P3 using CSS OKLCH method
28
-
29
22
  /**
30
23
  * Build a dependency graph from the steps configuration
31
24
  * @param config - The steps configuration object
@@ -133,10 +133,12 @@ export const Default: StoryObj< typeof ColorGen > = {
133
133
  fgName,
134
134
  fgColor,
135
135
  unmetContrast,
136
+ achievedContrast,
136
137
  },
137
138
  i
138
139
  ) => (
139
140
  <li key={ i }>
141
+ { fgName } (
140
142
  <span
141
143
  style={ {
142
144
  width: 20,
@@ -144,8 +146,8 @@ export const Default: StoryObj< typeof ColorGen > = {
144
146
  backgroundColor: fgColor,
145
147
  display: 'inline-block',
146
148
  } }
147
- ></span>
148
- { fgName } over
149
+ />
150
+ { fgColor }) over { bgName } (
149
151
  <span
150
152
  style={ {
151
153
  width: 20,
@@ -153,8 +155,9 @@ export const Default: StoryObj< typeof ColorGen > = {
153
155
  backgroundColor: bgColor,
154
156
  display: 'inline-block',
155
157
  } }
156
- ></span>
157
- { bgName } did not meet { unmetContrast }
158
+ />
159
+ { bgColor }) did not meet { unmetContrast },
160
+ achieved just { achievedContrast }
158
161
  </li>
159
162
  )
160
163
  ) }