feat(core): move sidebar new page button beside quick-search (#7578)

close AF-1078
This commit is contained in:
CatsJuice 2024-07-26 03:04:10 +00:00
parent a714961b20
commit 22c36102b9
No known key found for this signature in database
GPG Key ID: 1C1E76924FAFDDE4
7 changed files with 52 additions and 63 deletions

View File

@ -1,30 +1,16 @@
import { cssVar } from '@toeverything/theme';
import { cssVarV2 } from '@toeverything/theme/v2';
import { style } from '@vanilla-extract/css';
export const root = style({
display: 'inline-flex',
background: cssVar('white30'),
alignItems: 'center',
borderRadius: '8px',
border: `1px solid ${cssVar('black10')}`,
fontSize: cssVar('fontSm'),
width: '100%',
position: 'relative',
height: '52px',
userSelect: 'none',
cursor: 'pointer',
padding: '0 24px',
transition: 'background 0.2s ease',
selectors: {
'&:active': {
background: cssVar('white50'),
},
},
width: 32,
height: 32,
borderRadius: 8,
boxShadow: '0px 1px 2px 0px rgba(0, 0, 0, 0.15)',
border: `1px solid ${cssVarV2('layer/border')}`,
background: cssVarV2('button/siderbarPrimary/background'),
});
export const icon = style({
marginRight: '18px',
color: cssVar('iconColor'),
fontSize: '24px',
});
export const spacer = style({
flex: 1,
color: cssVarV2('icon/primary'),
fontSize: 20,
display: 'block',
});

View File

@ -1,16 +0,0 @@
import type { Meta, StoryFn } from '@storybook/react';
import { AddPageButton } from './index';
export default {
title: 'Components/AppSidebar/AddPageButton',
component: AddPageButton,
} satisfies Meta;
export const Default: StoryFn = () => {
return (
<main style={{ width: '240px' }}>
<AddPageButton onClick={() => alert('opened')} />
</main>
);
};

View File

@ -1,9 +1,9 @@
import { Button, Tooltip } from '@affine/component';
import { useI18n } from '@affine/i18n';
import { PlusIcon } from '@blocksuite/icons/rc';
import clsx from 'clsx';
import type React from 'react';
import { Spotlight } from '../spolight';
import * as styles from './index.css';
interface AddPageButtonProps {
@ -20,14 +20,15 @@ export function AddPageButton({
const t = useI18n();
return (
<button
data-testid="sidebar-new-page-button"
style={style}
className={clsx([styles.root, className])}
onClick={onClick}
>
<PlusIcon className={styles.icon} /> {t['New Page']()}
<Spotlight />
</button>
<Tooltip content={t['New Page']()} side="bottom">
<Button
data-testid="sidebar-new-page-button"
style={style}
className={clsx([styles.root, className])}
onClick={onClick}
>
<PlusIcon className={styles.icon} />
</Button>
</Tooltip>
);
}

View File

@ -1,11 +1,12 @@
import { cssVar } from '@toeverything/theme';
import { cssVarV2 } from '@toeverything/theme/v2';
import { style } from '@vanilla-extract/css';
export const root = style({
display: 'inline-flex',
background: cssVar('white10'),
background: cssVarV2('button/siderbarPrimary/background'),
alignItems: 'center',
borderRadius: '8px',
border: `1px solid ${cssVar('black10')}`,
border: `1px solid ${cssVarV2('layer/border')}`,
fontSize: cssVar('fontSm'),
width: '100%',
height: '36px',
@ -14,16 +15,17 @@ export const root = style({
padding: '0 12px',
margin: '20px 0',
position: 'relative',
whiteSpace: 'nowrap',
});
export const icon = style({
marginRight: '8px',
color: cssVar('iconColor'),
color: cssVarV2('icon/primary'),
fontSize: '20px',
});
export const spacer = style({
flex: 1,
});
export const shortcutHint = style({
color: cssVar('black30'),
color: cssVarV2('text/tertiary'),
fontSize: cssVar('fontBase'),
});

View File

@ -9,6 +9,15 @@ export const workspaceAndUserWrapper = style({
justifyContent: 'space-between',
gap: 8,
});
export const quickSearchAndNewPage = style({
display: 'flex',
alignItems: 'center',
gap: 8,
});
export const quickSearch = style({
width: 0,
flex: 1,
});
export const workspaceWrapper = style({
width: 0,

View File

@ -37,7 +37,12 @@ import { AddCollectionButton } from '../pure/workspace-slider-bar/collections/ad
import FavoriteList from '../pure/workspace-slider-bar/favorite/favorite-list';
import { WorkspaceSelector } from '../workspace-selector';
import ImportPage from './import-page';
import { workspaceAndUserWrapper, workspaceWrapper } from './index.css';
import {
quickSearch,
quickSearchAndNewPage,
workspaceAndUserWrapper,
workspaceWrapper,
} from './index.css';
import { AppSidebarJournalButton } from './journal-button';
import { UpdaterButton } from './updater-button';
import { UserInfo } from './user-info';
@ -176,10 +181,14 @@ export const RootAppSidebar = memo(
</div>
<UserInfo />
</div>
<QuickSearchInput
data-testid="slider-bar-quick-search-button"
onClick={onOpenQuickSearchModal}
/>
<div className={quickSearchAndNewPage}>
<QuickSearchInput
className={quickSearch}
data-testid="slider-bar-quick-search-button"
onClick={onOpenQuickSearchModal}
/>
<AddPageButton onClick={onClickNewPage} />
</div>
<RouteMenuLinkItem
icon={<FolderIcon />}
active={allPageActive}
@ -230,8 +239,6 @@ export const RootAppSidebar = memo(
</SidebarScrollableContainer>
<SidebarContainer>
{environment.isDesktop ? <UpdaterButton /> : <AppDownloadButton />}
<div style={{ height: '4px' }} />
<AddPageButton onClick={onClickNewPage} />
</SidebarContainer>
</AppSidebar>
);

View File

@ -233,7 +233,7 @@
"Publishing": "Publishing to web requires AFFiNE Cloud service.",
"Publishing Description": "After publishing to the web, everyone can view the content of this workspace through the link.",
"Quick Search": "Quick Search",
"Quick search": "Quick search",
"Quick search": "Search",
"Quick search placeholder": "Quick Search...",
"Quick search placeholder2": "Search in {{workspace}}",
"RFP": "Docs can be freely added/removed from pivots, remaining accessible from \"All Docs\".",