@wordpress/theme 0.9.0 → 0.10.1-next.v.202604091042.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 (33) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +22 -17
  3. package/build/context.cjs +2 -1
  4. package/build/context.cjs.map +2 -2
  5. package/build/prebuilt/js/design-token-fallbacks.cjs +1 -1
  6. package/build/prebuilt/js/design-token-fallbacks.cjs.map +1 -1
  7. package/build/theme-provider.cjs +5 -3
  8. package/build/theme-provider.cjs.map +2 -2
  9. package/build/types.cjs.map +1 -1
  10. package/build/use-theme-provider-styles.cjs +16 -4
  11. package/build/use-theme-provider-styles.cjs.map +2 -2
  12. package/build-module/context.mjs +2 -1
  13. package/build-module/context.mjs.map +2 -2
  14. package/build-module/prebuilt/js/design-token-fallbacks.mjs +1 -1
  15. package/build-module/prebuilt/js/design-token-fallbacks.mjs.map +1 -1
  16. package/build-module/theme-provider.mjs +5 -3
  17. package/build-module/theme-provider.mjs.map +2 -2
  18. package/build-module/use-theme-provider-styles.mjs +16 -4
  19. package/build-module/use-theme-provider-styles.mjs.map +2 -2
  20. package/build-types/context.d.ts.map +1 -1
  21. package/build-types/theme-provider.d.ts +1 -1
  22. package/build-types/theme-provider.d.ts.map +1 -1
  23. package/build-types/types.d.ts +13 -0
  24. package/build-types/types.d.ts.map +1 -1
  25. package/build-types/use-theme-provider-styles.d.ts +865 -6
  26. package/build-types/use-theme-provider-styles.d.ts.map +1 -1
  27. package/package.json +4 -4
  28. package/src/context.ts +1 -0
  29. package/src/prebuilt/css/design-tokens.css +1 -1
  30. package/src/prebuilt/js/design-token-fallbacks.mjs +1 -1
  31. package/src/theme-provider.tsx +2 -0
  32. package/src/types.ts +14 -0
  33. package/src/use-theme-provider-styles.ts +16 -2
@@ -1 +1 @@
1
- {"version":3,"file":"use-theme-provider-styles.d.ts","sourceRoot":"","sources":["../src/use-theme-provider-styles.ts"],"names":[],"mappings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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoEL"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/theme",
3
- "version": "0.9.0",
3
+ "version": "0.10.1-next.v.202604091042.0+668146787",
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",
@@ -84,8 +84,8 @@
84
84
  "build-module/color-ramps/lib/register-color-spaces.mjs"
85
85
  ],
86
86
  "dependencies": {
87
- "@wordpress/element": "^6.42.0",
88
- "@wordpress/private-apis": "^1.42.0",
87
+ "@wordpress/element": "^6.44.1-next.v.202604091042.0+668146787",
88
+ "@wordpress/private-apis": "^1.43.1-next.v.202604091042.0+668146787",
89
89
  "colorjs.io": "^0.6.0",
90
90
  "memize": "^2.1.0"
91
91
  },
@@ -121,5 +121,5 @@
121
121
  "build": "npm run build:tokens && npm run build:default-ramps && npm run prelint:js",
122
122
  "postbuild": "prettier --write tokens/color.json tokens/modes src/prebuilt src/color-ramps/lib/default-ramps.ts docs"
123
123
  },
124
- "gitHead": "c20787b1778ae64c2db65643b1c236309d68e6ba"
124
+ "gitHead": "73606df74f1c38a084bfa5db97205259ef817593"
125
125
  }
package/src/context.ts CHANGED
@@ -15,5 +15,6 @@ interface ThemeContextType {
15
15
  export const ThemeContext = createContext< ThemeContextType >( {
16
16
  resolvedSettings: {
17
17
  color: {},
18
+ cursor: undefined,
18
19
  },
19
20
  } );
@@ -100,7 +100,7 @@
100
100
  --wpds-color-stroke-surface-success-strong: #007f30; /* Decorative stroke color used to define success-toned surface boundaries with strong emphasis. */
101
101
  --wpds-color-stroke-surface-warning: #d0b381; /* Decorative stroke color used to define warning-toned surface boundaries with normal emphasis. */
102
102
  --wpds-color-stroke-surface-warning-strong: #926300; /* Decorative stroke color used to define warning-toned surface boundaries with strong emphasis. */
103
- --wpds-cursor-control: default; /* Cursor style for interactive controls that are not links (e.g. buttons, checkboxes, and toggles). */
103
+ --wpds-cursor-control: pointer; /* Cursor style for interactive controls that are not links (e.g. buttons, checkboxes, and toggles). */
104
104
  --wpds-dimension-base: 4px; /* Base dimension unit */
105
105
  --wpds-dimension-gap-2xl: 32px; /* 2x extra large gap */
106
106
  --wpds-dimension-gap-3xl: 40px; /* 3x extra large gap */
@@ -111,7 +111,7 @@ export default {
111
111
  '--wpds-color-stroke-surface-success-strong': '#007f30',
112
112
  '--wpds-color-stroke-surface-warning': '#d0b381',
113
113
  '--wpds-color-stroke-surface-warning-strong': '#926300',
114
- '--wpds-cursor-control': 'default',
114
+ '--wpds-cursor-control': 'pointer',
115
115
  '--wpds-dimension-base': '4px',
116
116
  '--wpds-dimension-gap-2xl': '32px',
117
117
  '--wpds-dimension-gap-3xl': '40px',
@@ -48,6 +48,7 @@ function generateCSSSelector( {
48
48
  export const ThemeProvider = ( {
49
49
  children,
50
50
  color = {},
51
+ cursor,
51
52
  isRoot = false,
52
53
  density,
53
54
  }: ThemeProviderProps ) => {
@@ -55,6 +56,7 @@ export const ThemeProvider = ( {
55
56
 
56
57
  const { themeProviderStyles, resolvedSettings } = useThemeProviderStyles( {
57
58
  color,
59
+ cursor,
58
60
  } );
59
61
 
60
62
  const contextValue = useMemo(
package/src/types.ts CHANGED
@@ -24,6 +24,20 @@ export interface ThemeProviderSettings {
24
24
  bg?: string;
25
25
  };
26
26
 
27
+ /**
28
+ * The set of cursor options to apply to the theme.
29
+ */
30
+ cursor?: {
31
+ /**
32
+ * The cursor style for interactive controls that are not links
33
+ * (e.g. buttons, checkboxes, and toggles).
34
+ *
35
+ * By default, it inherits from the parent `ThemeProvider`,
36
+ * and falls back to the prebuilt default (`default`).
37
+ */
38
+ control?: 'default' | 'pointer';
39
+ };
40
+
27
41
  /**
28
42
  * The density of the theme. If left unspecified, the theme inherits from
29
43
  * the density of the closest `ThemeProvider`, or uses the default density
@@ -170,8 +170,10 @@ function generateStyles( {
170
170
 
171
171
  export function useThemeProviderStyles( {
172
172
  color = {},
173
+ cursor,
173
174
  }: {
174
175
  color?: ThemeProviderProps[ 'color' ];
176
+ cursor?: ThemeProviderProps[ 'cursor' ];
175
177
  } = {} ) {
176
178
  const { resolvedSettings: inheritedSettings } = useContext( ThemeContext );
177
179
 
@@ -185,6 +187,7 @@ export function useThemeProviderStyles( {
185
187
  DEFAULT_SEED_COLORS.primary;
186
188
  const bg =
187
189
  color.bg ?? inheritedSettings.color?.bg ?? DEFAULT_SEED_COLORS.bg;
190
+ const cursorControl = cursor?.control ?? inheritedSettings.cursor?.control;
188
191
 
189
192
  const resolvedSettings = useMemo(
190
193
  () => ( {
@@ -192,11 +195,12 @@ export function useThemeProviderStyles( {
192
195
  primary,
193
196
  bg,
194
197
  },
198
+ cursor: cursorControl ? { control: cursorControl } : undefined,
195
199
  } ),
196
- [ primary, bg ]
200
+ [ primary, bg, cursorControl ]
197
201
  );
198
202
 
199
- const themeProviderStyles = useMemo( () => {
203
+ const colorStyles = useMemo( () => {
200
204
  // Determine which seeds are needed for generating ramps.
201
205
  const seeds = {
202
206
  ...DEFAULT_SEED_COLORS,
@@ -224,6 +228,16 @@ export function useThemeProviderStyles( {
224
228
  } );
225
229
  }, [ primary, bg ] );
226
230
 
231
+ const themeProviderStyles = useMemo(
232
+ () => ( {
233
+ ...colorStyles,
234
+ ...( cursorControl && {
235
+ '--wpds-cursor-control': cursorControl,
236
+ } ),
237
+ } ),
238
+ [ colorStyles, cursorControl ]
239
+ );
240
+
227
241
  return {
228
242
  resolvedSettings,
229
243
  themeProviderStyles,