fix(core): make sidebar switch transition smooth (#6085)
This commit is contained in:
@@ -1,18 +1,23 @@
|
|||||||
import { style } from '@vanilla-extract/css';
|
import { style } from '@vanilla-extract/css';
|
||||||
|
|
||||||
export const sidebarSwitch = style({
|
export const sidebarSwitch = style({
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
display: 'none !important',
|
display: 'inline-flex',
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
pointerEvents: 'none',
|
pointerEvents: 'none',
|
||||||
transition: 'all .3s ease-in-out',
|
transition: 'max-width 0.2s ease-in-out, margin 0.3s ease-in-out',
|
||||||
selectors: {
|
selectors: {
|
||||||
'&[data-show=true]': {
|
'&[data-show=true]': {
|
||||||
|
maxWidth: '32px',
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
display: 'inline-flex !important',
|
|
||||||
width: '32px',
|
width: '32px',
|
||||||
flexShrink: 0,
|
flexShrink: 0,
|
||||||
fontSize: '24px',
|
fontSize: '24px',
|
||||||
pointerEvents: 'auto',
|
pointerEvents: 'auto',
|
||||||
},
|
},
|
||||||
|
'&[data-show=false]': {
|
||||||
|
maxWidth: 0,
|
||||||
|
margin: '0 !important',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ import { appSidebarOpenAtom } from '../index.jotai';
|
|||||||
import * as styles from './sidebar-switch.css';
|
import * as styles from './sidebar-switch.css';
|
||||||
|
|
||||||
export const SidebarSwitch = ({
|
export const SidebarSwitch = ({
|
||||||
show = true,
|
show,
|
||||||
className,
|
className,
|
||||||
}: {
|
}: {
|
||||||
show?: boolean;
|
show: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
}) => {
|
}) => {
|
||||||
const [open, setOpen] = useAtom(appSidebarOpenAtom);
|
const [open, setOpen] = useAtom(appSidebarOpenAtom);
|
||||||
|
|||||||
@@ -39,7 +39,20 @@ export const leftSidebarButton = style({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const rightSidebarButton = style({
|
export const rightSidebarButton = style({
|
||||||
margin: '0 0 0 16px',
|
transition: 'all 0.2s ease-in-out',
|
||||||
|
selectors: {
|
||||||
|
'&[data-show=true]': {
|
||||||
|
opacity: 1,
|
||||||
|
width: 32,
|
||||||
|
maxWidth: 32,
|
||||||
|
marginLeft: 16,
|
||||||
|
},
|
||||||
|
'&[data-show=false]': {
|
||||||
|
opacity: 0,
|
||||||
|
maxWidth: 0,
|
||||||
|
marginLeft: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const viewHeaderContainer = style({
|
export const viewHeaderContainer = style({
|
||||||
|
|||||||
@@ -25,12 +25,19 @@ export interface Props {
|
|||||||
const ToggleButton = ({
|
const ToggleButton = ({
|
||||||
onToggle,
|
onToggle,
|
||||||
className,
|
className,
|
||||||
|
show,
|
||||||
}: {
|
}: {
|
||||||
onToggle?: () => void;
|
onToggle?: () => void;
|
||||||
className: string;
|
className: string;
|
||||||
|
show: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<IconButton size="large" onClick={onToggle} className={className}>
|
<IconButton
|
||||||
|
size="large"
|
||||||
|
onClick={onToggle}
|
||||||
|
className={className}
|
||||||
|
data-show={show}
|
||||||
|
>
|
||||||
<RightSidebarIcon />
|
<RightSidebarIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
@@ -50,14 +57,18 @@ export const RouteContainer = ({ route }: Props) => {
|
|||||||
return (
|
return (
|
||||||
<div className={styles.root}>
|
<div className={styles.root}>
|
||||||
<div className={styles.header}>
|
<div className={styles.header}>
|
||||||
{viewPosition.isFirst && !leftSidebarOpen && (
|
{viewPosition.isFirst && (
|
||||||
<SidebarSwitch className={styles.leftSidebarButton} />
|
<SidebarSwitch
|
||||||
|
show={!leftSidebarOpen}
|
||||||
|
className={styles.leftSidebarButton}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
<view.header.Target className={styles.viewHeaderContainer} />
|
<view.header.Target className={styles.viewHeaderContainer} />
|
||||||
{viewPosition.isLast && !rightSidebarOpen && (
|
{viewPosition.isLast && (
|
||||||
<>
|
<>
|
||||||
{rightSidebarHasViews && (
|
{rightSidebarHasViews && (
|
||||||
<ToggleButton
|
<ToggleButton
|
||||||
|
show={!rightSidebarOpen}
|
||||||
className={styles.rightSidebarButton}
|
className={styles.rightSidebarButton}
|
||||||
onToggle={handleToggleRightSidebar}
|
onToggle={handleToggleRightSidebar}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user