From bf41b259888b2467ac29f4f63a8f10ce07932894 Mon Sep 17 00:00:00 2001 From: Whitewater Date: Tue, 18 Jul 2023 13:36:14 +0800 Subject: [PATCH] feat: new import page component (#3277) --- apps/storybook/src/stories/card.stories.tsx | 20 ++++- .../src/stories/import-page.stories.tsx | 19 +++++ .../src/components/card/block-card/index.tsx | 12 ++- .../components/card/block-card/styles.css.ts | 7 ++ .../src/components/import-page/index.css.ts | 43 +++++++++++ .../src/components/import-page/index.tsx | 76 +++++++++++++++++++ 6 files changed, 173 insertions(+), 4 deletions(-) create mode 100644 apps/storybook/src/stories/import-page.stories.tsx create mode 100644 packages/component/src/components/import-page/index.css.ts create mode 100644 packages/component/src/components/import-page/index.tsx diff --git a/apps/storybook/src/stories/card.stories.tsx b/apps/storybook/src/stories/card.stories.tsx index ac03299ade..3d18b37fbb 100644 --- a/apps/storybook/src/stories/card.stories.tsx +++ b/apps/storybook/src/stories/card.stories.tsx @@ -1,9 +1,14 @@ -import { toast } from '@affine/component'; +import { toast, Tooltip } from '@affine/component'; import { BlockCard } from '@affine/component/card/block-card'; import { WorkspaceCard } from '@affine/component/card/workspace-card'; import { WorkspaceFlavour } from '@affine/env/workspace'; import { createEmptyBlockSuiteWorkspace } from '@affine/workspace/utils'; -import { EdgelessIcon, PageIcon } from '@blocksuite/icons'; +import { + EdgelessIcon, + ExportToHtmlIcon, + HelpIcon, + PageIcon, +} from '@blocksuite/icons'; export default { title: 'AFFiNE/Card', @@ -48,6 +53,17 @@ export const AffineBlockCard = () => { right={} onClick={() => toast('clicked edgeless')} /> + } + title="HTML" + disabled + right={ + + + + } + onClick={() => toast('click HTML')} + /> ); }; diff --git a/apps/storybook/src/stories/import-page.stories.tsx b/apps/storybook/src/stories/import-page.stories.tsx new file mode 100644 index 0000000000..f7b4df5e16 --- /dev/null +++ b/apps/storybook/src/stories/import-page.stories.tsx @@ -0,0 +1,19 @@ +/* deepscan-disable USELESS_ARROW_FUNC_BIND */ +import { toast } from '@affine/component'; +import { ImportPage } from '@affine/component/import-page'; +import type { StoryFn } from '@storybook/react'; + +export default { + title: 'AFFiNE/ImportPage', + component: ImportPage, +}; + +const Template: StoryFn = args => ; + +export const Basic = Template.bind(undefined); +Basic.args = { + importHtml: () => toast('Click importHtml'), + importMarkdown: () => toast('Click importMarkdown'), + importNotion: () => toast('Click importNotion'), + onClose: () => toast('Click onClose'), +}; diff --git a/packages/component/src/components/card/block-card/index.tsx b/packages/component/src/components/card/block-card/index.tsx index ffdc614209..3ec1d1e96a 100644 --- a/packages/component/src/components/card/block-card/index.tsx +++ b/packages/component/src/components/card/block-card/index.tsx @@ -9,10 +9,18 @@ export const BlockCard = forwardRef< title: string; desc?: string; right?: ReactNode; + disabled?: boolean; } & HTMLAttributes ->(({ left, title, desc, right, ...props }, ref) => { +>(({ left, title, desc, right, disabled, onClick, ...props }, ref) => { return ( -
+
{left &&
{left}
}
{title}
diff --git a/packages/component/src/components/card/block-card/styles.css.ts b/packages/component/src/components/card/block-card/styles.css.ts index 710ae3c8e7..27ac781370 100644 --- a/packages/component/src/components/card/block-card/styles.css.ts +++ b/packages/component/src/components/card/block-card/styles.css.ts @@ -14,6 +14,13 @@ export const blockCard = style({ '&:hover': { boxShadow: 'var(--affine-shadow-1)', }, + '&[aria-disabled]': { + color: 'var(--affine-text-disable-color)', + }, + '&[aria-disabled]:hover': { + cursor: 'not-allowed', + boxShadow: 'none', + }, // TODO active styles }, }); diff --git a/packages/component/src/components/import-page/index.css.ts b/packages/component/src/components/import-page/index.css.ts new file mode 100644 index 0000000000..98c0435eb4 --- /dev/null +++ b/packages/component/src/components/import-page/index.css.ts @@ -0,0 +1,43 @@ +import { globalStyle, style } from '@vanilla-extract/css'; + +export const importPageContainerStyle = style({ + position: 'relative', + display: 'flex', + width: '480px', + flexDirection: 'column', + justifyContent: 'center', + alignItems: 'center', + borderRadius: '16px', + boxShadow: 'var(--affine-shadow-1)', +}); + +export const importPageBodyStyle = style({ + display: 'flex', + padding: '32px 40px 20px 40px', + flexDirection: 'column', + gap: '20px', + alignSelf: 'stretch', +}); + +export const importPageButtonContainerStyle = style({ + display: 'grid', + gridTemplateColumns: '1fr 1fr', + padding: '0px 40px 36px', + flexDirection: 'column', + alignItems: 'center', + gap: '20px', + alignSelf: 'stretch', +}); + +globalStyle(`${importPageBodyStyle} .title`, { + fontSize: 'var(--affine-font-h-6)', + fontWeight: 600, +}); + +globalStyle(`${importPageBodyStyle} a`, { + whiteSpace: 'nowrap', + wordBreak: 'break-word', + color: 'var(--affine-link-color)', + textDecoration: 'none', + cursor: 'pointer', +}); diff --git a/packages/component/src/components/import-page/index.tsx b/packages/component/src/components/import-page/index.tsx new file mode 100644 index 0000000000..e78b6a58fa --- /dev/null +++ b/packages/component/src/components/import-page/index.tsx @@ -0,0 +1,76 @@ +import { + ExportToHtmlIcon, + ExportToMarkdownIcon, + HelpIcon, + NewIcon, + NotionIcon, +} from '@blocksuite/icons'; + +import { ModalCloseButton } from '../../ui/modal'; +import { Tooltip } from '../../ui/tooltip'; +import { BlockCard } from '../card/block-card'; +import { + importPageBodyStyle, + importPageButtonContainerStyle, + importPageContainerStyle, +} from './index.css'; + +export const ImportPage = ({ + importMarkdown, + importHtml, + importNotion, + onClose, +}: { + importMarkdown: () => void; + importHtml: () => void; + importNotion: () => void; + onClose: () => void; +}) => ( +
+ +
+
Import
+ + AFFiNE will gradually support more and more file types for import.  + + Provide feedback. + + +
+
+ } + title="Markdown" + onClick={importMarkdown} + /> + } + title="HTML" + onClick={importHtml} + /> + } + title="Notion" + right={ + + + + } + onClick={importNotion} + /> + } + title="Coming soon..." + disabled + onClick={importHtml} + /> +
+
+);