@wordpress/theme 0.1.0 → 0.2.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.
- package/README.md +69 -9
- package/bin/generate-default-ramps/index.ts +49 -0
- package/bin/generate-primitive-tokens/index.ts +14 -9
- package/bin/terrazzo-plugin-ds-tokens-docs/index.ts +5 -24
- package/bin/terrazzo-plugin-figma-ds-token-manager/index.ts +11 -4
- package/bin/terrazzo-plugin-inline-alias-values/index.ts +84 -0
- package/bin/terrazzo-plugin-known-wpds-css-variables/index.ts +19 -39
- package/build/color-ramps/index.js +21 -39
- package/build/color-ramps/index.js.map +3 -3
- package/build/color-ramps/lib/color-utils.js +39 -0
- package/build/color-ramps/lib/color-utils.js.map +7 -0
- package/build/color-ramps/lib/constants.js +20 -27
- package/build/color-ramps/lib/constants.js.map +3 -3
- package/build/color-ramps/lib/default-ramps.js +220 -0
- package/build/color-ramps/lib/default-ramps.js.map +7 -0
- package/build/color-ramps/lib/find-color-with-constraints.js +60 -91
- package/build/color-ramps/lib/find-color-with-constraints.js.map +3 -3
- package/build/color-ramps/lib/index.js +77 -119
- package/build/color-ramps/lib/index.js.map +3 -3
- package/build/color-ramps/lib/ramp-configs.js +15 -14
- package/build/color-ramps/lib/ramp-configs.js.map +2 -2
- package/build/color-ramps/lib/register-color-spaces.js +7 -0
- package/build/color-ramps/lib/register-color-spaces.js.map +7 -0
- package/build/color-ramps/lib/taper-chroma.js +35 -27
- package/build/color-ramps/lib/taper-chroma.js.map +3 -3
- package/build/color-ramps/lib/types.js +2 -1
- package/build/color-ramps/lib/types.js.map +1 -1
- package/build/color-ramps/lib/utils.js +75 -11
- package/build/color-ramps/lib/utils.js.map +2 -2
- package/build/context.js +3 -2
- package/build/context.js.map +1 -1
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/lock-unlock.js +3 -2
- package/build/lock-unlock.js.map +1 -1
- package/build/prebuilt/js/design-tokens.js +19 -11
- package/build/prebuilt/js/design-tokens.js.map +2 -2
- package/build/prebuilt/json/figma.json +165 -783
- package/build/prebuilt/ts/color-tokens.js +137 -0
- package/build/prebuilt/ts/color-tokens.js.map +7 -0
- package/build/private-apis.js +3 -2
- package/build/private-apis.js.map +1 -1
- package/build/theme-provider.js +19 -17
- package/build/theme-provider.js.map +4 -4
- package/build/token-id.js +30 -0
- package/build/token-id.js.map +7 -0
- package/build/types/css-modules.d.js +0 -1
- package/build/types.js +2 -1
- package/build/types.js.map +1 -1
- package/build/use-theme-provider-styles.js +67 -62
- package/build/use-theme-provider-styles.js.map +3 -3
- package/build-module/color-ramps/index.js +20 -28
- package/build-module/color-ramps/index.js.map +2 -2
- package/build-module/color-ramps/lib/color-utils.js +19 -0
- package/build-module/color-ramps/lib/color-utils.js.map +7 -0
- package/build-module/color-ramps/lib/constants.js +14 -11
- package/build-module/color-ramps/lib/constants.js.map +2 -2
- package/build-module/color-ramps/lib/default-ramps.js +196 -0
- package/build-module/color-ramps/lib/default-ramps.js.map +7 -0
- package/build-module/color-ramps/lib/find-color-with-constraints.js +61 -87
- package/build-module/color-ramps/lib/find-color-with-constraints.js.map +2 -2
- package/build-module/color-ramps/lib/index.js +85 -109
- package/build-module/color-ramps/lib/index.js.map +3 -3
- package/build-module/color-ramps/lib/ramp-configs.js +14 -13
- package/build-module/color-ramps/lib/ramp-configs.js.map +2 -2
- package/build-module/color-ramps/lib/register-color-spaces.js +7 -0
- package/build-module/color-ramps/lib/register-color-spaces.js.map +7 -0
- package/build-module/color-ramps/lib/taper-chroma.js +40 -16
- package/build-module/color-ramps/lib/taper-chroma.js.map +2 -2
- package/build-module/color-ramps/lib/utils.js +70 -6
- package/build-module/color-ramps/lib/utils.js.map +2 -2
- package/build-module/context.js +2 -1
- package/build-module/context.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/lock-unlock.js +2 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/prebuilt/js/design-tokens.js +18 -10
- package/build-module/prebuilt/js/design-tokens.js.map +2 -2
- package/build-module/prebuilt/json/figma.json +165 -783
- package/build-module/prebuilt/ts/color-tokens.js +117 -0
- package/build-module/prebuilt/ts/color-tokens.js.map +7 -0
- package/build-module/private-apis.js +2 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/theme-provider.js +18 -6
- package/build-module/theme-provider.js.map +3 -3
- package/build-module/token-id.js +6 -0
- package/build-module/token-id.js.map +7 -0
- package/build-module/use-theme-provider-styles.js +69 -57
- package/build-module/use-theme-provider-styles.js.map +2 -2
- package/build-types/color-ramps/index.d.ts +9 -16
- package/build-types/color-ramps/index.d.ts.map +1 -1
- package/build-types/color-ramps/lib/color-utils.d.ts +22 -0
- package/build-types/color-ramps/lib/color-utils.d.ts.map +1 -0
- package/build-types/color-ramps/lib/constants.d.ts +7 -9
- package/build-types/color-ramps/lib/constants.d.ts.map +1 -1
- package/build-types/color-ramps/lib/default-ramps.d.ts +7 -0
- package/build-types/color-ramps/lib/default-ramps.d.ts.map +1 -0
- package/build-types/color-ramps/lib/find-color-with-constraints.d.ts +8 -7
- package/build-types/color-ramps/lib/find-color-with-constraints.d.ts.map +1 -1
- package/build-types/color-ramps/lib/index.d.ts +5 -2
- package/build-types/color-ramps/lib/index.d.ts.map +1 -1
- package/build-types/color-ramps/lib/register-color-spaces.d.ts +2 -0
- package/build-types/color-ramps/lib/register-color-spaces.d.ts.map +1 -0
- package/build-types/color-ramps/lib/taper-chroma.d.ts +7 -3
- package/build-types/color-ramps/lib/taper-chroma.d.ts.map +1 -1
- package/build-types/color-ramps/lib/utils.d.ts +28 -5
- package/build-types/color-ramps/lib/utils.d.ts.map +1 -1
- package/build-types/color-ramps/stories/index.story.d.ts.map +1 -1
- package/build-types/prebuilt/ts/color-tokens.d.ts +7 -0
- package/build-types/prebuilt/ts/color-tokens.d.ts.map +1 -0
- package/build-types/stories/index.story.d.ts.map +1 -1
- package/build-types/theme-provider.d.ts.map +1 -1
- package/build-types/token-id.d.ts +9 -0
- package/build-types/token-id.d.ts.map +1 -0
- package/build-types/use-theme-provider-styles.d.ts +4 -0
- package/build-types/use-theme-provider-styles.d.ts.map +1 -1
- package/docs/ds-tokens.md +22 -156
- package/package.json +19 -9
- package/src/color-ramps/index.ts +24 -41
- package/src/color-ramps/lib/color-utils.ts +34 -0
- package/src/color-ramps/lib/constants.ts +13 -9
- package/src/color-ramps/lib/default-ramps.ts +200 -0
- package/src/color-ramps/lib/find-color-with-constraints.ts +83 -116
- package/src/color-ramps/lib/index.ts +107 -145
- package/src/color-ramps/lib/ramp-configs.ts +3 -3
- package/src/color-ramps/lib/register-color-spaces.ts +13 -0
- package/src/color-ramps/lib/taper-chroma.ts +47 -19
- package/src/color-ramps/lib/utils.ts +117 -14
- package/src/color-ramps/stories/index.story.tsx +16 -22
- package/src/color-ramps/test/__snapshots__/index.test.ts.snap +45722 -376
- package/src/color-ramps/test/index.test.ts +68 -29
- package/src/prebuilt/css/design-tokens.css +88 -355
- package/src/prebuilt/js/design-tokens.js +17 -10
- package/src/prebuilt/json/figma.json +165 -783
- package/src/prebuilt/ts/color-tokens.ts +117 -0
- package/src/stories/index.story.tsx +4 -18
- package/src/test/token-id.test.ts +12 -0
- package/src/token-id.ts +9 -0
- package/src/use-theme-provider-styles.ts +67 -60
- package/terrazzo.config.ts +15 -12
- package/tokens/color.json +221 -69
- package/tokens/dimension.json +75 -0
- package/tsconfig.bin.json +13 -0
- package/tsconfig.bin.tsbuildinfo +1 -0
- package/tsconfig.json +6 -4
- package/tsconfig.src.json +9 -0
- package/tsconfig.src.tsbuildinfo +1 -0
- package/bin/build-tokens.js +0 -83
- package/build/color-ramps/lib/cache-utils.js +0 -57
- package/build/color-ramps/lib/cache-utils.js.map +0 -7
- package/build/prebuilt/ts/design-tokens.js +0 -354
- package/build/prebuilt/ts/design-tokens.js.map +0 -7
- package/build/style.module.css.js +0 -2
- package/build-module/color-ramps/lib/cache-utils.js +0 -31
- package/build-module/color-ramps/lib/cache-utils.js.map +0 -7
- package/build-module/prebuilt/ts/design-tokens.js +0 -334
- package/build-module/prebuilt/ts/design-tokens.js.map +0 -7
- package/build-module/style.module.css.js +0 -1
- package/build-style/style.css +0 -3
- package/build-types/color-ramps/lib/cache-utils.d.ts +0 -22
- package/build-types/color-ramps/lib/cache-utils.d.ts.map +0 -1
- package/build-types/prebuilt/ts/design-tokens.d.ts +0 -7
- package/build-types/prebuilt/ts/design-tokens.d.ts.map +0 -1
- package/src/color-ramps/lib/cache-utils.ts +0 -56
- package/src/prebuilt/ts/design-tokens.ts +0 -335
- package/tokens/spacing.json +0 -45
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// packages/theme/src/prebuilt/ts/color-tokens.ts
|
|
2
|
+
var color_tokens_default = {
|
|
3
|
+
"primary-bgFill1": ["bg-interactive-brand-strong"],
|
|
4
|
+
"primary-fgFill": [
|
|
5
|
+
"fg-interactive-brand-strong-active",
|
|
6
|
+
"fg-interactive-brand-strong"
|
|
7
|
+
],
|
|
8
|
+
"primary-bgFill2": ["bg-interactive-brand-strong-active"],
|
|
9
|
+
"primary-surface2": ["bg-interactive-brand-active"],
|
|
10
|
+
"primary-surface4": ["bg-interactive-brand-weak-active"],
|
|
11
|
+
"primary-fgSurface3": [
|
|
12
|
+
"fg-interactive-brand-active",
|
|
13
|
+
"fg-interactive-brand"
|
|
14
|
+
],
|
|
15
|
+
"primary-stroke3": [
|
|
16
|
+
"bg-thumb-brand-active",
|
|
17
|
+
"bg-thumb-brand",
|
|
18
|
+
"stroke-focus-brand",
|
|
19
|
+
"stroke-interactive-brand",
|
|
20
|
+
"stroke-surface-brand-strong"
|
|
21
|
+
],
|
|
22
|
+
"primary-stroke4": ["stroke-interactive-brand-active"],
|
|
23
|
+
"primary-stroke1": ["stroke-surface-brand"],
|
|
24
|
+
"primary-surface1": ["bg-surface-brand"],
|
|
25
|
+
"info-surface2": ["bg-surface-info-weak"],
|
|
26
|
+
"info-surface4": ["bg-surface-info"],
|
|
27
|
+
"info-fgSurface4": ["fg-content-info"],
|
|
28
|
+
"info-fgSurface3": ["fg-content-info-weak"],
|
|
29
|
+
"info-stroke3": ["stroke-surface-info-strong"],
|
|
30
|
+
"info-stroke1": ["stroke-surface-info"],
|
|
31
|
+
"success-surface2": ["bg-surface-success-weak"],
|
|
32
|
+
"success-surface4": ["bg-surface-success"],
|
|
33
|
+
"success-fgSurface4": ["fg-content-success"],
|
|
34
|
+
"success-fgSurface3": ["fg-content-success-weak"],
|
|
35
|
+
"success-stroke3": ["stroke-surface-success-strong"],
|
|
36
|
+
"success-stroke1": ["stroke-surface-success"],
|
|
37
|
+
"warning-surface2": ["bg-surface-warning-weak"],
|
|
38
|
+
"warning-surface4": ["bg-surface-warning"],
|
|
39
|
+
"warning-fgSurface4": ["fg-content-warning"],
|
|
40
|
+
"warning-fgSurface3": ["fg-content-warning-weak"],
|
|
41
|
+
"warning-stroke3": ["stroke-surface-warning-strong"],
|
|
42
|
+
"warning-stroke1": ["stroke-surface-warning"],
|
|
43
|
+
"error-surface2": ["bg-surface-error-weak"],
|
|
44
|
+
"error-surface4": ["bg-surface-error"],
|
|
45
|
+
"error-fgSurface4": ["fg-content-error"],
|
|
46
|
+
"error-fgSurface3": ["fg-content-error-weak"],
|
|
47
|
+
"error-stroke3": [
|
|
48
|
+
"stroke-interactive-error-strong",
|
|
49
|
+
"stroke-surface-error-strong"
|
|
50
|
+
],
|
|
51
|
+
"error-stroke1": ["stroke-surface-error"],
|
|
52
|
+
"bg-surface2": ["bg-surface-neutral"],
|
|
53
|
+
"bg-surface6": [
|
|
54
|
+
"bg-interactive-brand-strong-disabled",
|
|
55
|
+
"bg-interactive-neutral-strong-disabled"
|
|
56
|
+
],
|
|
57
|
+
"bg-surface5": [
|
|
58
|
+
"bg-interactive-brand-disabled",
|
|
59
|
+
"bg-interactive-brand-weak-disabled",
|
|
60
|
+
"bg-interactive-neutral-disabled",
|
|
61
|
+
"bg-interactive-neutral-weak-disabled"
|
|
62
|
+
],
|
|
63
|
+
"bg-surface4": [
|
|
64
|
+
"bg-interactive-neutral-active",
|
|
65
|
+
"bg-interactive-neutral-weak-active"
|
|
66
|
+
],
|
|
67
|
+
"bg-surface3": ["bg-surface-neutral-strong"],
|
|
68
|
+
"bg-fgSurface4": [
|
|
69
|
+
"fg-content-neutral",
|
|
70
|
+
"fg-interactive-neutral-active",
|
|
71
|
+
"fg-interactive-neutral"
|
|
72
|
+
],
|
|
73
|
+
"bg-fgSurface3": [
|
|
74
|
+
"fg-content-neutral-weak",
|
|
75
|
+
"fg-interactive-brand-strong-disabled",
|
|
76
|
+
"fg-interactive-neutral-strong-disabled",
|
|
77
|
+
"fg-interactive-neutral-weak"
|
|
78
|
+
],
|
|
79
|
+
"bg-fgSurface2": [
|
|
80
|
+
"fg-interactive-brand-disabled",
|
|
81
|
+
"fg-interactive-neutral-disabled",
|
|
82
|
+
"fg-interactive-neutral-weak-disabled"
|
|
83
|
+
],
|
|
84
|
+
"bg-stroke3": [
|
|
85
|
+
"bg-thumb-neutral-weak",
|
|
86
|
+
"stroke-interactive-neutral",
|
|
87
|
+
"stroke-surface-neutral-strong"
|
|
88
|
+
],
|
|
89
|
+
"bg-stroke4": [
|
|
90
|
+
"bg-thumb-neutral-weak-active",
|
|
91
|
+
"stroke-interactive-neutral-active",
|
|
92
|
+
"stroke-interactive-neutral-strong"
|
|
93
|
+
],
|
|
94
|
+
"bg-stroke2": [
|
|
95
|
+
"bg-thumb-brand-disabled",
|
|
96
|
+
"bg-track-neutral",
|
|
97
|
+
"stroke-interactive-brand-disabled",
|
|
98
|
+
"stroke-interactive-neutral-disabled",
|
|
99
|
+
"stroke-surface-neutral"
|
|
100
|
+
],
|
|
101
|
+
"bg-stroke1": ["bg-track-neutral-weak", "stroke-surface-neutral-weak"],
|
|
102
|
+
"bg-bgFillInverted2": ["bg-interactive-neutral-strong-active"],
|
|
103
|
+
"bg-bgFillInverted1": ["bg-interactive-neutral-strong"],
|
|
104
|
+
"bg-fgFillInverted": [
|
|
105
|
+
"fg-interactive-neutral-strong-active",
|
|
106
|
+
"fg-interactive-neutral-strong"
|
|
107
|
+
],
|
|
108
|
+
"bg-surface1": ["bg-surface-neutral-weak"],
|
|
109
|
+
"caution-surface2": ["bg-surface-caution-weak"],
|
|
110
|
+
"caution-surface4": ["bg-surface-caution"],
|
|
111
|
+
"caution-fgSurface4": ["fg-content-caution"],
|
|
112
|
+
"caution-fgSurface3": ["fg-content-caution-weak"]
|
|
113
|
+
};
|
|
114
|
+
export {
|
|
115
|
+
color_tokens_default as default
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=color-tokens.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/prebuilt/ts/color-tokens.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * This file is generated by the @wordpress/terrazzo-plugin-inline-alias-values plugin.\n * Do not edit this file directly.\n */\n\nexport default {\n\t'primary-bgFill1': [ 'bg-interactive-brand-strong' ],\n\t'primary-fgFill': [\n\t\t'fg-interactive-brand-strong-active',\n\t\t'fg-interactive-brand-strong',\n\t],\n\t'primary-bgFill2': [ 'bg-interactive-brand-strong-active' ],\n\t'primary-surface2': [ 'bg-interactive-brand-active' ],\n\t'primary-surface4': [ 'bg-interactive-brand-weak-active' ],\n\t'primary-fgSurface3': [\n\t\t'fg-interactive-brand-active',\n\t\t'fg-interactive-brand',\n\t],\n\t'primary-stroke3': [\n\t\t'bg-thumb-brand-active',\n\t\t'bg-thumb-brand',\n\t\t'stroke-focus-brand',\n\t\t'stroke-interactive-brand',\n\t\t'stroke-surface-brand-strong',\n\t],\n\t'primary-stroke4': [ 'stroke-interactive-brand-active' ],\n\t'primary-stroke1': [ 'stroke-surface-brand' ],\n\t'primary-surface1': [ 'bg-surface-brand' ],\n\t'info-surface2': [ 'bg-surface-info-weak' ],\n\t'info-surface4': [ 'bg-surface-info' ],\n\t'info-fgSurface4': [ 'fg-content-info' ],\n\t'info-fgSurface3': [ 'fg-content-info-weak' ],\n\t'info-stroke3': [ 'stroke-surface-info-strong' ],\n\t'info-stroke1': [ 'stroke-surface-info' ],\n\t'success-surface2': [ 'bg-surface-success-weak' ],\n\t'success-surface4': [ 'bg-surface-success' ],\n\t'success-fgSurface4': [ 'fg-content-success' ],\n\t'success-fgSurface3': [ 'fg-content-success-weak' ],\n\t'success-stroke3': [ 'stroke-surface-success-strong' ],\n\t'success-stroke1': [ 'stroke-surface-success' ],\n\t'warning-surface2': [ 'bg-surface-warning-weak' ],\n\t'warning-surface4': [ 'bg-surface-warning' ],\n\t'warning-fgSurface4': [ 'fg-content-warning' ],\n\t'warning-fgSurface3': [ 'fg-content-warning-weak' ],\n\t'warning-stroke3': [ 'stroke-surface-warning-strong' ],\n\t'warning-stroke1': [ 'stroke-surface-warning' ],\n\t'error-surface2': [ 'bg-surface-error-weak' ],\n\t'error-surface4': [ 'bg-surface-error' ],\n\t'error-fgSurface4': [ 'fg-content-error' ],\n\t'error-fgSurface3': [ 'fg-content-error-weak' ],\n\t'error-stroke3': [\n\t\t'stroke-interactive-error-strong',\n\t\t'stroke-surface-error-strong',\n\t],\n\t'error-stroke1': [ 'stroke-surface-error' ],\n\t'bg-surface2': [ 'bg-surface-neutral' ],\n\t'bg-surface6': [\n\t\t'bg-interactive-brand-strong-disabled',\n\t\t'bg-interactive-neutral-strong-disabled',\n\t],\n\t'bg-surface5': [\n\t\t'bg-interactive-brand-disabled',\n\t\t'bg-interactive-brand-weak-disabled',\n\t\t'bg-interactive-neutral-disabled',\n\t\t'bg-interactive-neutral-weak-disabled',\n\t],\n\t'bg-surface4': [\n\t\t'bg-interactive-neutral-active',\n\t\t'bg-interactive-neutral-weak-active',\n\t],\n\t'bg-surface3': [ 'bg-surface-neutral-strong' ],\n\t'bg-fgSurface4': [\n\t\t'fg-content-neutral',\n\t\t'fg-interactive-neutral-active',\n\t\t'fg-interactive-neutral',\n\t],\n\t'bg-fgSurface3': [\n\t\t'fg-content-neutral-weak',\n\t\t'fg-interactive-brand-strong-disabled',\n\t\t'fg-interactive-neutral-strong-disabled',\n\t\t'fg-interactive-neutral-weak',\n\t],\n\t'bg-fgSurface2': [\n\t\t'fg-interactive-brand-disabled',\n\t\t'fg-interactive-neutral-disabled',\n\t\t'fg-interactive-neutral-weak-disabled',\n\t],\n\t'bg-stroke3': [\n\t\t'bg-thumb-neutral-weak',\n\t\t'stroke-interactive-neutral',\n\t\t'stroke-surface-neutral-strong',\n\t],\n\t'bg-stroke4': [\n\t\t'bg-thumb-neutral-weak-active',\n\t\t'stroke-interactive-neutral-active',\n\t\t'stroke-interactive-neutral-strong',\n\t],\n\t'bg-stroke2': [\n\t\t'bg-thumb-brand-disabled',\n\t\t'bg-track-neutral',\n\t\t'stroke-interactive-brand-disabled',\n\t\t'stroke-interactive-neutral-disabled',\n\t\t'stroke-surface-neutral',\n\t],\n\t'bg-stroke1': [ 'bg-track-neutral-weak', 'stroke-surface-neutral-weak' ],\n\t'bg-bgFillInverted2': [ 'bg-interactive-neutral-strong-active' ],\n\t'bg-bgFillInverted1': [ 'bg-interactive-neutral-strong' ],\n\t'bg-fgFillInverted': [\n\t\t'fg-interactive-neutral-strong-active',\n\t\t'fg-interactive-neutral-strong',\n\t],\n\t'bg-surface1': [ 'bg-surface-neutral-weak' ],\n\t'caution-surface2': [ 'bg-surface-caution-weak' ],\n\t'caution-surface4': [ 'bg-surface-caution' ],\n\t'caution-fgSurface4': [ 'fg-content-caution' ],\n\t'caution-fgSurface3': [ 'fg-content-caution-weak' ],\n} as Record< string, string[] >;\n"],
|
|
5
|
+
"mappings": ";AAKA,IAAO,uBAAQ;AAAA,EACd,mBAAmB,CAAE,6BAA8B;AAAA,EACnD,kBAAkB;AAAA,IACjB;AAAA,IACA;AAAA,EACD;AAAA,EACA,mBAAmB,CAAE,oCAAqC;AAAA,EAC1D,oBAAoB,CAAE,6BAA8B;AAAA,EACpD,oBAAoB,CAAE,kCAAmC;AA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;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACA,eAAe;AAAA,IACd;AAAA,IACA;AAAA,EACD;AAAA,EACA,eAAe,CAAE,2BAA4B;AAAA,EAC7C,iBAAiB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACA,iBAAiB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACA,iBAAiB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACA,cAAc;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACA,cAAc;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACA,cAAc;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACA,cAAc,CAAE,yBAAyB,6BAA8B;AAAA,EACvE,sBAAsB,CAAE,sCAAuC;AAAA,EAC/D,sBAAsB,CAAE,+BAAgC;AAAA,EACxD,qBAAqB;AAAA,IACpB;AAAA,IACA;AAAA,EACD;AAAA,EACA,eAAe,CAAE,yBAA0B;AAAA,EAC3C,oBAAoB,CAAE,yBAA0B;AAAA,EAChD,oBAAoB,CAAE,oBAAqB;AAAA,EAC3C,sBAAsB,CAAE,oBAAqB;AAAA,EAC7C,sBAAsB,CAAE,yBAA0B;AACnD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
// packages/theme/src/private-apis.ts
|
|
1
2
|
import { lock } from "./lock-unlock";
|
|
2
3
|
import { ThemeProvider } from "./theme-provider";
|
|
3
4
|
import { useThemeProviderStyles } from "./use-theme-provider-styles";
|
|
4
|
-
|
|
5
|
+
var privateApis = {};
|
|
5
6
|
lock(privateApis, {
|
|
6
7
|
ThemeProvider,
|
|
7
8
|
useThemeProviderStyles
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/private-apis.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { lock } from './lock-unlock';\nimport { ThemeProvider } from './theme-provider';\nimport { useThemeProviderStyles } from './use-theme-provider-styles';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tThemeProvider,\n\tuseThemeProviderStyles,\n} );\n"],
|
|
5
|
-
"mappings": "AAGA,SAAS,YAAY;AACrB,SAAS,qBAAqB;AAC9B,SAAS,8BAA8B;AAEhC,
|
|
5
|
+
"mappings": ";AAGA,SAAS,YAAY;AACrB,SAAS,qBAAqB;AAC9B,SAAS,8BAA8B;AAEhC,IAAM,cAAc,CAAC;AAC5B,KAAM,aAAa;AAAA,EAClB;AAAA,EACA;AACD,CAAE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
// packages/theme/src/theme-provider.tsx
|
|
2
2
|
import { useMemo, useId } from "@wordpress/element";
|
|
3
3
|
import { ThemeContext } from "./context";
|
|
4
4
|
import { useThemeProviderStyles } from "./use-theme-provider-styles";
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
// packages/theme/src/style.module.css
|
|
7
|
+
var css = `.style-module__root__26kw6 {
|
|
8
|
+
display: contents;
|
|
9
|
+
}
|
|
10
|
+
`;
|
|
11
|
+
document.head.appendChild(document.createElement("style")).appendChild(document.createTextNode(css));
|
|
12
|
+
var style_default = {
|
|
13
|
+
"root": "style-module__root__26kw6"
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// packages/theme/src/theme-provider.tsx
|
|
17
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
18
|
function cssObjectToText(values) {
|
|
7
19
|
return Object.entries(values).map(([key, value]) => `${key}: ${value};`).join("");
|
|
8
20
|
}
|
|
@@ -15,13 +27,13 @@ function generateCSSSelector({
|
|
|
15
27
|
const selectors = [];
|
|
16
28
|
if (isRoot) {
|
|
17
29
|
selectors.push(
|
|
18
|
-
`:root:has(.${
|
|
30
|
+
`:root:has(.${style_default.root}${rootSel}${instanceIdSel})`
|
|
19
31
|
);
|
|
20
32
|
}
|
|
21
|
-
selectors.push(`.${
|
|
33
|
+
selectors.push(`.${style_default.root}.${style_default.root}${instanceIdSel}`);
|
|
22
34
|
return selectors.join(",");
|
|
23
35
|
}
|
|
24
|
-
|
|
36
|
+
var ThemeProvider = ({
|
|
25
37
|
children,
|
|
26
38
|
color = {},
|
|
27
39
|
isRoot = false
|
|
@@ -46,7 +58,7 @@ const ThemeProvider = ({
|
|
|
46
58
|
{
|
|
47
59
|
"data-wpds-theme-provider-id": instanceId,
|
|
48
60
|
"data-wpds-root-provider": isRoot,
|
|
49
|
-
className:
|
|
61
|
+
className: style_default.root,
|
|
50
62
|
children: /* @__PURE__ */ jsx(ThemeContext.Provider, { value: contextValue, children })
|
|
51
63
|
}
|
|
52
64
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/theme-provider.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useId } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ThemeContext } from './context';\nimport { useThemeProviderStyles } from './use-theme-provider-styles';\nimport { type ThemeProviderProps } from './types';\nimport styles from './style.module.css';\n\nfunction cssObjectToText( values: CSSProperties ) {\n\treturn Object.entries( values )\n\t\t.map( ( [ key, value ] ) => `${ key }: ${ value };` )\n\t\t.join( '' );\n}\n\nfunction generateCSSSelector( {\n\tinstanceId,\n\tisRoot,\n}: {\n\tinstanceId: string;\n\tisRoot: boolean;\n} ) {\n\tconst rootSel = `[data-wpds-root-provider=\"true\"]`;\n\tconst instanceIdSel = `[data-wpds-theme-provider-id=\"${ instanceId }\"]`;\n\n\tconst selectors = [];\n\n\tif ( isRoot ) {\n\t\tselectors.push(\n\t\t\t`:root:has(.${ styles.root }${ rootSel }${ instanceIdSel })`\n\t\t);\n\t}\n\n\tselectors.push( `.${ styles.root }.${ styles.root }${ instanceIdSel }` );\n\n\treturn selectors.join( ',' );\n}\n\nexport const ThemeProvider = ( {\n\tchildren,\n\tcolor = {},\n\tisRoot = false,\n}: ThemeProviderProps ) => {\n\tconst instanceId = useId();\n\n\tconst { themeProviderStyles, resolvedSettings } = useThemeProviderStyles( {\n\t\tcolor,\n\t} );\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tresolvedSettings,\n\t\t} ),\n\t\t[ resolvedSettings ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ themeProviderStyles ? (\n\t\t\t\t<style>\n\t\t\t\t\t{ `${ generateCSSSelector( {\n\t\t\t\t\t\tinstanceId,\n\t\t\t\t\t\tisRoot,\n\t\t\t\t\t} ) } {${ cssObjectToText( themeProviderStyles ) }}` }\n\t\t\t\t</style>\n\t\t\t) : null }\n\t\t\t<div\n\t\t\t\tdata-wpds-theme-provider-id={ instanceId }\n\t\t\t\tdata-wpds-root-provider={ isRoot }\n\t\t\t\tclassName={ styles.root }\n\t\t\t>\n\t\t\t\t<ThemeContext.Provider value={ contextValue }>\n\t\t\t\t\t{ children }\n\t\t\t\t</ThemeContext.Provider>\n\t\t\t</div>\n\t\t</>\n\t);\n};\n"],
|
|
5
|
-
"mappings": "
|
|
3
|
+
"sources": ["../src/theme-provider.tsx", "../src/style.module.css"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useId } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ThemeContext } from './context';\nimport { useThemeProviderStyles } from './use-theme-provider-styles';\nimport { type ThemeProviderProps } from './types';\nimport styles from './style.module.css';\n\nfunction cssObjectToText( values: CSSProperties ) {\n\treturn Object.entries( values )\n\t\t.map( ( [ key, value ] ) => `${ key }: ${ value };` )\n\t\t.join( '' );\n}\n\nfunction generateCSSSelector( {\n\tinstanceId,\n\tisRoot,\n}: {\n\tinstanceId: string;\n\tisRoot: boolean;\n} ) {\n\tconst rootSel = `[data-wpds-root-provider=\"true\"]`;\n\tconst instanceIdSel = `[data-wpds-theme-provider-id=\"${ instanceId }\"]`;\n\n\tconst selectors = [];\n\n\tif ( isRoot ) {\n\t\tselectors.push(\n\t\t\t`:root:has(.${ styles.root }${ rootSel }${ instanceIdSel })`\n\t\t);\n\t}\n\n\tselectors.push( `.${ styles.root }.${ styles.root }${ instanceIdSel }` );\n\n\treturn selectors.join( ',' );\n}\n\nexport const ThemeProvider = ( {\n\tchildren,\n\tcolor = {},\n\tisRoot = false,\n}: ThemeProviderProps ) => {\n\tconst instanceId = useId();\n\n\tconst { themeProviderStyles, resolvedSettings } = useThemeProviderStyles( {\n\t\tcolor,\n\t} );\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tresolvedSettings,\n\t\t} ),\n\t\t[ resolvedSettings ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ themeProviderStyles ? (\n\t\t\t\t<style>\n\t\t\t\t\t{ `${ generateCSSSelector( {\n\t\t\t\t\t\tinstanceId,\n\t\t\t\t\t\tisRoot,\n\t\t\t\t\t} ) } {${ cssObjectToText( themeProviderStyles ) }}` }\n\t\t\t\t</style>\n\t\t\t) : null }\n\t\t\t<div\n\t\t\t\tdata-wpds-theme-provider-id={ instanceId }\n\t\t\t\tdata-wpds-root-provider={ isRoot }\n\t\t\t\tclassName={ styles.root }\n\t\t\t>\n\t\t\t\t<ThemeContext.Provider value={ contextValue }>\n\t\t\t\t\t{ children }\n\t\t\t\t</ThemeContext.Provider>\n\t\t\t</div>\n\t\t</>\n\t);\n};\n", "const css = `.style-module__root__26kw6 {\n\tdisplay: contents;\n}\n`;\ndocument.head\n .appendChild(document.createElement(\"style\"))\n .appendChild(document.createTextNode(css));\nexport {css};\nexport default {\n \"root\": \"style-module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KAClD,IACG;AAAA,IACJ;AAAA,MAAC;AAAA;AAAA,QACA,+BAA8B;AAAA,QAC9B,2BAA0B;AAAA,QAC1B,WAAY,cAAO;AAAA,QAEnB,8BAAC,aAAa,UAAb,EAAsB,OAAQ,cAC5B,UACH;AAAA;AAAA,IACD;AAAA,KACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/token-id.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Normalizes a token ID by removing default states and visibility identifiers,\n * making it human-readable as a publicly-accessible variable name.\n *\n * @param id The token ID to normalize.\n * @return The normalized token ID.\n */\nexport const publicTokenId = ( id: string ) =>\n\tid.replace( /\\.(normal|resting|semantic|primitive)/g, '' );\n"],
|
|
5
|
+
"mappings": ";AAOO,IAAM,gBAAgB,CAAE,OAC9B,GAAG,QAAS,0CAA0C,EAAG;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,13 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
// packages/theme/src/use-theme-provider-styles.ts
|
|
2
|
+
import {
|
|
3
|
+
parse,
|
|
4
|
+
to,
|
|
5
|
+
get,
|
|
6
|
+
serialize,
|
|
7
|
+
sRGB,
|
|
8
|
+
HSL
|
|
9
|
+
} from "colorjs.io/fn";
|
|
10
|
+
import memoize from "memize";
|
|
2
11
|
import { useMemo, useContext } from "@wordpress/element";
|
|
12
|
+
import "./color-ramps/lib/register-color-spaces";
|
|
3
13
|
import { ThemeContext } from "./context";
|
|
4
|
-
import
|
|
14
|
+
import colorTokens from "./prebuilt/ts/color-tokens";
|
|
5
15
|
import {
|
|
6
16
|
buildBgRamp,
|
|
7
17
|
buildAccentRamp,
|
|
8
18
|
DEFAULT_SEED_COLORS
|
|
9
19
|
} from "./color-ramps";
|
|
10
|
-
|
|
20
|
+
var getCachedBgRamp = memoize(buildBgRamp, { maxSize: 10 });
|
|
21
|
+
var getCachedAccentRamp = memoize(buildAccentRamp, { maxSize: 10 });
|
|
22
|
+
var legacyWpComponentsOverridesCSS = [
|
|
11
23
|
["--wp-components-color-accent", "var(--wp-admin-theme-color)"],
|
|
12
24
|
[
|
|
13
25
|
"--wp-components-color-accent-darker-10",
|
|
@@ -63,37 +75,49 @@ const legacyWpComponentsOverridesCSS = [
|
|
|
63
75
|
]
|
|
64
76
|
];
|
|
65
77
|
function customRgbFormat(color) {
|
|
66
|
-
const rgb =
|
|
67
|
-
return [rgb.r, rgb.g, rgb.b].map((n) => Math.round(n * 255)).join(", ");
|
|
78
|
+
const rgb = to(color, sRGB);
|
|
79
|
+
return [get(rgb, "srgb.r"), get(rgb, "srgb.g"), get(rgb, "srgb.b")].map((n) => Math.round(n * 255)).join(", ");
|
|
68
80
|
}
|
|
69
81
|
function legacyWpAdminThemeOverridesCSS(accent) {
|
|
70
|
-
const parsedAccent =
|
|
71
|
-
const
|
|
72
|
-
const darker10 =
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
const parsedAccent = to(parse(accent), HSL);
|
|
83
|
+
const coords = parsedAccent.coords;
|
|
84
|
+
const darker10 = to(
|
|
85
|
+
{
|
|
86
|
+
space: HSL,
|
|
87
|
+
coords: [
|
|
88
|
+
coords[0],
|
|
89
|
+
// h
|
|
90
|
+
coords[1],
|
|
91
|
+
// s
|
|
92
|
+
Math.max(0, Math.min(100, coords[2] - 5))
|
|
93
|
+
// l (reduced by 5%)
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
sRGB
|
|
97
|
+
);
|
|
98
|
+
const darker20 = to(
|
|
99
|
+
{
|
|
100
|
+
space: HSL,
|
|
101
|
+
coords: [
|
|
102
|
+
coords[0],
|
|
103
|
+
// h
|
|
104
|
+
coords[1],
|
|
105
|
+
// s
|
|
106
|
+
Math.max(0, Math.min(100, coords[2] - 10))
|
|
107
|
+
// l (reduced by 10%)
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
sRGB
|
|
111
|
+
);
|
|
88
112
|
return [
|
|
89
113
|
[
|
|
90
114
|
"--wp-admin-theme-color",
|
|
91
|
-
|
|
115
|
+
serialize(to(parsedAccent, sRGB), { format: "hex" })
|
|
92
116
|
],
|
|
93
117
|
["--wp-admin-theme-color--rgb", customRgbFormat(parsedAccent)],
|
|
94
118
|
[
|
|
95
119
|
"--wp-admin-theme-color-darker-10",
|
|
96
|
-
darker10
|
|
120
|
+
serialize(darker10, { format: "hex" })
|
|
97
121
|
],
|
|
98
122
|
[
|
|
99
123
|
"--wp-admin-theme-color-darker-10--rgb",
|
|
@@ -101,7 +125,7 @@ function legacyWpAdminThemeOverridesCSS(accent) {
|
|
|
101
125
|
],
|
|
102
126
|
[
|
|
103
127
|
"--wp-admin-theme-color-darker-20",
|
|
104
|
-
darker20
|
|
128
|
+
serialize(darker20, { format: "hex" })
|
|
105
129
|
],
|
|
106
130
|
[
|
|
107
131
|
"--wp-admin-theme-color-darker-20--rgb",
|
|
@@ -109,23 +133,21 @@ function legacyWpAdminThemeOverridesCSS(accent) {
|
|
|
109
133
|
]
|
|
110
134
|
];
|
|
111
135
|
}
|
|
112
|
-
function
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
]
|
|
128
|
-
);
|
|
136
|
+
function colorTokensCSS(computedColorRamps) {
|
|
137
|
+
const entries = [];
|
|
138
|
+
for (const [rampName, { ramp }] of computedColorRamps) {
|
|
139
|
+
for (const [tokenName, tokenValue] of Object.entries(ramp)) {
|
|
140
|
+
const key = `${rampName}-${tokenName}`;
|
|
141
|
+
const aliasedBy = colorTokens[key] ?? [];
|
|
142
|
+
for (const aliasedId of aliasedBy) {
|
|
143
|
+
entries.push([
|
|
144
|
+
`--wpds-color-${aliasedId}`,
|
|
145
|
+
tokenValue.color
|
|
146
|
+
]);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return entries;
|
|
129
151
|
}
|
|
130
152
|
function generateStyles({
|
|
131
153
|
primary,
|
|
@@ -133,15 +155,8 @@ function generateStyles({
|
|
|
133
155
|
}) {
|
|
134
156
|
return Object.fromEntries(
|
|
135
157
|
[
|
|
136
|
-
//
|
|
137
|
-
|
|
138
|
-
colorRampCSS(
|
|
139
|
-
computedColorRamp,
|
|
140
|
-
`--wpds-color-private-${rampName}-`
|
|
141
|
-
)
|
|
142
|
-
]).flat(2),
|
|
143
|
-
// Semantic color tokens (other semantic tokens for now are static)
|
|
144
|
-
semanticTokensCSS(([key]) => /color/.test(key)),
|
|
158
|
+
// Semantic color tokens
|
|
159
|
+
colorTokensCSS(computedColorRamps),
|
|
145
160
|
// Legacy overrides
|
|
146
161
|
legacyWpAdminThemeOverridesCSS(primary),
|
|
147
162
|
legacyWpComponentsOverridesCSS
|
|
@@ -170,17 +185,14 @@ function useThemeProviderStyles({
|
|
|
170
185
|
primary
|
|
171
186
|
};
|
|
172
187
|
const computedColorRamps = /* @__PURE__ */ new Map();
|
|
173
|
-
const bgRamp =
|
|
188
|
+
const bgRamp = getCachedBgRamp(seeds.bg);
|
|
174
189
|
Object.entries(seeds).forEach(([rampName, seed]) => {
|
|
175
190
|
if (rampName === "bg") {
|
|
176
191
|
computedColorRamps.set(rampName, bgRamp);
|
|
177
192
|
} else {
|
|
178
193
|
computedColorRamps.set(
|
|
179
194
|
rampName,
|
|
180
|
-
|
|
181
|
-
seed,
|
|
182
|
-
bgRamp
|
|
183
|
-
})
|
|
195
|
+
getCachedAccentRamp(seed, bgRamp)
|
|
184
196
|
);
|
|
185
197
|
}
|
|
186
198
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/use-theme-provider-styles.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\nimport
|
|
5
|
-
"mappings": "AAIA,OAAO,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\nimport {\n\tparse,\n\tto,\n\tget,\n\tserialize,\n\tsRGB,\n\tHSL,\n\ttype ColorTypes,\n} from 'colorjs.io/fn';\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport './color-ramps/lib/register-color-spaces';\nimport { ThemeContext } from './context';\nimport colorTokens from './prebuilt/ts/color-tokens';\nimport {\n\tbuildBgRamp,\n\tbuildAccentRamp,\n\tDEFAULT_SEED_COLORS,\n\ttype RampResult,\n} from './color-ramps';\nimport type { ThemeProviderProps } from './types';\n\ntype Entry = [ string, string ];\n\nconst getCachedBgRamp = memoize( buildBgRamp, { maxSize: 10 } );\nconst getCachedAccentRamp = memoize( buildAccentRamp, { maxSize: 10 } );\n\nconst legacyWpComponentsOverridesCSS: Entry[] = [\n\t[ '--wp-components-color-accent', 'var(--wp-admin-theme-color)' ],\n\t[\n\t\t'--wp-components-color-accent-darker-10',\n\t\t'var(--wp-admin-theme-color-darker-10)',\n\t],\n\t[\n\t\t'--wp-components-color-accent-darker-20',\n\t\t'var(--wp-admin-theme-color-darker-20)',\n\t],\n\t[\n\t\t'--wp-components-color-accent-inverted',\n\t\t'var(--wpds-color-fg-interactive-brand-strong)',\n\t],\n\t[\n\t\t'--wp-components-color-background',\n\t\t'var(--wpds-color-bg-surface-neutral-strong)',\n\t],\n\t[\n\t\t'--wp-components-color-foreground',\n\t\t'var(--wpds-color-fg-content-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-foreground-inverted',\n\t\t'var(--wpds-color-bg-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-100',\n\t\t'var(--wpds-color-bg-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-200',\n\t\t'var(--wpds-color-stroke-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-300',\n\t\t'var(--wpds-color-stroke-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-400',\n\t\t'var(--wpds-color-stroke-interactive-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-600',\n\t\t'var(--wpds-color-stroke-interactive-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-700',\n\t\t'var(--wpds-color-fg-content-neutral-weak)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-800',\n\t\t'var(--wpds-color-fg-content-neutral)',\n\t],\n];\n\nfunction customRgbFormat( color: ColorTypes ) {\n\tconst rgb = to( color, sRGB );\n\treturn [ get( rgb, 'srgb.r' ), get( rgb, 'srgb.g' ), get( rgb, 'srgb.b' ) ]\n\t\t.map( ( n ) => Math.round( n * 255 ) )\n\t\t.join( ', ' );\n}\n\nfunction legacyWpAdminThemeOverridesCSS( accent: string ): Entry[] {\n\tconst parsedAccent = to( parse( accent ), HSL );\n\n\tconst coords = parsedAccent.coords;\n\tconst darker10 = to(\n\t\t{\n\t\t\tspace: HSL,\n\t\t\tcoords: [\n\t\t\t\tcoords[ 0 ], // h\n\t\t\t\tcoords[ 1 ], // s\n\t\t\t\tMath.max( 0, Math.min( 100, coords[ 2 ] - 5 ) ), // l (reduced by 5%)\n\t\t\t],\n\t\t},\n\t\tsRGB\n\t);\n\tconst darker20 = to(\n\t\t{\n\t\t\tspace: HSL,\n\t\t\tcoords: [\n\t\t\t\tcoords[ 0 ], // h\n\t\t\t\tcoords[ 1 ], // s\n\t\t\t\tMath.max( 0, Math.min( 100, coords[ 2 ] - 10 ) ), // l (reduced by 10%)\n\t\t\t],\n\t\t},\n\t\tsRGB\n\t);\n\n\treturn [\n\t\t[\n\t\t\t'--wp-admin-theme-color',\n\t\t\tserialize( to( parsedAccent, sRGB ), { format: 'hex' } ),\n\t\t],\n\t\t[ '--wp-admin-theme-color--rgb', customRgbFormat( parsedAccent ) ],\n\t\t[\n\t\t\t'--wp-admin-theme-color-darker-10',\n\t\t\tserialize( darker10, { format: 'hex' } ),\n\t\t],\n\t\t[\n\t\t\t'--wp-admin-theme-color-darker-10--rgb',\n\t\t\tcustomRgbFormat( darker10 ),\n\t\t],\n\t\t[\n\t\t\t'--wp-admin-theme-color-darker-20',\n\t\t\tserialize( darker20, { format: 'hex' } ),\n\t\t],\n\t\t[\n\t\t\t'--wp-admin-theme-color-darker-20--rgb',\n\t\t\tcustomRgbFormat( darker20 ),\n\t\t],\n\t];\n}\n\nfunction colorTokensCSS(\n\tcomputedColorRamps: Map< string, RampResult >\n): Entry[] {\n\tconst entries: Entry[] = [];\n\n\tfor ( const [ rampName, { ramp } ] of computedColorRamps ) {\n\t\tfor ( const [ tokenName, tokenValue ] of Object.entries( ramp ) ) {\n\t\t\tconst key = `${ rampName }-${ tokenName }`;\n\t\t\tconst aliasedBy = colorTokens[ key ] ?? [];\n\t\t\tfor ( const aliasedId of aliasedBy ) {\n\t\t\t\tentries.push( [\n\t\t\t\t\t`--wpds-color-${ aliasedId }`,\n\t\t\t\t\ttokenValue.color,\n\t\t\t\t] );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn entries;\n}\n\nfunction generateStyles( {\n\tprimary,\n\tcomputedColorRamps,\n}: {\n\tprimary: string;\n\tcomputedColorRamps: Map< string, RampResult >;\n} ): CSSProperties {\n\treturn Object.fromEntries(\n\t\t[\n\t\t\t// Semantic color tokens\n\t\t\tcolorTokensCSS( computedColorRamps ),\n\t\t\t// Legacy overrides\n\t\t\tlegacyWpAdminThemeOverridesCSS( primary ),\n\t\t\tlegacyWpComponentsOverridesCSS,\n\t\t].flat()\n\t);\n}\n\nexport function useThemeProviderStyles( {\n\tcolor = {},\n}: {\n\tcolor?: ThemeProviderProps[ 'color' ];\n} = {} ) {\n\tconst { resolvedSettings: inheritedSettings } = useContext( ThemeContext );\n\n\t// Compute settings:\n\t// - used provided prop value;\n\t// - otherwise, use inherited value from parent instance;\n\t// - otherwise, use fallback value (where applicable).\n\tconst primary =\n\t\tcolor.primary ??\n\t\tinheritedSettings.color?.primary ??\n\t\tDEFAULT_SEED_COLORS.primary;\n\tconst bg =\n\t\tcolor.bg ?? inheritedSettings.color?.bg ?? DEFAULT_SEED_COLORS.bg;\n\n\tconst resolvedSettings = useMemo(\n\t\t() => ( {\n\t\t\tcolor: {\n\t\t\t\tprimary,\n\t\t\t\tbg,\n\t\t\t},\n\t\t} ),\n\t\t[ primary, bg ]\n\t);\n\n\tconst themeProviderStyles = useMemo( () => {\n\t\t// Determine which seeds are needed for generating ramps.\n\t\tconst seeds = {\n\t\t\t...DEFAULT_SEED_COLORS,\n\t\t\tbg,\n\t\t\tprimary,\n\t\t};\n\n\t\t// Generate ramps.\n\t\tconst computedColorRamps = new Map< string, RampResult >();\n\t\tconst bgRamp = getCachedBgRamp( seeds.bg );\n\t\tObject.entries( seeds ).forEach( ( [ rampName, seed ] ) => {\n\t\t\tif ( rampName === 'bg' ) {\n\t\t\t\tcomputedColorRamps.set( rampName, bgRamp );\n\t\t\t} else {\n\t\t\t\tcomputedColorRamps.set(\n\t\t\t\t\trampName,\n\t\t\t\t\tgetCachedAccentRamp( seed, bgRamp )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn generateStyles( {\n\t\t\tprimary: seeds.primary,\n\t\t\tcomputedColorRamps,\n\t\t} );\n\t}, [ primary, bg ] );\n\n\treturn {\n\t\tresolvedSettings,\n\t\tthemeProviderStyles,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";AAIA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AACP,OAAO,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;AAEnB,SAAO;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,28 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import './lib/register-color-spaces';
|
|
1
5
|
import type { RampResult as InternalRampResult, Ramp } from './lib/types';
|
|
2
6
|
export { DEFAULT_SEED_COLORS } from './lib/constants';
|
|
3
7
|
/**
|
|
4
8
|
* Creates a background ramp.
|
|
5
|
-
* @param
|
|
6
|
-
* @param params.seed
|
|
7
|
-
* @param params.debug
|
|
9
|
+
* @param seed The seed color for the background ramp.
|
|
8
10
|
*/
|
|
9
|
-
export declare function buildBgRamp(
|
|
10
|
-
seed: string;
|
|
11
|
-
debug?: boolean;
|
|
12
|
-
}): InternalRampResult;
|
|
11
|
+
export declare function buildBgRamp(seed: string): InternalRampResult;
|
|
13
12
|
/**
|
|
14
13
|
* Creates an accent ramp (ie used by primary, success, info, warning and error
|
|
15
14
|
* ramps).
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
18
|
-
* @param params.bgRamp
|
|
19
|
-
* @param params.debug
|
|
15
|
+
* @param seed The seed color for the accent ramp.
|
|
16
|
+
* @param bgRamp The ramp of the background on which the accent is shown.
|
|
20
17
|
*/
|
|
21
|
-
export declare function buildAccentRamp(
|
|
22
|
-
seed: string;
|
|
23
|
-
bgRamp?: InternalRampResult;
|
|
24
|
-
debug?: boolean;
|
|
25
|
-
}): InternalRampResult;
|
|
18
|
+
export declare function buildAccentRamp(seed: string, bgRamp?: InternalRampResult): InternalRampResult;
|
|
26
19
|
/**
|
|
27
20
|
* Checks that all bg/fg combinations generated by the ramps meet contrast
|
|
28
21
|
* targets.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/color-ramps/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/color-ramps/index.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,6BAA6B,CAAC;AAIrC,OAAO,KAAK,EACX,UAAU,IAAI,kBAAkB,EAEhC,IAAI,EACJ,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;GAGG;AACH,wBAAgB,WAAW,CAAE,IAAI,EAAE,MAAM,sBAMxC;AAsBD;;;;;GAKG;AACH,wBAAgB,eAAe,CAC9B,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,kBAAkB,GACzB,kBAAkB,CAOpB;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAE,EAC5C,MAAM,EACN,WAAgB,GAChB,EAAE;IACF,MAAM,EAAE,kBAAkB,CAAC;IAC3B,WAAW,CAAC,EAAE,kBAAkB,EAAE,CAAC;CACnC;YAES,MAAM,IAAI;aACT,MAAM;YACP,MAAM,IAAI;aACT,MAAM;mBACA,MAAM;IA6CtB;AAED,MAAM,MAAM,UAAU,GAAG,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { type ColorTypes } from 'colorjs.io/fn';
|
|
5
|
+
/**
|
|
6
|
+
* Internal dependencies
|
|
7
|
+
*/
|
|
8
|
+
import './register-color-spaces';
|
|
9
|
+
/**
|
|
10
|
+
* Get string representation of a color
|
|
11
|
+
* @param color Color object to stringify
|
|
12
|
+
* @return String representation
|
|
13
|
+
*/
|
|
14
|
+
export declare function getColorString(color: ColorTypes): string;
|
|
15
|
+
/**
|
|
16
|
+
* Get contrast value between two colors
|
|
17
|
+
* @param colorA First color
|
|
18
|
+
* @param colorB Second color
|
|
19
|
+
* @return WCAG 2.1 contrast ratio
|
|
20
|
+
*/
|
|
21
|
+
export declare function getContrast(colorA: ColorTypes, colorB: ColorTypes): number;
|
|
22
|
+
//# sourceMappingURL=color-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-utils.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/color-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAKN,KAAK,UAAU,EACf,MAAM,eAAe,CAAC;AAEvB;;GAEG;AACH,OAAO,yBAAyB,CAAC;AAEjC;;;;GAIG;AACH,wBAAgB,cAAc,CAAE,KAAK,EAAE,UAAU,GAAI,MAAM,CAE1D;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,GAAI,MAAM,CAE5E"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import Color from 'colorjs.io';
|
|
5
1
|
/**
|
|
6
2
|
* Internal dependencies
|
|
7
3
|
*/
|
|
4
|
+
import './register-color-spaces';
|
|
8
5
|
import type { Ramp } from './types';
|
|
9
|
-
export declare const WHITE:
|
|
10
|
-
export declare const BLACK:
|
|
11
|
-
export declare const UNIVERSAL_CONTRAST_TOPUP = 0.
|
|
6
|
+
export declare const WHITE: import("colorjs.io/fn").PlainColorObject;
|
|
7
|
+
export declare const BLACK: import("colorjs.io/fn").PlainColorObject;
|
|
8
|
+
export declare const UNIVERSAL_CONTRAST_TOPUP = 0.012;
|
|
12
9
|
export declare const WHITE_TEXT_CONTRAST_MARGIN = 3.1;
|
|
13
10
|
export declare const ACCENT_SCALE_BASE_LIGHTNESS_THRESHOLDS: {
|
|
14
11
|
readonly lighter: {
|
|
@@ -20,8 +17,8 @@ export declare const ACCENT_SCALE_BASE_LIGHTNESS_THRESHOLDS: {
|
|
|
20
17
|
readonly max: 0.98;
|
|
21
18
|
};
|
|
22
19
|
};
|
|
23
|
-
export declare const
|
|
24
|
-
export declare const MAX_BISECTION_ITERATIONS =
|
|
20
|
+
export declare const CONTRAST_EPSILON = 0.004;
|
|
21
|
+
export declare const MAX_BISECTION_ITERATIONS = 10;
|
|
25
22
|
export declare const CONTRAST_COMBINATIONS: {
|
|
26
23
|
bgs: (keyof Ramp)[];
|
|
27
24
|
fgs: (keyof Ramp)[];
|
|
@@ -32,6 +29,7 @@ export declare const DEFAULT_SEED_COLORS: {
|
|
|
32
29
|
primary: string;
|
|
33
30
|
info: string;
|
|
34
31
|
success: string;
|
|
32
|
+
caution: string;
|
|
35
33
|
warning: string;
|
|
36
34
|
error: string;
|
|
37
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/constants.ts"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { RampResult } from './types';
|
|
5
|
+
import type { DEFAULT_SEED_COLORS } from './constants';
|
|
6
|
+
export declare const DEFAULT_RAMPS: Record<keyof typeof DEFAULT_SEED_COLORS, RampResult>;
|
|
7
|
+
//# sourceMappingURL=default-ramps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-ramps.d.ts","sourceRoot":"","sources":["../../../src/color-ramps/lib/default-ramps.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,eAAO,MAAM,aAAa,EAAE,MAAM,CACjC,MAAM,OAAO,mBAAmB,EAChC,UAAU,CA+LV,CAAC"}
|