fix: sidebar ui fix (#4187)

This commit is contained in:
Peng Xiao
2023-09-05 17:48:48 +08:00
committed by GitHub
parent dfa5fefa7f
commit 8b4f2a6c50
2 changed files with 5 additions and 4 deletions

View File

@@ -35,7 +35,7 @@ export const navWrapperStyle = style({
'&[data-enable-animation="true"]': {
transition: 'margin-left .3s .05s, width .3s .05s',
},
'&.has-background': {
'&[data-is-floating="false"].has-background': {
backgroundColor: 'var(--affine-white-60)',
borderRight: '1px solid var(--affine-border-color)',
},

View File

@@ -2,6 +2,7 @@ import { Skeleton } from '@mui/material';
import { assignInlineVars } from '@vanilla-extract/dynamic';
import clsx from 'clsx';
import { useAtom, useAtomValue } from 'jotai';
import debounce from 'lodash/debounce';
import type { PropsWithChildren, ReactElement } from 'react';
import { useEffect, useRef, useState } from 'react';
@@ -77,10 +78,10 @@ export function AppSidebar(props: AppSidebarProps): ReactElement {
setAppSidebarFloating(isFloating && !!open);
}
onResize();
window.addEventListener('resize', onResize);
const dOnResize = debounce(onResize, 50);
window.addEventListener('resize', dOnResize);
return () => {
window.removeEventListener('resize', onResize);
window.removeEventListener('resize', dOnResize);
};
}, [appSidebarWidth, open, setAppSidebarFloating, setOpen]);