Skip to content

Commit

Permalink
fix: resolve color moded theme and make it extendable
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptammergard committed Jul 6, 2021
1 parent e17aa25 commit d2f37f0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/components/EinrideProvider/EinrideProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import { ThemeProvider } from "@emotion/react";
import { ReactNode } from "react";
import { light } from "../../theme";
import { themes } from "../../theme";

interface EinrideProviderProps {
children: ReactNode;
colorMode: "light" | "dark";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
customTheme: any;
}

export const EinrideProvider = ({ children }: EinrideProviderProps) => {
return <ThemeProvider theme={light}>{children}</ThemeProvider>;
export const EinrideProvider = ({
children,
colorMode = "light",
customTheme,
}: EinrideProviderProps) => {
const defaultTheme = themes[colorMode];
const theme = {
...defaultTheme,
custom: customTheme,
};
return <ThemeProvider theme={theme}>{children}</ThemeProvider>;
};
1 change: 1 addition & 0 deletions src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,4 @@ export const dark: Theme = {
};

export type Theme = typeof light;
export const themes = { light, dark };

0 comments on commit d2f37f0

Please sign in to comment.