diff --git a/components/ThemeSwitcher.tsx b/components/ThemeSwitcher.tsx new file mode 100644 index 00000000..03d5bdad --- /dev/null +++ b/components/ThemeSwitcher.tsx @@ -0,0 +1,31 @@ +import { useTranslation } from 'next-i18next' +import { useTheme } from 'next-themes' +import ThemesIcon from './icons/ThemesIcon' +import { THEMES } from './settings/DisplaySettings' +import { LinkButton } from './shared/Button' +import IconDropMenu from './shared/IconDropMenu' + +const ThemeSwitcher = () => { + const { t } = useTranslation('settings') + const { theme, setTheme } = useTheme() + return ( + } + panelClassName="rounded-t-none" + > + {THEMES.map((value) => ( + setTheme(t(value))} + key={value} + > + {t(value)} + + ))} + + ) +} + +export default ThemeSwitcher diff --git a/components/TopBar.tsx b/components/TopBar.tsx index 21565cb2..cfec318c 100644 --- a/components/TopBar.tsx +++ b/components/TopBar.tsx @@ -23,6 +23,7 @@ import useOnlineStatus from 'hooks/useOnlineStatus' import { DEFAULT_DELEGATE } from './modals/DelegateModal' import Tooltip from './shared/Tooltip' import { abbreviateAddress } from 'utils/formatting' +import ThemeSwitcher from './ThemeSwitcher' const TopBar = () => { const { t } = useTranslation('common') @@ -83,58 +84,63 @@ const TopBar = () => { ) : null} {!isOnline ? ( -
- -
- Your network connection appears to be offline! -
+
+ +

+ Your connection appears to be offline +

) : null} - {connected ? ( -
- - +
+
+
- ) : isOnboarded ? ( - - ) : ( - +
- - )} + ) : isOnboarded ? ( + + ) : ( + + )} +
{showMangoAccountsModal ? ( { + return ( + + + + + + + + + + + ) +} + +export default ThemesIcon diff --git a/components/settings/DisplaySettings.tsx b/components/settings/DisplaySettings.tsx index 302df67d..a64855f8 100644 --- a/components/settings/DisplaySettings.tsx +++ b/components/settings/DisplaySettings.tsx @@ -5,7 +5,7 @@ import useLocalStorageState from 'hooks/useLocalStorageState' import { useTranslation } from 'next-i18next' import { useTheme } from 'next-themes' import { useRouter } from 'next/router' -import { useCallback, useMemo } from 'react' +import { useCallback } from 'react' import { NOTIFICATION_POSITION_KEY, SIZE_INPUT_UI_KEY } from 'utils/constants' const NOTIFICATION_POSITIONS = [ @@ -27,6 +27,19 @@ const LANGS = [ { locale: 'zh', name: 'chinese', description: 'simplified chinese' }, ] +export const THEMES = [ + 'light', + 'medium', + 'dark', + 'high-contrast', + 'mango-classic', + 'avocado', + 'banana', + 'blueberry', + 'lychee', + 'olive', +] + const DisplaySettings = () => { const { t } = useTranslation(['common', 'settings']) const { theme, setTheme } = useTheme() @@ -41,20 +54,6 @@ const DisplaySettings = () => { SIZE_INPUT_UI_KEY, 'Slider' ) - const themes = useMemo(() => { - return [ - t('settings:light'), - t('settings:medium'), - t('settings:dark'), - t('settings:high-contrast'), - t('settings:mango-classic'), - t('settings:avocado'), - t('settings:banana'), - t('settings:blueberry'), - t('settings:lychee'), - t('settings:olive'), - ] - }, [t]) const handleLangChange = useCallback( (l: string) => { @@ -76,10 +75,10 @@ const DisplaySettings = () => { onChange={(t) => setTheme(t)} className="w-full" > - {themes.map((t) => ( - + {THEMES.map((theme) => ( +
- {t} + {t(`settings:${theme}`)}
))} diff --git a/components/shared/Button.tsx b/components/shared/Button.tsx index 563bc87c..3c78c9fb 100644 --- a/components/shared/Button.tsx +++ b/components/shared/Button.tsx @@ -108,7 +108,7 @@ export const LinkButton: FunctionComponent = ({