From c78dbcf8f89072dc9c2fa8ba81e2cf5a80218cd7 Mon Sep 17 00:00:00 2001 From: Haishan Date: Sun, 13 Jun 2021 15:20:12 +0800 Subject: Support switch theme on backend config page --- src/components/shared/ThemeSwitcher.tsx | 97 +++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 src/components/shared/ThemeSwitcher.tsx (limited to 'src/components/shared/ThemeSwitcher.tsx') diff --git a/src/components/shared/ThemeSwitcher.tsx b/src/components/shared/ThemeSwitcher.tsx new file mode 100644 index 0000000..fba5b0b --- /dev/null +++ b/src/components/shared/ThemeSwitcher.tsx @@ -0,0 +1,97 @@ +import Tooltip from '@reach/tooltip'; +import cx from 'clsx'; +import * as React from 'react'; +import { useTranslation } from 'react-i18next'; +import { connect } from 'src/components/StateProvider'; +import { framerMotionResouce } from 'src/misc/motion'; +import { getTheme, switchTheme } from 'src/store/app'; +import { State } from 'src/store/types'; + +import s from './ThemeSwitcher.module.css'; + +export function ThemeSwitcherImpl({ theme, dispatch }) { + const { t } = useTranslation(); + + const switchThemeHooked = React.useCallback(() => { + dispatch(switchTheme()); + }, [dispatch]); + + return ( + + + + ); +} + +function MoonA() { + const module = framerMotionResouce.read(); + const motion = module.motion; + return ( + + + + ); +} + +function Sun() { + const module = framerMotionResouce.read(); + const motion = module.motion; + + return ( + + + + + + + + + + + + + + ); +} + +const mapState = (s: State) => ({ theme: getTheme(s) }); +export const ThemeSwitcher = connect(mapState)(ThemeSwitcherImpl); -- cgit v1.3.1