refactor(component): make component pure (#5427)

This commit is contained in:
EYHN
2023-12-28 09:57:26 +00:00
parent e11e8277ca
commit 9d51f9596f
19 changed files with 307 additions and 273 deletions

View File

@@ -1,17 +1,17 @@
import {
type AddPageButtonPureProps,
AppUpdaterButtonPure,
type AddPageButtonProps,
AppUpdaterButton,
} from '@affine/component/app-sidebar';
import type { Meta, StoryFn } from '@storybook/react';
import type { PropsWithChildren } from 'react';
export default {
title: 'AFFiNE/AppUpdaterButton',
component: AppUpdaterButtonPure,
component: AppUpdaterButton,
parameters: {
chromatic: { disableSnapshot: true },
},
} satisfies Meta<typeof AppUpdaterButtonPure>;
} satisfies Meta<typeof AppUpdaterButton>;
const Container = ({ children }: PropsWithChildren) => (
<main
@@ -28,10 +28,10 @@ const Container = ({ children }: PropsWithChildren) => (
</main>
);
export const Default: StoryFn<AddPageButtonPureProps> = props => {
export const Default: StoryFn<AddPageButtonProps> = props => {
return (
<Container>
<AppUpdaterButtonPure {...props} />
<AppUpdaterButton {...props} />
</Container>
);
};
@@ -44,17 +44,18 @@ Default.args = {
allowAutoUpdate: true,
},
downloadProgress: 42,
currentChangelogUnread: true,
changelogUnread: true,
autoDownload: false,
};
export const Updated: StoryFn<AddPageButtonPureProps> = props => {
export const Updated: StoryFn<AddPageButtonProps> = props => {
return (
<Container>
<AppUpdaterButtonPure {...props} updateAvailable={null} />
<AppUpdaterButton {...props} updateAvailable={null} />
</Container>
);
};
Updated.args = {
currentChangelogUnread: true,
changelogUnread: true,
};

View File

@@ -21,6 +21,9 @@ export const Default = () => {
onClick={() => {}}
onSettingClick={() => {}}
onDragEnd={_ => {}}
useWorkspaceAvatar={() => undefined}
useWorkspaceName={() => undefined}
useIsWorkspaceOwner={() => false}
/>
);
};