Skip to content

Commit 9bdafa4

Browse files
Merge pull request #263 from ItsJonQ/fix/wrapped-theme-provider
fix: Wrapped ThemeProvider props
2 parents cd02dbe + be94165 commit 9bdafa4

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

packages/create-styles/src/components/theme-provider/theme-provider.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ import {
2626
* @typedef ThemeProviderProps
2727
* @property {import('react').ReactNode} children Children to render.
2828
* @property {import('../../create-compiler').Compiler} compiler The style compiler.
29-
* @property {string} className Optional className to render on the provider.
30-
* @property {boolean} isGlobal Determines if the theme styles are rendered globally or scoped locally.
29+
* @property {string} [className] Optional className to render on the provider.
30+
* @property {boolean} [isGlobal=false] Determines if the theme styles are rendered globally or scoped locally.
3131
* @property {import('../../create-style-system/generate-theme').GenerateThemeResults} globalStyles Styles to apply globally.
32-
* @property {boolean} isDark Determines if dark-mode styles should be rendered.
33-
* @property {boolean} isColorBlind Determines if color-blind-mode styles should be rendered.
34-
* @property {boolean} isReducedMotion Determines if reduced-motion-mode styles should be rendered.
35-
* @property {boolean} isHighContrast Determines if high-contrast-mode styles should be rendered.
36-
* @property {Record<string, string>} theme Custom theme properties.
37-
* @property {Record<string, string>} darkTheme Custom dark theme properties.
38-
* @property {Record<string, string>} highContrastTheme Custom high contrast theme properties.
39-
* @property {Record<string, string>} darkHighContrastTheme Custom dark & high contrast theme properties.
32+
* @property {boolean} [isDark=false] Determines if dark-mode styles should be rendered.
33+
* @property {boolean} [isColorBlind=false] Determines if color-blind-mode styles should be rendered.
34+
* @property {boolean} [isReducedMotion=false] Determines if reduced-motion-mode styles should be rendered.
35+
* @property {boolean} [isHighContrast=false] Determines if high-contrast-mode styles should be rendered.
36+
* @property {Record<string, string>} [theme={}] Custom theme properties.
37+
* @property {Record<string, string>} [darkTheme={}] Custom dark theme properties.
38+
* @property {Record<string, string>} [highContrastTheme={}] Custom high contrast theme properties.
39+
* @property {Record<string, string>} [darkHighContrastTheme={}] Custom dark & high contrast theme properties.
4040
*/
4141

4242
/**
@@ -64,10 +64,10 @@ function ThemeProvider(
6464
className,
6565
isGlobal = false,
6666
globalStyles,
67-
isDark,
68-
isColorBlind,
69-
isReducedMotion,
70-
isHighContrast,
67+
isDark = false,
68+
isColorBlind = false,
69+
isReducedMotion = false,
70+
isHighContrast = false,
7171
theme = {},
7272
darkTheme = {},
7373
highContrastTheme = {},

packages/create-styles/src/create-style-system/create-style-system.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { createToken, DEFAULT_STYLE_SYSTEM_OPTIONS } from './utils';
1111

1212
const defaultOptions = DEFAULT_STYLE_SYSTEM_OPTIONS;
1313

14+
/** @typedef {Omit<import('../components/theme-provider/theme-provider').ThemeProviderProps, 'compiler' | 'globalStyles'>} WrappedThemeProviderProps */
15+
1416
/**
1517
* @template {Record<string, string | number>} TConfig
1618
* @template {Record<string, string | number>} TDarkConfig
@@ -27,7 +29,7 @@ const defaultOptions = DEFAULT_STYLE_SYSTEM_OPTIONS;
2729
* @property {(value: keyof (TConfig & TDarkConfig & THCConfig & TDarkHCConfig) | TGeneratedTokens) => string} get The primary function to retrieve Style system variables.
2830
* @property {import('./polymorphic-component').CreateStyled} styled A set of styled components.
2931
* @property {import('react').ComponentType} View The base <View /> component.
30-
* @property {import('react').ComponentType<import('react').ComponentProps<BaseThemeProvider>>} ThemeProvider The component (Provider) used to adjust design tokens.
32+
* @property {import('react').ComponentType<WrappedThemeProviderProps>} ThemeProvider The component (Provider) used to adjust design tokens.
3133
* @property {import('../css-custom-properties').RootStore} rootStore
3234
*/
3335

@@ -129,9 +131,7 @@ export function createStyleSystem(options = defaultOptions) {
129131
/**
130132
* An enhanced (base) ThemeProvider with injectGlobal from the custom Emotion instance.
131133
*/
132-
const ThemeProvider = (
133-
/** @type {import('react').ComponentProps<BaseThemeProvider>} */ props,
134-
) => (
134+
const ThemeProvider = (/** @type {WrappedThemeProviderProps} */ props) => (
135135
<BaseThemeProvider
136136
{...props}
137137
compiler={compiler}

0 commit comments

Comments
 (0)