-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
19 changed files
with
125 additions
and
56 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 @@ | ||
{} |
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 |
---|---|---|
|
@@ -5,5 +5,5 @@ | |
"tabWidth": 2, | ||
"endOfLine": "auto", | ||
"semi": true, | ||
"printWidth": 120 | ||
"printWidth": 130 | ||
} |
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,2 +1,3 @@ | ||
export * from './layout'; | ||
export * from "./CustomPagination"; | ||
export * from './Loader'; | ||
export * from './layout'; |
60 changes: 34 additions & 26 deletions
60
src/components/layout/CustomOffcanvas/CustomOffcanvas.tsx
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,35 +1,43 @@ | ||
import { FC } from "react"; | ||
import { Offcanvas } from "react-bootstrap"; | ||
import { Moon, Sun } from "react-feather"; | ||
import ReactFocusLock from "react-focus-lock"; | ||
import styles from "./customOffcanvas.module.css"; | ||
import { FC, useContext } from 'react'; | ||
import { Offcanvas } from 'react-bootstrap'; | ||
import { Moon, Sun } from 'react-feather'; | ||
import ReactFocusLock from 'react-focus-lock'; | ||
import { ThemeContext } from '../../../contexts'; | ||
import styles from './customOffcanvas.module.css'; | ||
|
||
type OffcanvasProps = { | ||
name:string | ||
show:boolean | ||
handleShow:()=>void | ||
handleClose:()=>void | ||
|
||
} | ||
type CustomOffcanvasProps = { | ||
name: string; | ||
show: boolean; | ||
handleShow: () => void; | ||
handleClose: () => void; | ||
}; | ||
|
||
export const CustomOffcanvas: FC<CustomOffcanvasProps> = ({ show, handleShow, handleClose, ...props }) => { | ||
const { isDark, setIsDark } = useContext(ThemeContext); | ||
|
||
export const CustomOffcanvas:FC<OffcanvasProps> = ({ show, handleShow, handleClose, ...props }) => { | ||
|
||
|
||
return ( | ||
<> | ||
<Offcanvas show={show} onHide={handleClose} {...props} placement={"end"}> | ||
<ReactFocusLock> | ||
return ( | ||
<> | ||
<ReactFocusLock> | ||
<Offcanvas show={show} onHide={handleClose} className={styles.offcanvas} {...props} placement={'end'}> | ||
<Offcanvas.Header closeButton> | ||
<Offcanvas.Title>Menu:</Offcanvas.Title> | ||
</Offcanvas.Header> | ||
<Offcanvas.Body> | ||
|
||
<button className={styles.button} ><Moon size={36}/></button> | ||
<button className={styles.button}><Sun size={36}/></button> | ||
<div className={styles["menu-item"]}> | ||
Toggle page theme: | ||
{isDark ? ( | ||
<button className={styles.button}> | ||
<Sun size={36} onClick={() => setIsDark(isDark)} /> | ||
</button> | ||
) : ( | ||
<button className={styles.button} onClick={() => setIsDark(isDark)}> | ||
<Moon size={36} /> | ||
</button> | ||
)} | ||
</div> | ||
</Offcanvas.Body> | ||
</Offcanvas> | ||
</ReactFocusLock> | ||
</Offcanvas> | ||
</> | ||
); | ||
} | ||
</> | ||
); | ||
}; |
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 +1 @@ | ||
export * from "./CustomOffcanvas"; | ||
export * from './CustomOffcanvas'; |
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,43 @@ | ||
import { FC, PropsWithChildren, createContext, useEffect, useState } from 'react'; | ||
|
||
type ThemeContextType = { | ||
isDark: boolean; | ||
setIsDark: (isDark: boolean) => void; | ||
}; | ||
|
||
export const ThemeContext = createContext<ThemeContextType>({ | ||
isDark: true, | ||
setIsDark: (isDark: boolean) => { | ||
return isDark; | ||
}, | ||
}); | ||
|
||
export const ThemeContextProvider: FC<PropsWithChildren> = ({ children }) => { | ||
const [isDark, setIsDark] = useState(true); | ||
|
||
useEffect(() => { | ||
const theme = window.localStorage.getItem('theme'); | ||
if (theme) { | ||
setIsDark(!(theme === 'light')); | ||
} | ||
}, []); | ||
|
||
useEffect(() => { | ||
document.body.setAttribute('data-bs-theme', `${isDark ? 'dark' : 'light'}`); | ||
}, [isDark]); | ||
|
||
const isDarkHandler = (isDark: boolean) => { | ||
setIsDark(!isDark); | ||
}; | ||
|
||
return ( | ||
<ThemeContext.Provider | ||
value={{ | ||
isDark: isDark, | ||
setIsDark: isDarkHandler, | ||
}} | ||
> | ||
{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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './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 @@ | ||
export * from './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
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 +0,0 @@ | ||
export * from './BeerBrowser'; | ||
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