-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: dark theme and UI improvements
- Loading branch information
Showing
37 changed files
with
546 additions
and
339 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,41 @@ | ||
/** | ||
* | ||
* ThemeSwitcher | ||
* | ||
*/ | ||
import { Moon, Sun } from 'grommet-icons/icons' | ||
import React, { memo } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { useDispatch, useSelector } from 'react-redux' | ||
import { useThemeSlice } from 'styles/theme/slice' | ||
import { selectTheme } from 'styles/theme/slice/selectors' | ||
|
||
import { SidebarButton } from '../Sidebar' | ||
|
||
interface Props {} | ||
|
||
export const ThemeSwitcher = memo((props: Props) => { | ||
const { t } = useTranslation() | ||
const themeActions = useThemeSlice().actions | ||
const theme = useSelector(selectTheme) | ||
const dispatch = useDispatch() | ||
|
||
const modes = { | ||
light: { | ||
icon: <Moon />, | ||
label: t('theme.darkMode', 'Dark mode'), | ||
}, | ||
dark: { | ||
icon: <Sun />, | ||
label: t('theme.ligthMode', 'Light mode'), | ||
}, | ||
} | ||
|
||
const currentMode = modes[theme] | ||
const switchTheme = () => { | ||
const newTheme = theme === 'dark' ? 'light' : 'dark' | ||
dispatch(themeActions.changeTheme(newTheme)) | ||
} | ||
|
||
return <SidebarButton icon={currentMode.icon} label={currentMode.label} onClick={switchTheme} /> | ||
}) |
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
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
Oops, something went wrong.