@khanacademy/wonder-blocks-theming 3.2.0 → 3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @khanacademy/wonder-blocks-theming
2
2
 
3
+ ## 3.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 7f79943: Export THEME_DATA_ATTRIBUTE to centralize how the theme is set in WB
8
+ - 7bbf311: Add ThemeSwitcher component to change themes using CSS variables
9
+
10
+ ## 3.2.1
11
+
12
+ ### Patch Changes
13
+
14
+ - 1d7be37: Use pnpm catalog to pin dependency versions across packages
15
+
3
16
  ## 3.2.0
4
17
 
5
18
  ### Minor Changes
@@ -0,0 +1,17 @@
1
+ import * as React from "react";
2
+ import { SupportedThemes } from "../types";
3
+ type Props = {
4
+ /**
5
+ * The theme to use.
6
+ */
7
+ theme: SupportedThemes;
8
+ /**
9
+ * The children where the theme will be applied.
10
+ */
11
+ children: React.ReactNode;
12
+ };
13
+ /**
14
+ * ThemeSwitcher is a component that allows users to switch between themes.
15
+ */
16
+ export declare function ThemeSwitcher({ theme, children }: Props): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
17
+ export {};
package/dist/es/index.js CHANGED
@@ -57,4 +57,19 @@ function useStyles(styles, theme) {
57
57
  return styleSheet;
58
58
  }
59
59
 
60
- export { ThemeSwitcherContext, createThemeContext, mergeTheme, useScopedTheme, useStyles, withScopedTheme };
60
+ const THEME_DATA_ATTRIBUTE = "data-wb-theme";
61
+
62
+ function ThemeSwitcher({
63
+ theme,
64
+ children
65
+ }) {
66
+ if (!theme) {
67
+ return children;
68
+ }
69
+ const props = {
70
+ [THEME_DATA_ATTRIBUTE]: theme
71
+ };
72
+ return React.createElement("div", props, children);
73
+ }
74
+
75
+ export { THEME_DATA_ATTRIBUTE, ThemeSwitcher, ThemeSwitcherContext, createThemeContext, mergeTheme, useScopedTheme, useStyles, withScopedTheme };
package/dist/index.d.ts CHANGED
@@ -4,4 +4,6 @@ export { default as useScopedTheme } from "./hooks/use-scoped-theme";
4
4
  export { default as withScopedTheme, type WithThemeProps, type WithoutTheme, } from "./components/with-scoped-theme";
5
5
  export { type ThemedStylesFn, type SupportedThemes, type Themes } from "./types";
6
6
  export { default as useStyles } from "./hooks/use-styles";
7
+ export { THEME_DATA_ATTRIBUTE } from "./utils/constants";
7
8
  export { ThemeSwitcherContext } from "./utils/theme-switcher-context";
9
+ export { ThemeSwitcher } from "./components/theme-switcher";
package/dist/index.js CHANGED
@@ -81,6 +81,23 @@ function useStyles(styles, theme) {
81
81
  return styleSheet;
82
82
  }
83
83
 
84
+ const THEME_DATA_ATTRIBUTE = "data-wb-theme";
85
+
86
+ function ThemeSwitcher({
87
+ theme,
88
+ children
89
+ }) {
90
+ if (!theme) {
91
+ return children;
92
+ }
93
+ const props = {
94
+ [THEME_DATA_ATTRIBUTE]: theme
95
+ };
96
+ return React__namespace.createElement("div", props, children);
97
+ }
98
+
99
+ exports.THEME_DATA_ATTRIBUTE = THEME_DATA_ATTRIBUTE;
100
+ exports.ThemeSwitcher = ThemeSwitcher;
84
101
  exports.ThemeSwitcherContext = ThemeSwitcherContext;
85
102
  exports.createThemeContext = createThemeContext;
86
103
  exports.mergeTheme = mergeTheme;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The data attribute that scopes the theme to a specific element.
3
+ * This is used to apply the theme to a specific element(s) in the DOM.
4
+ *
5
+ * NOTE: The -wb- prefix is used to avoid conflicts with other libraries, and
6
+ * scope the theme to Wonder Blocks.
7
+ */
8
+ export declare const THEME_DATA_ATTRIBUTE = "data-wb-theme";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-theming",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },