feat(core): make sidebar others collapsible (#9862)
This commit is contained in:
@@ -3,7 +3,6 @@ import {
|
|||||||
AddPageButton,
|
AddPageButton,
|
||||||
AppDownloadButton,
|
AppDownloadButton,
|
||||||
AppSidebar,
|
AppSidebar,
|
||||||
CategoryDivider,
|
|
||||||
MenuItem,
|
MenuItem,
|
||||||
MenuLinkItem,
|
MenuLinkItem,
|
||||||
QuickSearchInput,
|
QuickSearchInput,
|
||||||
@@ -13,6 +12,7 @@ import {
|
|||||||
import { ExternalMenuLinkItem } from '@affine/core/modules/app-sidebar/views/menu-item/external-menu-link-item';
|
import { ExternalMenuLinkItem } from '@affine/core/modules/app-sidebar/views/menu-item/external-menu-link-item';
|
||||||
import { WorkspaceDialogService } from '@affine/core/modules/dialogs';
|
import { WorkspaceDialogService } from '@affine/core/modules/dialogs';
|
||||||
import {
|
import {
|
||||||
|
CollapsibleSection,
|
||||||
ExplorerCollections,
|
ExplorerCollections,
|
||||||
ExplorerFavorites,
|
ExplorerFavorites,
|
||||||
ExplorerMigrationFavorites,
|
ExplorerMigrationFavorites,
|
||||||
@@ -175,8 +175,11 @@ export const RootAppSidebar = memo((): ReactElement => {
|
|||||||
<ExplorerMigrationFavorites />
|
<ExplorerMigrationFavorites />
|
||||||
<ExplorerCollections />
|
<ExplorerCollections />
|
||||||
<ExplorerTags />
|
<ExplorerTags />
|
||||||
<CategoryDivider label={t['com.affine.rootAppSidebar.others']()} />
|
<CollapsibleSection
|
||||||
<div style={{ padding: '0 8px' }}>
|
name="others"
|
||||||
|
title={t['com.affine.rootAppSidebar.others']()}
|
||||||
|
contentStyle={{ padding: '6px 8px 0 8px' }}
|
||||||
|
>
|
||||||
<TrashButton />
|
<TrashButton />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
data-testid="slider-bar-import-button"
|
data-testid="slider-bar-import-button"
|
||||||
@@ -191,7 +194,7 @@ export const RootAppSidebar = memo((): ReactElement => {
|
|||||||
icon={<JournalIcon />}
|
icon={<JournalIcon />}
|
||||||
label={t['com.affine.app-sidebar.learn-more']()}
|
label={t['com.affine.app-sidebar.learn-more']()}
|
||||||
/>
|
/>
|
||||||
</div>
|
</CollapsibleSection>
|
||||||
</SidebarScrollableContainer>
|
</SidebarScrollableContainer>
|
||||||
<SidebarContainer>
|
<SidebarContainer>
|
||||||
{BUILD_CONFIG.isElectron ? <UpdaterButton /> : <AppDownloadButton />}
|
{BUILD_CONFIG.isElectron ? <UpdaterButton /> : <AppDownloadButton />}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ const DEFAULT_COLLAPSABLE_STATE: Record<CollapsibleSectionName, boolean> = {
|
|||||||
tags: true,
|
tags: true,
|
||||||
favoritesOld: true,
|
favoritesOld: true,
|
||||||
migrationFavorites: true,
|
migrationFavorites: true,
|
||||||
|
others: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export class ExplorerSection extends Entity<{ name: CollapsibleSectionName }> {
|
export class ExplorerSection extends Entity<{ name: CollapsibleSectionName }> {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ const allSectionName: Array<CollapsibleSectionName> = [
|
|||||||
'tags',
|
'tags',
|
||||||
'favoritesOld',
|
'favoritesOld',
|
||||||
'migrationFavorites',
|
'migrationFavorites',
|
||||||
|
'others',
|
||||||
];
|
];
|
||||||
|
|
||||||
export class ExplorerService extends Service {
|
export class ExplorerService extends Service {
|
||||||
|
|||||||
@@ -5,4 +5,5 @@ export type CollapsibleSectionName =
|
|||||||
| 'tags'
|
| 'tags'
|
||||||
| 'organize'
|
| 'organize'
|
||||||
| 'favoritesOld'
|
| 'favoritesOld'
|
||||||
| 'migrationFavorites';
|
| 'migrationFavorites'
|
||||||
|
| 'others';
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import * as Collapsible from '@radix-ui/react-collapsible';
|
|||||||
import { useLiveData, useService } from '@toeverything/infra';
|
import { useLiveData, useService } from '@toeverything/infra';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import {
|
import {
|
||||||
|
type CSSProperties,
|
||||||
type PropsWithChildren,
|
type PropsWithChildren,
|
||||||
type ReactNode,
|
type ReactNode,
|
||||||
type RefObject,
|
type RefObject,
|
||||||
@@ -26,6 +27,7 @@ interface CollapsibleSectionProps extends PropsWithChildren {
|
|||||||
headerClassName?: string;
|
headerClassName?: string;
|
||||||
|
|
||||||
contentClassName?: string;
|
contentClassName?: string;
|
||||||
|
contentStyle?: CSSProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CollapsibleSection = ({
|
export const CollapsibleSection = ({
|
||||||
@@ -42,6 +44,7 @@ export const CollapsibleSection = ({
|
|||||||
headerClassName,
|
headerClassName,
|
||||||
|
|
||||||
contentClassName,
|
contentClassName,
|
||||||
|
contentStyle,
|
||||||
}: CollapsibleSectionProps) => {
|
}: CollapsibleSectionProps) => {
|
||||||
const section = useService(ExplorerService).sections[name];
|
const section = useService(ExplorerService).sections[name];
|
||||||
|
|
||||||
@@ -74,6 +77,7 @@ export const CollapsibleSection = ({
|
|||||||
<Collapsible.Content
|
<Collapsible.Content
|
||||||
data-testid="collapsible-section-content"
|
data-testid="collapsible-section-content"
|
||||||
className={clsx(content, contentClassName)}
|
className={clsx(content, contentClassName)}
|
||||||
|
style={contentStyle}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Collapsible.Content>
|
</Collapsible.Content>
|
||||||
|
|||||||
Reference in New Issue
Block a user