fixed provider color bug

This commit is contained in:
Zai Shi 2024-03-21 18:31:09 +08:00
parent 63a90fed35
commit 9ca2789e42
2 changed files with 8 additions and 5 deletions

View File

@ -30,8 +30,8 @@ type DesignContextValue = {
export type DesignConfig = {
colors?: {
dark: Partial<ColorPalette>,
light: Partial<ColorPalette>,
dark?: Partial<ColorPalette>,
light?: Partial<ColorPalette>,
},
breakpoints?: Partial<Breakpoints>,
} & (
@ -61,9 +61,12 @@ export function hasCustomColorMode(config: DesignConfig): config is DesignConfig
function getColors(
theme: 'dark' | 'light',
colors: { dark: Partial<ColorPalette>, light: Partial<ColorPalette> } | undefined,
colors: { dark?: Partial<ColorPalette>, light?: Partial<ColorPalette> } | undefined,
): ColorPalette {
return { ...DEFAULT_COLORS[theme], ...colors?.[theme]};
return {
dark: { ...DEFAULT_COLORS.dark, ...colors?.dark },
light: { ...DEFAULT_COLORS.light, ...colors?.light },
}[theme];
}
const useColorMode = (

View File

@ -28,7 +28,7 @@ export function StackTheme({
let { colorMode, setColorMode } = theme;
designProps = { colorMode, setColorMode };
}
designProps = designProps || {breakpoints: theme?.breakpoints, colors: theme?.colors};
designProps = { breakpoints: theme?.breakpoints, colors: theme?.colors, ...designProps };
return (
<ColorModeProvider {...colorModeProps}>