Skip to content

Commit

Permalink
Update behavior of themee
Browse files Browse the repository at this point in the history
  • Loading branch information
congmul committed Jul 14, 2024
1 parent 4654bb2 commit 0a380eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function App() {
}, [leftMenuCollapse])
return (
<>
<Header setCurrentTheme={setCurrentTheme} />
<Header currentTheme={currentTheme} setCurrentTheme={setCurrentTheme} />
<div className="app-wrapper">
<LeftMenu setContent={setContent} leftMenuCollapse={leftMenuCollapse} setLeftMenuCollapse={setLeftMenuCollapse} />
<div className="editor-page-wrapper" ref={rightMenuRef}>
Expand Down
13 changes: 7 additions & 6 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@ import { Theme } from "../../utils/theme.cont";
import TooltipComponent from "../Tooltip/Tooltip";

interface HeaderType {
currentTheme: string
setCurrentTheme: React.Dispatch<string>
}
const Header:React.FC<HeaderType> = ({setCurrentTheme}) => {
const [ themeState, setThemeState ] = useLocalStorageState('theme');
const Header:React.FC<HeaderType> = ({currentTheme, setCurrentTheme}) => {
const [ _, setThemeState ] = useLocalStorageState('theme');
return(
<header>
<div className="header-wrapper">
<div><BsCodeSquare /> OpenAPI Specification Editor</div>
<div>
{themeState === Theme.LIGHT
{currentTheme === Theme.LIGHT
?
<TooltipComponent message="Dark theme" onClick={() => {setThemeState(Theme.DARK); setCurrentTheme(Theme.DARK);}}>
<LightModeSVG />
</TooltipComponent>
:
</TooltipComponent>
:
<TooltipComponent message="Light theme" onClick={() => {setThemeState(Theme.LIGHT); setCurrentTheme(Theme.LIGHT);}}>
<DarkModeSVG />
</TooltipComponent>
</TooltipComponent>
}
</div>
</div>
Expand Down

0 comments on commit 0a380eb

Please sign in to comment.