-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into add/BasePage_297_1_2
- Loading branch information
Showing
11 changed files
with
188 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// ThemeContext.js | ||
import React, { FC, PropsWithChildren, createContext, useContext, useState } from 'react' | ||
import { ThemeProvider as MuiThemeProvider, createTheme } from '@mui/material/styles' | ||
import { ConfigProvider, theme } from 'antd' | ||
import heIL from 'antd/es/locale/he_IL' | ||
export interface ThemeContextInterface { | ||
toggleTheme: () => void | ||
isDarkTheme: boolean | ||
} | ||
const ThemeContext = createContext({} as ThemeContextInterface) | ||
const darkTheme = createTheme({ | ||
palette: { | ||
mode: 'dark', | ||
}, | ||
}) | ||
|
||
const lightTheme = createTheme({ | ||
palette: { | ||
mode: 'light', | ||
}, | ||
}) | ||
|
||
const { defaultAlgorithm, darkAlgorithm } = theme | ||
export const ThemeProvider: FC<PropsWithChildren> = ({ children }) => { | ||
const [isDarkTheme, setIsDarkTheme] = useState(false) | ||
|
||
const toggleTheme = () => { | ||
setIsDarkTheme((prevTheme) => !prevTheme) | ||
} | ||
|
||
const contextValue = { | ||
isDarkTheme, | ||
toggleTheme, | ||
} | ||
|
||
return ( | ||
<ConfigProvider | ||
direction="rtl" | ||
locale={heIL} | ||
theme={{ | ||
algorithm: isDarkTheme ? darkAlgorithm : defaultAlgorithm, | ||
}}> | ||
<MuiThemeProvider theme={isDarkTheme ? darkTheme : lightTheme}> | ||
<ThemeContext.Provider value={contextValue}> {children} </ThemeContext.Provider> | ||
</MuiThemeProvider> | ||
</ConfigProvider> | ||
) | ||
} | ||
|
||
export const useTheme = () => { | ||
return useContext(ThemeContext) | ||
} |
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,9 @@ | ||
.main-header { | ||
display: flex; | ||
justify-content: flex-end; | ||
align-items: center; | ||
background: #fff; | ||
} | ||
.main-header.dark { | ||
background: #141414; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import { Card } from 'antd' | ||
|
||
const Widget = (props: { children: React.ReactNode }) => { | ||
return <section className="widget">{props.children}</section> | ||
return <Card>{props.children}</Card> | ||
} | ||
|
||
export default Widget |
Oops, something went wrong.