Skip to content

Commit

Permalink
fix: remove color mode deps
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Jun 21, 2020
1 parent 16d94b1 commit 8b9e463
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 35 deletions.
4 changes: 1 addition & 3 deletions integrations/storybook/src/context/ThemeProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React from 'react';
import { ThemeProvider as ThemeUIProvider } from '@component-controls/components';
import { useIsDark } from './useIsDark';

export const ThemeProvider: React.FC = ({ children }) => {
const isDark = useIsDark();
return <ThemeUIProvider dark={isDark}>{children}</ThemeUIProvider>;
return <ThemeUIProvider>{children}</ThemeUIProvider>;
};
1 change: 0 additions & 1 deletion integrations/storybook/src/context/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './BlockContext';
export * from './ControlsProvider';
export * from './useIsDark';
export * from './ThemeProvider';
19 changes: 0 additions & 19 deletions integrations/storybook/src/context/useIsDark.tsx

This file was deleted.

4 changes: 1 addition & 3 deletions integrations/storybook/src/docs-page/DocsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ import {
getGlobalOptions,
} from '@component-controls/storybook-custom-docs';
import { store } from '@component-controls/store/live_store';
import { useIsDark } from '../context/useIsDark';

export const PageContextContainer: FC = ({ children }) => {
const options = React.useMemo(() => getGlobalOptions(), []);
const storyId = useStoryId();
const isDark = useIsDark();
return (
<ThemeProvider theme={store.config?.theme} dark={isDark}>
<ThemeProvider theme={store.config?.theme}>
<BlockContextProvider storyId={storyId} store={store} options={options}>
<BlockPageContainer variant="pagecontainer.storybook">
{children}
Expand Down
11 changes: 2 additions & 9 deletions ui/components/src/ThemeContext/ThemeContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { theme as defaultTheme } from './theme';

export interface ThemeContextProps {
theme?: Theme;
dark?: boolean;
}
export const ThemeContext = React.createContext<ThemeContextProps>({});

Expand All @@ -16,27 +15,21 @@ export interface ThemeProviderProps {
* components to customize the markdown display.
*/
components?: MarkdownComponentType;
dark?: boolean;
theme?: Theme;
}

export const ThemeProvider: React.FC<ThemeProviderProps> = ({
theme: customTheme,
children,
dark,
components = {},
}) => {
const theme = React.useMemo(() => {
return {
...(customTheme ? merge(defaultTheme, customTheme) : defaultTheme),
initialColorModeName: dark ? 'dark' : 'default',
};
}, [dark, customTheme]);
return customTheme ? merge(defaultTheme, customTheme) : defaultTheme;
}, [customTheme]);
return (
<ThemeContext.Provider
value={{
theme,
dark,
}}
>
<ThemeUIProvider
Expand Down

0 comments on commit 8b9e463

Please sign in to comment.