-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Agney
committed
Mar 13, 2021
1 parent
c7108e7
commit 4b8eb89
Showing
7 changed files
with
50 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React, { createContext, useContext, useState, useEffect } from 'react'; | ||
import getTheme, { theme } from './theme'; | ||
|
||
export type DefaultTheme = typeof theme; | ||
|
||
const ThemeContext = createContext(theme); | ||
export const useTheme = () => useContext(ThemeContext); | ||
|
||
export function ThemeProvider({ mode, userTheme, children }) { | ||
const [consolidatedTheme, setConsolidatedTheme] = useState<DefaultTheme>( | ||
theme | ||
); | ||
|
||
useEffect(() => { | ||
setConsolidatedTheme(getTheme(mode)); | ||
}, [mode]); | ||
|
||
return ( | ||
<ThemeContext.Provider value={userTheme ?? consolidatedTheme}> | ||
{children} | ||
</ThemeContext.Provider> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import "styled-components"; | ||
import "goober"; | ||
|
||
import { theme } from "../src/utils/theme"; | ||
|
||
declare module "styled-components" { | ||
type Theme = typeof theme; | ||
export interface DefaultTheme extends Theme {} | ||
declare module "goober" { | ||
type OurTheme = typeof theme; | ||
export interface DefaultTheme extends OurTheme {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters