Switcher: Add animation (#1079)
This commit is contained in:
parent
ecc2ed9979
commit
fd6aec4f08
@ -203,6 +203,7 @@ const LeftMainHeader: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
id="darkmode"
|
id="darkmode"
|
||||||
label="Toggle Dark Mode"
|
label="Toggle Dark Mode"
|
||||||
checked={theme === 'dark'}
|
checked={theme === 'dark'}
|
||||||
|
noAnimation
|
||||||
/>
|
/>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
|
|||||||
@ -13,6 +13,18 @@
|
|||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body.animation-level-0 &,
|
||||||
|
&.no-animation {
|
||||||
|
.widget,
|
||||||
|
.widget::after {
|
||||||
|
transition: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.widget:active:after {
|
||||||
|
width: 1.125rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
input {
|
input {
|
||||||
height: 0;
|
height: 0;
|
||||||
width: 0;
|
width: 0;
|
||||||
@ -31,6 +43,7 @@
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
border-radius: .5rem;
|
border-radius: .5rem;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
transition: background .2s ease-in;
|
||||||
}
|
}
|
||||||
|
|
||||||
.widget:after {
|
.widget:after {
|
||||||
@ -42,6 +55,7 @@
|
|||||||
height: 1.125rem;
|
height: 1.125rem;
|
||||||
background: var(--color-background);
|
background: var(--color-background);
|
||||||
border-radius: .75rem;
|
border-radius: .75rem;
|
||||||
|
transition: 0.2s ease-out;
|
||||||
border: .125rem solid var(--color-gray);
|
border: .125rem solid var(--color-gray);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,4 +68,8 @@
|
|||||||
transform: translateX(calc(-100% + 1.125rem));
|
transform: translateX(calc(-100% + 1.125rem));
|
||||||
border-color: var(--color-primary);
|
border-color: var(--color-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.widget:active:after {
|
||||||
|
width: 1.25rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ type OwnProps = {
|
|||||||
checked?: boolean;
|
checked?: boolean;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
inactive?: boolean;
|
inactive?: boolean;
|
||||||
|
noAnimation?: boolean;
|
||||||
onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
|
onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
|
||||||
onCheck?: (isChecked: boolean) => void;
|
onCheck?: (isChecked: boolean) => void;
|
||||||
};
|
};
|
||||||
@ -25,6 +26,7 @@ const Switcher: FC<OwnProps> = ({
|
|||||||
checked = false,
|
checked = false,
|
||||||
disabled,
|
disabled,
|
||||||
inactive,
|
inactive,
|
||||||
|
noAnimation,
|
||||||
onChange,
|
onChange,
|
||||||
onCheck,
|
onCheck,
|
||||||
}) => {
|
}) => {
|
||||||
@ -42,6 +44,7 @@ const Switcher: FC<OwnProps> = ({
|
|||||||
'Switcher',
|
'Switcher',
|
||||||
disabled && 'disabled',
|
disabled && 'disabled',
|
||||||
inactive && 'inactive',
|
inactive && 'inactive',
|
||||||
|
noAnimation && 'no-animation',
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -83,7 +83,9 @@ body.cursor-grabbing, body.cursor-grabbing * {
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.disable-animations #root * {
|
.no-animations #root *,
|
||||||
|
.no-animations #root *::before,
|
||||||
|
.no-animations #root *::after {
|
||||||
transition: none !important;
|
transition: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ export default (theme: ISettings['theme'], withAnimation: boolean) => {
|
|||||||
|
|
||||||
document.documentElement.classList.remove(`theme-${isDarkTheme ? 'light' : 'dark'}`);
|
document.documentElement.classList.remove(`theme-${isDarkTheme ? 'light' : 'dark'}`);
|
||||||
if (isInitialized) {
|
if (isInitialized) {
|
||||||
document.documentElement.classList.add('disable-animations');
|
document.documentElement.classList.add('no-animations');
|
||||||
}
|
}
|
||||||
document.documentElement.classList.add(`theme-${theme}`);
|
document.documentElement.classList.add(`theme-${theme}`);
|
||||||
if (themeColorTag) {
|
if (themeColorTag) {
|
||||||
@ -44,7 +44,7 @@ export default (theme: ISettings['theme'], withAnimation: boolean) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
document.documentElement.classList.remove('disable-animations');
|
document.documentElement.classList.remove('no-animations');
|
||||||
}, ENABLE_ANIMATION_DELAY_MS);
|
}, ENABLE_ANIMATION_DELAY_MS);
|
||||||
|
|
||||||
isInitialized = true;
|
isInitialized = true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user