mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
refactor(web): move contact modal to component (#1718)
This commit is contained in:
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
@@ -1,10 +1,9 @@
|
|||||||
import { Tooltip } from '@affine/component';
|
import { MuiFade, Tooltip } from '@affine/component';
|
||||||
import { MuiFade } from '@affine/component';
|
|
||||||
import { useTranslation } from '@affine/i18n';
|
import { useTranslation } from '@affine/i18n';
|
||||||
import { CloseIcon } from '@blocksuite/icons';
|
import { CloseIcon } from '@blocksuite/icons';
|
||||||
|
import dynamic from 'next/dynamic';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
import ContactModal from '../contact-modal';
|
|
||||||
import { ShortcutsModal } from '../shortcuts-modal';
|
import { ShortcutsModal } from '../shortcuts-modal';
|
||||||
import { ContactIcon, HelpIcon, KeyboardIcon } from './Icons';
|
import { ContactIcon, HelpIcon, KeyboardIcon } from './Icons';
|
||||||
import {
|
import {
|
||||||
@@ -13,6 +12,17 @@ import {
|
|||||||
StyledIsland,
|
StyledIsland,
|
||||||
StyledTriggerWrapper,
|
StyledTriggerWrapper,
|
||||||
} from './style';
|
} from './style';
|
||||||
|
|
||||||
|
const ContactModal = dynamic(
|
||||||
|
() =>
|
||||||
|
import('@affine/component/contact-modal').then(({ ContactModal }) => ({
|
||||||
|
default: ContactModal,
|
||||||
|
})),
|
||||||
|
{
|
||||||
|
ssr: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
export type IslandItemNames = 'contact' | 'shortcuts';
|
export type IslandItemNames = 'contact' | 'shortcuts';
|
||||||
export const HelpIsland = ({
|
export const HelpIsland = ({
|
||||||
showList = ['contact', 'shortcuts'],
|
showList = ['contact', 'shortcuts'],
|
||||||
@@ -93,7 +103,11 @@ export const HelpIsland = ({
|
|||||||
</StyledTriggerWrapper>
|
</StyledTriggerWrapper>
|
||||||
</MuiFade>
|
</MuiFade>
|
||||||
</StyledIsland>
|
</StyledIsland>
|
||||||
<ContactModal open={open} onClose={() => setOpen(false)} />
|
<ContactModal
|
||||||
|
open={open}
|
||||||
|
onClose={() => setOpen(false)}
|
||||||
|
logoSrc="/imgs/affine-text-logo.png"
|
||||||
|
/>
|
||||||
<ShortcutsModal
|
<ShortcutsModal
|
||||||
open={openShortCut}
|
open={openShortCut}
|
||||||
onClose={() => setOpenShortCut(false)}
|
onClose={() => setOpenShortCut(false)}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import '@blocksuite/editor/themes/affine.css';
|
import '@blocksuite/editor/themes/affine.css';
|
||||||
|
|
||||||
import { getDarkTheme, getLightTheme, ThemeProvider } from '../src';
|
import { getDarkTheme, getLightTheme, ThemeProvider } from '@affine/component';
|
||||||
import { useDarkMode } from 'storybook-dark-mode-v7';
|
import { useDarkMode } from 'storybook-dark-mode-v7';
|
||||||
export const parameters = {
|
export const parameters = {
|
||||||
actions: { argTypesRegex: '^on[A-Z].*' },
|
actions: { argTypesRegex: '^on[A-Z].*' },
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ const config: Pick<StorybookConfig, 'viteFinal'> = {
|
|||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'@': resolve(fileURLToPath(new URL('../src', import.meta.url))),
|
'@': resolve(fileURLToPath(new URL('../src', import.meta.url))),
|
||||||
|
'@affine/component': resolve(
|
||||||
|
fileURLToPath(new URL('../src/index.ts', import.meta.url))
|
||||||
|
),
|
||||||
'@affine/i18n': resolve(
|
'@affine/i18n': resolve(
|
||||||
fileURLToPath(new URL('../../i18n/src', import.meta.url))
|
fileURLToPath(new URL('../../i18n/src', import.meta.url))
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts",
|
".": "./src/index.ts",
|
||||||
"./block-suite-editor": "./src/components/block-suite-editor/index.tsx"
|
"./*": "./src/components/*/index.tsx"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@affine/debug": "workspace:*",
|
"@affine/debug": "workspace:*",
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
} from '@affine/component';
|
} from '@affine/component';
|
||||||
import { useTranslation } from '@affine/i18n';
|
import { useTranslation } from '@affine/i18n';
|
||||||
|
|
||||||
import logo from './affine-text-logo.png';
|
|
||||||
import {
|
import {
|
||||||
DiscordIcon,
|
DiscordIcon,
|
||||||
DocIcon,
|
DocIcon,
|
||||||
@@ -54,15 +53,17 @@ const linkList = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
type TransitionsModalProps = {
|
export type ContactModalProps = {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
logoSrc: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ContactModal = ({
|
export const ContactModal = ({
|
||||||
open,
|
open,
|
||||||
onClose,
|
onClose,
|
||||||
}: TransitionsModalProps): JSX.Element => {
|
logoSrc,
|
||||||
|
}: ContactModalProps): JSX.Element => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const topLinkList = [
|
const topLinkList = [
|
||||||
{
|
{
|
||||||
@@ -84,7 +85,7 @@ export const ContactModal = ({
|
|||||||
<Modal open={open} onClose={onClose} data-testid="contact-us-modal-content">
|
<Modal open={open} onClose={onClose} data-testid="contact-us-modal-content">
|
||||||
<ModalWrapper width={720} height={436} style={{ letterSpacing: '1px' }}>
|
<ModalWrapper width={720} height={436} style={{ letterSpacing: '1px' }}>
|
||||||
<StyledModalHeader>
|
<StyledModalHeader>
|
||||||
<StyledLogo src={logo.src} alt="" />
|
<StyledLogo src={logoSrc} alt="" />
|
||||||
|
|
||||||
<ModalCloseButton
|
<ModalCloseButton
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -124,10 +125,14 @@ export const ContactModal = ({
|
|||||||
<StyledModalFooter>
|
<StyledModalFooter>
|
||||||
<p>Copyright © {year} Toeverything</p>
|
<p>Copyright © {year} Toeverything</p>
|
||||||
<StyledPrivacyContainer>
|
<StyledPrivacyContainer>
|
||||||
<a href="https://affine.pro/terms" target="_blank">
|
<a href="https://affine.pro/terms" target="_blank" rel="noreferrer">
|
||||||
Terms
|
Terms
|
||||||
</a>
|
</a>
|
||||||
<a href="https://affine.pro/privacy" target="_blank">
|
<a
|
||||||
|
href="https://affine.pro/privacy"
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
>
|
||||||
Privacy
|
Privacy
|
||||||
</a>
|
</a>
|
||||||
</StyledPrivacyContainer>
|
</StyledPrivacyContainer>
|
||||||
@@ -136,5 +141,3 @@ export const ContactModal = ({
|
|||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ContactModal;
|
|
||||||
36
packages/component/src/stories/ContactModal.stories.tsx
Normal file
36
packages/component/src/stories/ContactModal.stories.tsx
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { Button } from '@affine/component';
|
||||||
|
import type { StoryFn } from '@storybook/react';
|
||||||
|
import { useState } from 'react';
|
||||||
|
|
||||||
|
import type { ContactModalProps } from '../components/contact-modal';
|
||||||
|
import { ContactModal } from '../components/contact-modal';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
title: 'AFFiNE/ContactModal',
|
||||||
|
component: ContactModal,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Basic: StoryFn<ContactModalProps> = args => {
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setOpen(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Open
|
||||||
|
</Button>
|
||||||
|
<ContactModal
|
||||||
|
{...args}
|
||||||
|
open={open}
|
||||||
|
onClose={() => {
|
||||||
|
setOpen(false);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
Basic.args = {
|
||||||
|
logoSrc: '/imgs/affine-text-logo.png',
|
||||||
|
};
|
||||||
@@ -1,4 +1,9 @@
|
|||||||
{
|
{
|
||||||
"extends": "../../tsconfig.json",
|
"extends": "../../tsconfig.json",
|
||||||
"include": ["./src", "./.storybook/*.ts"]
|
"include": ["./src", "./.storybook/*.ts"],
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.node.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
11
packages/component/tsconfig.node.json
Normal file
11
packages/component/tsconfig.node.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"composite": true,
|
||||||
|
"module": "ESNext",
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"moduleResolution": "Node",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"allowSyntheticDefaultImports": true
|
||||||
|
},
|
||||||
|
"include": [".storybook/**/*"]
|
||||||
|
}
|
||||||
@@ -18,9 +18,7 @@
|
|||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@affine/component": ["./packages/component/src/index"],
|
"@affine/component": ["./packages/component/src/index"],
|
||||||
"@affine/component/block-suite-editor": [
|
"@affine/component/*": ["./packages/component/src/components/*/index"],
|
||||||
"./packages/component/src/components/block-suite-editor/index"
|
|
||||||
],
|
|
||||||
"@affine/templates/*": ["./packages/templates/src/*"],
|
"@affine/templates/*": ["./packages/templates/src/*"],
|
||||||
"@affine/i18n": ["./packages/i18n/src"],
|
"@affine/i18n": ["./packages/i18n/src"],
|
||||||
"@affine/debug": ["./packages/debug"],
|
"@affine/debug": ["./packages/debug"],
|
||||||
|
|||||||
Reference in New Issue
Block a user