From fd6aec4f08292932c3da5c7cd269b74a18a78daf Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Wed, 12 May 2021 15:28:39 +0300 Subject: [PATCH] Switcher: Add animation (#1079) --- src/components/left/main/LeftMainHeader.tsx | 1 + src/components/ui/Switcher.scss | 18 ++++++++++++++++++ src/components/ui/Switcher.tsx | 3 +++ src/styles/index.scss | 4 +++- src/util/switchTheme.ts | 4 ++-- 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/components/left/main/LeftMainHeader.tsx b/src/components/left/main/LeftMainHeader.tsx index 8330563ce..88a8ae489 100644 --- a/src/components/left/main/LeftMainHeader.tsx +++ b/src/components/left/main/LeftMainHeader.tsx @@ -203,6 +203,7 @@ const LeftMainHeader: FC = ({ id="darkmode" label="Toggle Dark Mode" checked={theme === 'dark'} + noAnimation /> ) => void; onCheck?: (isChecked: boolean) => void; }; @@ -25,6 +26,7 @@ const Switcher: FC = ({ checked = false, disabled, inactive, + noAnimation, onChange, onCheck, }) => { @@ -42,6 +44,7 @@ const Switcher: FC = ({ 'Switcher', disabled && 'disabled', inactive && 'inactive', + noAnimation && 'no-animation', ); return ( diff --git a/src/styles/index.scss b/src/styles/index.scss index b027840f2..b8b7a700a 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -83,7 +83,9 @@ body.cursor-grabbing, body.cursor-grabbing * { box-sizing: border-box; } -.disable-animations #root * { +.no-animations #root *, +.no-animations #root *::before, +.no-animations #root *::after { transition: none !important; } diff --git a/src/util/switchTheme.ts b/src/util/switchTheme.ts index f5cd8f757..8c9111558 100644 --- a/src/util/switchTheme.ts +++ b/src/util/switchTheme.ts @@ -36,7 +36,7 @@ export default (theme: ISettings['theme'], withAnimation: boolean) => { document.documentElement.classList.remove(`theme-${isDarkTheme ? 'light' : 'dark'}`); if (isInitialized) { - document.documentElement.classList.add('disable-animations'); + document.documentElement.classList.add('no-animations'); } document.documentElement.classList.add(`theme-${theme}`); if (themeColorTag) { @@ -44,7 +44,7 @@ export default (theme: ISettings['theme'], withAnimation: boolean) => { } setTimeout(() => { - document.documentElement.classList.remove('disable-animations'); + document.documentElement.classList.remove('no-animations'); }, ENABLE_ANIMATION_DELAY_MS); isInitialized = true;