refactor: clean all pages component (#2176)

Co-authored-by: himself65 <himself65@outlook.com>
This commit is contained in:
Whitewater
2023-05-04 20:59:16 -07:00
committed by GitHub
parent 2c49c774af
commit 84b36c1d35
32 changed files with 772 additions and 504 deletions

View File

@@ -44,5 +44,5 @@ export const Close: StoryFn = () => {
Close.play = async ({ canvasElement }) => {
const element = within(canvasElement);
await new Promise(resolve => setTimeout(resolve, 2000));
await element.getByTestId('change-log-close-button').click();
element.getByTestId('change-log-close-button').click();
};

View File

@@ -0,0 +1,89 @@
import { PageIcon } from '@blocksuite/icons';
import type { StoryFn } from '@storybook/react';
import { AffineLoading } from '../components/affine-loading';
import type {
PageListProps,
TrashListData,
} from '../components/page-list/all-page';
import { PageListTrashView } from '../components/page-list/all-page';
import PageList from '../components/page-list/all-page';
import type { OperationCellProps } from '../components/page-list/operation-cell';
import { OperationCell } from '../components/page-list/operation-cell';
import { toast } from '../ui/toast';
export default {
title: 'AFFiNE/PageList',
component: AffineLoading,
};
export const AffineOperationCell: StoryFn<OperationCellProps> = ({
...props
}) => (
<div>
<OperationCell {...props} />
</div>
);
AffineOperationCell.args = {
title: 'Example Page',
favorite: false,
isPublic: true,
onToggleFavoritePage: () => toast('Toggle favorite page'),
onDisablePublicSharing: () => toast('Disable public sharing'),
onOpenPageInNewTab: () => toast('Open page in new tab'),
onRemoveToTrash: () => toast('Remove to trash'),
};
export const AffineAllPageList: StoryFn<PageListProps> = ({ ...props }) => (
<div>
<PageList {...props} />
</div>
);
AffineAllPageList.args = {
isPublicWorkspace: false,
listType: 'all',
list: [
{
pageId: '1',
favorite: false,
icon: <PageIcon />,
isPublicPage: true,
title: 'Example Page',
updatedDate: '2021-01-01',
createDate: '2021-01-01',
trashDate: '2021-01-01',
bookmarkPage: () => toast('Bookmark page'),
onClickPage: () => toast('Click page'),
onDisablePublicSharing: () => toast('Disable public sharing'),
onOpenPageInNewTab: () => toast('Open page in new tab'),
removeToTrash: () => toast('Remove to trash'),
},
],
};
export const AffineTrashPageList: StoryFn<{
list: TrashListData[];
}> = ({ ...props }) => (
<div>
<PageListTrashView {...props} />
</div>
);
AffineTrashPageList.args = {
list: [
{
pageId: '1',
favorite: false,
icon: <PageIcon />,
title: 'Example Page',
updatedDate: '2021-01-01',
createDate: '2021-01-01',
trashDate: '2021-01-01',
onClickPage: () => toast('Click page'),
onPermanentlyDeletePage: () => toast('Permanently delete page'),
onRestorePage: () => toast('Restore page'),
},
],
};

View File

@@ -5,8 +5,11 @@ import { createEmptyBlockSuiteWorkspace } from '@affine/workspace/utils';
import type { Page } from '@blocksuite/store';
import { expect } from '@storybook/jest';
import type { StoryFn } from '@storybook/react';
import { useState } from 'react';
import { PublicLinkDisableModal } from '../components/share-menu/disable-public-link';
import { ShareMenu } from '../components/share-menu/ShareMenu';
import { StyledDisableButton } from '../components/share-menu/styles';
import toast from '../ui/toast/toast';
export default {
@@ -36,9 +39,9 @@ const blockSuiteWorkspace = createEmptyBlockSuiteWorkspace(
WorkspaceFlavour.LOCAL
);
initPage(blockSuiteWorkspace.createPage('page0'));
initPage(blockSuiteWorkspace.createPage('page1'));
initPage(blockSuiteWorkspace.createPage('page2'));
initPage(blockSuiteWorkspace.createPage({ id: 'page0' }));
initPage(blockSuiteWorkspace.createPage({ id: 'page1' }));
initPage(blockSuiteWorkspace.createPage({ id: 'page2' }));
const localWorkspace: LocalWorkspace = {
id: 'test-workspace',
@@ -103,3 +106,22 @@ export const AffineBasic: StoryFn = () => {
/>
);
};
export const DisableModal: StoryFn = () => {
const [open, setOpen] = useState(false);
return (
<>
<StyledDisableButton onClick={() => setOpen(!open)}>
Disable Public Link
</StyledDisableButton>
<PublicLinkDisableModal
open={open}
onConfirmDisable={() => {
toast('Disabled');
setOpen(false);
}}
onClose={() => setOpen(false)}
/>
</>
);
};

View File

@@ -11,6 +11,3 @@ export default {
export const Basic: StoryFn = () => {
return <Switch />;
};
Basic.args = {
logoSrc: '/imgs/affine-text-logo.png',
};