-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat/#393 added dark-light theme toggle button
- Loading branch information
1 parent
b54e15c
commit cbf9097
Showing
9 changed files
with
95 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import styles from '@/styles.module.scss'; | ||
import { ReactElement, createContext, useState } from 'react'; | ||
|
||
type Theme = 'light' | 'dark'; | ||
|
||
interface ThemeContextType { | ||
theme: Theme; | ||
toggleTheme: (theme: Theme) => void; | ||
} | ||
|
||
export const ThemeContext = createContext<ThemeContextType>({ | ||
theme: 'light', | ||
toggleTheme: () => {}, | ||
}); | ||
|
||
export const ThemeWrapper = ({ children }: { children: ReactElement }) => { | ||
const [theme, setTheme] = useState<Theme>('light'); | ||
|
||
const toggleTheme = (theme: Theme): void => setTheme(theme === 'light' ? 'dark' : 'light'); | ||
return ( | ||
<ThemeContext.Provider value={{ theme, toggleTheme }}> | ||
<div className={styles.containerWrapper} data-theme={theme}> | ||
{children} | ||
</div> | ||
</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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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