Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Wrapped ThemeProvider props #263

Merged
merged 1 commit into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ import {
* @typedef ThemeProviderProps
* @property {import('react').ReactNode} children Children to render.
* @property {import('../../create-compiler').Compiler} compiler The style compiler.
* @property {string} className Optional className to render on the provider.
* @property {boolean} isGlobal Determines if the theme styles are rendered globally or scoped locally.
* @property {string} [className] Optional className to render on the provider.
* @property {boolean} [isGlobal=false] Determines if the theme styles are rendered globally or scoped locally.
* @property {import('../../create-style-system/generate-theme').GenerateThemeResults} globalStyles Styles to apply globally.
* @property {boolean} isDark Determines if dark-mode styles should be rendered.
* @property {boolean} isColorBlind Determines if color-blind-mode styles should be rendered.
* @property {boolean} isReducedMotion Determines if reduced-motion-mode styles should be rendered.
* @property {boolean} isHighContrast Determines if high-contrast-mode styles should be rendered.
* @property {Record<string, string>} theme Custom theme properties.
* @property {Record<string, string>} darkTheme Custom dark theme properties.
* @property {Record<string, string>} highContrastTheme Custom high contrast theme properties.
* @property {Record<string, string>} darkHighContrastTheme Custom dark & high contrast theme properties.
* @property {boolean} [isDark=false] Determines if dark-mode styles should be rendered.
* @property {boolean} [isColorBlind=false] Determines if color-blind-mode styles should be rendered.
* @property {boolean} [isReducedMotion=false] Determines if reduced-motion-mode styles should be rendered.
* @property {boolean} [isHighContrast=false] Determines if high-contrast-mode styles should be rendered.
* @property {Record<string, string>} [theme={}] Custom theme properties.
* @property {Record<string, string>} [darkTheme={}] Custom dark theme properties.
* @property {Record<string, string>} [highContrastTheme={}] Custom high contrast theme properties.
* @property {Record<string, string>} [darkHighContrastTheme={}] Custom dark & high contrast theme properties.
*/

/**
Expand Down Expand Up @@ -64,10 +64,10 @@ function ThemeProvider(
className,
isGlobal = false,
globalStyles,
isDark,
isColorBlind,
isReducedMotion,
isHighContrast,
isDark = false,
isColorBlind = false,
isReducedMotion = false,
isHighContrast = false,
theme = {},
darkTheme = {},
highContrastTheme = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { createToken, DEFAULT_STYLE_SYSTEM_OPTIONS } from './utils';

const defaultOptions = DEFAULT_STYLE_SYSTEM_OPTIONS;

/** @typedef {Omit<import('../components/theme-provider/theme-provider').ThemeProviderProps, 'compiler' | 'globalStyles'>} WrappedThemeProviderProps */

/**
* @template {Record<string, string | number>} TConfig
* @template {Record<string, string | number>} TDarkConfig
Expand All @@ -27,7 +29,7 @@ const defaultOptions = DEFAULT_STYLE_SYSTEM_OPTIONS;
* @property {(value: keyof (TConfig & TDarkConfig & THCConfig & TDarkHCConfig) | TGeneratedTokens) => string} get The primary function to retrieve Style system variables.
* @property {import('./polymorphic-component').CreateStyled} styled A set of styled components.
* @property {import('react').ComponentType} View The base <View /> component.
* @property {import('react').ComponentType<import('react').ComponentProps<BaseThemeProvider>>} ThemeProvider The component (Provider) used to adjust design tokens.
* @property {import('react').ComponentType<WrappedThemeProviderProps>} ThemeProvider The component (Provider) used to adjust design tokens.
* @property {import('../css-custom-properties').RootStore} rootStore
*/

Expand Down Expand Up @@ -129,9 +131,7 @@ export function createStyleSystem(options = defaultOptions) {
/**
* An enhanced (base) ThemeProvider with injectGlobal from the custom Emotion instance.
*/
const ThemeProvider = (
/** @type {import('react').ComponentProps<BaseThemeProvider>} */ props,
) => (
const ThemeProvider = (/** @type {WrappedThemeProviderProps} */ props) => (
<BaseThemeProvider
{...props}
compiler={compiler}
Expand Down