mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-16 09:36:17 +08:00
fix: slide bar button position error
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
StyledListItemForWorkspace,
|
||||
StyledNewPageButton,
|
||||
StyledSliderBar,
|
||||
StyledSliderBarWrapper,
|
||||
StyledSubListItem,
|
||||
} from './style';
|
||||
import { Arrow } from './icons';
|
||||
@@ -84,92 +85,95 @@ export const WorkSpaceSliderBar = () => {
|
||||
return (
|
||||
<>
|
||||
<StyledSliderBar show={show}>
|
||||
<StyledListItemForWorkspace>
|
||||
<WorkspaceSelector />
|
||||
</StyledListItemForWorkspace>
|
||||
<StyledListItem
|
||||
data-testid="sliderBar-quickSearchButton"
|
||||
style={{ cursor: 'pointer' }}
|
||||
onClick={() => {
|
||||
triggerQuickSearchModal();
|
||||
}}
|
||||
<Tooltip
|
||||
content={show ? 'Collapse sidebar' : 'Expand sidebar'}
|
||||
placement="right"
|
||||
visible={showTip}
|
||||
>
|
||||
<SearchIcon /> Quick search
|
||||
</StyledListItem>
|
||||
<Link href={{ pathname: paths.all }}>
|
||||
<StyledListItem active={router.pathname === paths.all}>
|
||||
<AllPagesIcon /> <span>All pages</span>
|
||||
</StyledListItem>
|
||||
</Link>
|
||||
<StyledListItem active={router.pathname === paths.favorite}>
|
||||
<StyledLink href={{ pathname: paths.favorite }}>
|
||||
<FavouritesIcon />
|
||||
Favourites
|
||||
</StyledLink>
|
||||
<IconButton
|
||||
darker={true}
|
||||
<StyledArrowButton
|
||||
data-testid="sliderBar-arrowButton"
|
||||
isShow={show}
|
||||
onClick={() => {
|
||||
setShowSubFavorite(!showSubFavorite);
|
||||
setShow(!show);
|
||||
setShowTip(false);
|
||||
}}
|
||||
onMouseEnter={() => {
|
||||
setShowTip(true);
|
||||
}}
|
||||
onMouseLeave={() => {
|
||||
setShowTip(false);
|
||||
}}
|
||||
>
|
||||
<ArrowDownIcon
|
||||
style={{
|
||||
transform: `rotate(${showSubFavorite ? '180' : '0'}deg)`,
|
||||
}}
|
||||
/>
|
||||
</IconButton>
|
||||
</StyledListItem>
|
||||
<FavoriteList showList={showSubFavorite} />
|
||||
|
||||
<Tooltip content="Coming soon" placement="right-start" zIndex={9999}>
|
||||
<StyledListItem
|
||||
disabled={true}
|
||||
onClick={() => {
|
||||
// triggerImportModal();
|
||||
}}
|
||||
>
|
||||
<ImportIcon /> Import
|
||||
</StyledListItem>
|
||||
<Arrow />
|
||||
</StyledArrowButton>
|
||||
</Tooltip>
|
||||
|
||||
<Link href={{ pathname: paths.trash }}>
|
||||
<StyledListItem active={router.pathname === paths.trash}>
|
||||
<TrashIcon /> Trash
|
||||
<StyledSliderBarWrapper>
|
||||
<StyledListItemForWorkspace>
|
||||
<WorkspaceSelector />
|
||||
</StyledListItemForWorkspace>
|
||||
<StyledListItem
|
||||
data-testid="sliderBar-quickSearchButton"
|
||||
style={{ cursor: 'pointer' }}
|
||||
onClick={() => {
|
||||
triggerQuickSearchModal();
|
||||
}}
|
||||
>
|
||||
<SearchIcon /> Quick search
|
||||
</StyledListItem>
|
||||
</Link>
|
||||
<StyledNewPageButton
|
||||
onClick={async () => {
|
||||
const pageId = await createPage?.();
|
||||
if (pageId) {
|
||||
openPage(pageId);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<AddIcon /> New Page
|
||||
</StyledNewPageButton>
|
||||
<Link href={{ pathname: paths.all }}>
|
||||
<StyledListItem active={router.pathname === paths.all}>
|
||||
<AllPagesIcon /> <span>All pages</span>
|
||||
</StyledListItem>
|
||||
</Link>
|
||||
<StyledListItem active={router.pathname === paths.favorite}>
|
||||
<StyledLink href={{ pathname: paths.favorite }}>
|
||||
<FavouritesIcon />
|
||||
Favourites
|
||||
</StyledLink>
|
||||
<IconButton
|
||||
darker={true}
|
||||
onClick={() => {
|
||||
setShowSubFavorite(!showSubFavorite);
|
||||
}}
|
||||
>
|
||||
<ArrowDownIcon
|
||||
style={{
|
||||
transform: `rotate(${showSubFavorite ? '180' : '0'}deg)`,
|
||||
}}
|
||||
/>
|
||||
</IconButton>
|
||||
</StyledListItem>
|
||||
<FavoriteList showList={showSubFavorite} />
|
||||
|
||||
<Tooltip content="Coming soon" placement="right-start" zIndex={9999}>
|
||||
<StyledListItem
|
||||
disabled={true}
|
||||
onClick={() => {
|
||||
// triggerImportModal();
|
||||
}}
|
||||
>
|
||||
<ImportIcon /> Import
|
||||
</StyledListItem>
|
||||
</Tooltip>
|
||||
|
||||
<Link href={{ pathname: paths.trash }}>
|
||||
<StyledListItem active={router.pathname === paths.trash}>
|
||||
<TrashIcon /> Trash
|
||||
</StyledListItem>
|
||||
</Link>
|
||||
<StyledNewPageButton
|
||||
onClick={async () => {
|
||||
const pageId = await createPage?.();
|
||||
if (pageId) {
|
||||
openPage(pageId);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<AddIcon /> New Page
|
||||
</StyledNewPageButton>
|
||||
</StyledSliderBarWrapper>
|
||||
</StyledSliderBar>
|
||||
<Tooltip
|
||||
content={show ? 'Collapse sidebar' : 'Expand sidebar'}
|
||||
placement="right"
|
||||
visible={showTip}
|
||||
>
|
||||
<StyledArrowButton
|
||||
data-testid="sliderBar-arrowButton"
|
||||
isShow={show}
|
||||
onClick={() => {
|
||||
setShow(!show);
|
||||
setShowTip(false);
|
||||
}}
|
||||
onMouseEnter={() => {
|
||||
setShowTip(true);
|
||||
}}
|
||||
onMouseLeave={() => {
|
||||
setShowTip(false);
|
||||
}}
|
||||
>
|
||||
<Arrow />
|
||||
</StyledArrowButton>
|
||||
</Tooltip>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -8,15 +8,21 @@ export const StyledSliderBar = styled.div<{ show: boolean }>(
|
||||
height: '100vh',
|
||||
background: theme.mode === 'dark' ? '#272727' : '#FBFBFC',
|
||||
boxShadow: theme.shadow.modal,
|
||||
transition: 'width .15s',
|
||||
transition: 'width .15s, padding .15s',
|
||||
position: 'relative',
|
||||
zIndex: theme.zIndex.modal,
|
||||
padding: show ? '24px 12px' : '24px 0',
|
||||
overflowX: 'hidden',
|
||||
flexShrink: 0,
|
||||
};
|
||||
}
|
||||
);
|
||||
export const StyledSliderBarWrapper = styled.div(() => {
|
||||
return {
|
||||
height: '100%',
|
||||
overflowX: 'hidden',
|
||||
overflowY: 'auto',
|
||||
};
|
||||
});
|
||||
|
||||
export const StyledArrowButton = styled.button<{ isShow: boolean }>(
|
||||
({ theme, isShow }) => {
|
||||
@@ -28,9 +34,9 @@ export const StyledArrowButton = styled.button<{ isShow: boolean }>(
|
||||
backgroundColor: theme.colors.hoverBackground,
|
||||
borderRadius: '50%',
|
||||
transition: 'all .15s',
|
||||
position: 'relative',
|
||||
position: 'absolute',
|
||||
top: '34px',
|
||||
left: isShow ? '-16px' : '-8px',
|
||||
right: '-20px',
|
||||
zIndex: theme.zIndex.modal,
|
||||
svg: {
|
||||
transform: isShow ? 'rotate(180deg)' : 'unset',
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// import { useRef } from 'react';
|
||||
// import { AppStateContext } from '@/providers/app-state-provider';
|
||||
//
|
||||
// export const useLoadWorkspace = ({}:{
|
||||
// state,
|
||||
// loadWorkspaceHandler
|
||||
// }) => {
|
||||
// const loadWorkspace = useRef<AppStateContext['loadWorkspace']>(() =>
|
||||
// Promise.resolve(null)
|
||||
// );
|
||||
// loadWorkspace.current = async (workspaceId: string) => {
|
||||
// if (state.currentWorkspaceId === workspaceId) {
|
||||
// return state.currentWorkspace;
|
||||
// }
|
||||
//
|
||||
// const workspace =
|
||||
// (await loadWorkspaceHandler?.(workspaceId, true, state.user)) || null;
|
||||
//
|
||||
// // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// // @ts-expect-error
|
||||
// window.workspace = workspace;
|
||||
// // FIXME: there needs some method to destroy websocket.
|
||||
// // Or we need a manager to manage websocket.
|
||||
// // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// // @ts-expect-error
|
||||
// state.currentWorkspace?.__ws__?.destroy();
|
||||
//
|
||||
// setState(state => ({
|
||||
// ...state,
|
||||
// currentWorkspace: workspace,
|
||||
// currentWorkspaceId: workspaceId,
|
||||
// }));
|
||||
// return workspace;
|
||||
// };
|
||||
// };
|
||||
@@ -0,0 +1,46 @@
|
||||
import { useEffect } from 'react';
|
||||
import {
|
||||
AccessTokenMessage,
|
||||
getWorkspaces,
|
||||
token,
|
||||
} from '@pathfinder/data-services';
|
||||
import { LoadWorkspaceHandler } from '../context';
|
||||
|
||||
export const useSyncData = ({
|
||||
loadWorkspaceHandler,
|
||||
}: {
|
||||
loadWorkspaceHandler: LoadWorkspaceHandler;
|
||||
}) => {
|
||||
useEffect(() => {
|
||||
if (!loadWorkspaceHandler) {
|
||||
return;
|
||||
}
|
||||
const start = async () => {
|
||||
const isLogin = await token.refreshToken().catch(() => false);
|
||||
};
|
||||
start();
|
||||
|
||||
const callback = async (user: AccessTokenMessage | null) => {
|
||||
const workspacesMeta = user
|
||||
? await getWorkspaces().catch(() => {
|
||||
return [];
|
||||
})
|
||||
: [];
|
||||
// setState(state => ({
|
||||
// ...state,
|
||||
// user: user,
|
||||
// workspacesMeta,
|
||||
// synced: true,
|
||||
// }));
|
||||
};
|
||||
|
||||
token.onChange(callback);
|
||||
token.refreshToken().catch(err => {
|
||||
// FIXME: should resolve invalid refresh token
|
||||
console.log(err);
|
||||
});
|
||||
return () => {
|
||||
token.offChange(callback);
|
||||
};
|
||||
}, [loadWorkspaceHandler]);
|
||||
};
|
||||
Reference in New Issue
Block a user