Skip to content

Commit a49b92e

Browse files
committed
feat(core): adjust sidebar style, add github & learn more (#7864)
close AF-1202
1 parent cfe0677 commit a49b92e

File tree

8 files changed

+74
-4
lines changed

8 files changed

+74
-4
lines changed

packages/frontend/core/src/components/app-sidebar/index.css.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { cssVar } from '@toeverything/theme';
22
import { style } from '@vanilla-extract/css';
33
export const floatingMaxWidth = 768;
44
export const navWrapperStyle = style({
5-
paddingBottom: '8px',
65
'@media': {
76
print: {
87
display: 'none',
@@ -16,6 +15,9 @@ export const navWrapperStyle = style({
1615
'&[data-is-floating="true"]': {
1716
backgroundColor: cssVar('backgroundPrimaryColor'),
1817
},
18+
'&[data-client-border="true"]': {
19+
paddingBottom: 8,
20+
},
1921
},
2022
});
2123
export const navHeaderButton = style({

packages/frontend/core/src/components/app-sidebar/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export function AppSidebar({
102102
data-has-border={hasRightBorder}
103103
data-testid="app-sidebar-wrapper"
104104
data-is-macos-electron={isMacosDesktop}
105+
data-client-border={clientBorder}
105106
>
106107
<nav className={navStyle} data-testid="app-sidebar">
107108
{!environment.isDesktop && <SidebarHeader />}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { DualLinkIcon } from '@blocksuite/icons/rc';
2+
import { cssVarV2 } from '@toeverything/theme/v2';
3+
import type { ReactElement } from 'react';
4+
import type { To } from 'react-router-dom';
5+
6+
import { MenuLinkItem } from '.';
7+
8+
const RawLink = ({
9+
children,
10+
to,
11+
className,
12+
}: {
13+
children?: React.ReactNode;
14+
to: To;
15+
className?: string;
16+
}) => {
17+
const href = typeof to === 'string' ? to : to.pathname;
18+
return (
19+
<a className={className} href={href} target="_blank" rel="noreferrer">
20+
{children}
21+
</a>
22+
);
23+
};
24+
25+
export const ExternalMenuLinkItem = ({
26+
href,
27+
icon,
28+
label,
29+
}: {
30+
href: string;
31+
icon: ReactElement;
32+
label: string;
33+
}) => {
34+
return (
35+
<MenuLinkItem to={href} linkComponent={RawLink} icon={icon}>
36+
{label}
37+
<DualLinkIcon
38+
width={12}
39+
height={12}
40+
style={{ marginLeft: 4, color: cssVarV2('icon/tertiary') }}
41+
/>
42+
</MenuLinkItem>
43+
);
44+
};

packages/frontend/core/src/components/app-sidebar/quick-search-input/index.css.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export const root = style({
1313
userSelect: 'none',
1414
cursor: 'pointer',
1515
padding: '0 12px',
16-
margin: '20px 0',
1716
position: 'relative',
1817
whiteSpace: 'nowrap',
1918
});

packages/frontend/core/src/components/app-sidebar/sidebar-containers/index.css.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ export const baseContainer = style({
44
padding: '4px 16px',
55
display: 'flex',
66
flexFlow: 'column nowrap',
7+
':empty': {
8+
display: 'none',
9+
},
710
});
811
export const scrollableContainerRoot = style({
912
flex: '1 1 auto',
@@ -30,6 +33,8 @@ export const scrollTopBorder = style({
3033
export const scrollableViewport = style({
3134
height: '100%',
3235
marginTop: '4px',
36+
// safe area to avoid bottom clipping
37+
paddingBottom: 8,
3338
});
3439
globalStyle(`${scrollableViewport} > div`, {
3540
maxWidth: '100%',

packages/frontend/core/src/components/root-app-sidebar/index.css.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const quickSearchAndNewPage = style({
1313
display: 'flex',
1414
alignItems: 'center',
1515
gap: 8,
16+
padding: '8px 0',
1617
});
1718
export const quickSearch = style({
1819
width: 0,

packages/frontend/core/src/components/root-app-sidebar/index.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ import { CMDKQuickSearchService } from '@affine/core/modules/quicksearch/service
1212
import { isNewTabTrigger } from '@affine/core/utils';
1313
import { events } from '@affine/electron-api';
1414
import { useI18n } from '@affine/i18n';
15-
import { AllDocsIcon, SettingsIcon } from '@blocksuite/icons/rc';
15+
import {
16+
AllDocsIcon,
17+
GithubIcon,
18+
JournalIcon,
19+
SettingsIcon,
20+
} from '@blocksuite/icons/rc';
1621
import type { Doc } from '@blocksuite/store';
1722
import type { Workspace } from '@toeverything/infra';
1823
import { useLiveData, useService, WorkspaceService } from '@toeverything/infra';
@@ -33,6 +38,7 @@ import {
3338
SidebarContainer,
3439
SidebarScrollableContainer,
3540
} from '../app-sidebar';
41+
import { ExternalMenuLinkItem } from '../app-sidebar/menu-item/external-menu-link-item';
3642
import { usePageHelper } from '../blocksuite/block-suite-page-list/utils';
3743
import { WorkspaceSelector } from '../workspace-selector';
3844
import ImportPage from './import-page';
@@ -158,6 +164,16 @@ export const RootAppSidebar = (): ReactElement => {
158164
<div style={{ padding: '0 8px' }}>
159165
<TrashButton />
160166
<ImportPage docCollection={docCollection} />
167+
<ExternalMenuLinkItem
168+
href="https://affine.pro/blog?tag=Release+Note"
169+
icon={<JournalIcon />}
170+
label={t['com.affine.app-sidebar.learn-more']()}
171+
/>
172+
<ExternalMenuLinkItem
173+
href="https://github.com/toeverything/affine"
174+
icon={<GithubIcon />}
175+
label={t['com.affine.app-sidebar.star-us']()}
176+
/>
161177
</div>
162178
</SidebarScrollableContainer>
163179
<SidebarContainer>

packages/frontend/i18n/src/resources/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1456,5 +1456,7 @@
14561456
"unnamed": "unnamed",
14571457
"upgradeBrowser": "Please upgrade to the latest version of Chrome for the best experience.",
14581458
"will be moved to Trash": "{{title}} will be moved to trash",
1459-
"will delete member": "will delete member"
1459+
"will delete member": "will delete member",
1460+
"com.affine.app-sidebar.star-us": "Star us",
1461+
"com.affine.app-sidebar.learn-more": "Learn more"
14601462
}

0 commit comments

Comments
 (0)