From 0fa44f82dd7671c26e67ffca5aebdfea6aaf2c9b Mon Sep 17 00:00:00 2001 From: DiamondThree <857159145@qq.com> Date: Mon, 23 Jan 2023 11:23:41 +0800 Subject: [PATCH] feat: rewrite publish style --- .../workspace-setting/PublishPage.tsx | 66 ++++++++++--------- .../src/components/workspace-setting/style.ts | 38 +++++------ 2 files changed, 50 insertions(+), 54 deletions(-) diff --git a/packages/app/src/components/workspace-setting/PublishPage.tsx b/packages/app/src/components/workspace-setting/PublishPage.tsx index 3d65ac8676..a30b72bdf7 100644 --- a/packages/app/src/components/workspace-setting/PublishPage.tsx +++ b/packages/app/src/components/workspace-setting/PublishPage.tsx @@ -14,16 +14,18 @@ import { toast } from '@/ui/toast'; import { WorkspaceUnit } from '@affine/datacenter'; import { useWorkspaceHelper } from '@/hooks/use-workspace-helper'; import { useTranslation } from '@affine/i18n'; -import Loading from '@/components/loading'; -import { Wrapper } from '@/ui/layout'; import { EnableWorkspaceButton } from '../enable-workspace'; export const PublishPage = ({ workspace }: { workspace: WorkspaceUnit }) => { const shareUrl = window.location.host + '/public-workspace/' + workspace.id; const { publishWorkspace } = useWorkspaceHelper(); const { t } = useTranslation(); - const [loaded, setLoaded] = useState(true); + const [loaded, setLoaded] = useState(false); const togglePublic = async (flag: boolean) => { - await publishWorkspace(workspace.id.toString(), flag); + try { + await publishWorkspace(workspace.id.toString(), flag); + } catch (e) { + toast('Failed to publish workspace'); + } }; const copyUrl = () => { @@ -34,17 +36,21 @@ export const PublishPage = ({ workspace }: { workspace: WorkspaceUnit }) => { return ( <> {workspace.provider === 'affine' ? ( -
+
{workspace.published ? ( <> - {t('Publishing')} + The current workspace has been published to the web, everyone + can view the contents of this workspace through the link. - - {t('Share with link')} - + + + {t('Share with link')} + +
)} @@ -64,10 +84,11 @@ export const PublishPage = ({ workspace }: { workspace: WorkspaceUnit }) => { ) : ( - - - + <> )}
) : ( <> - {t('Publishing')} + Publishing to web requires AFFiNE Cloud service. - +
- +
)} - {!loaded && ( - - - - )} ); }; diff --git a/packages/app/src/components/workspace-setting/style.ts b/packages/app/src/components/workspace-setting/style.ts index c855b767d9..2f95a29b89 100644 --- a/packages/app/src/components/workspace-setting/style.ts +++ b/packages/app/src/components/workspace-setting/style.ts @@ -1,4 +1,4 @@ -import { displayFlex, styled } from '@/styles'; +import { styled } from '@/styles'; export const StyledSettingContainer = styled('div')(() => { return { @@ -85,26 +85,25 @@ export const StyledSettingTagIconContainer = styled('div')(() => { }; }); -export const StyledSettingH2 = styled('h2')<{ marginTop?: number }>( - ({ marginTop, theme }) => { - return { - fontWeight: '500', - fontSize: theme.font.base, - lineHeight: theme.font.lineHeightBase, - marginTop: marginTop ? `${marginTop}px` : '0px', - }; - } -); +export const StyledSettingH2 = styled('h2')<{ + marginTop?: number; + marginBottom?: number; +}>(({ marginTop, marginBottom, theme }) => { + return { + fontWeight: '500', + fontSize: theme.font.base, + lineHeight: theme.font.lineHeightBase, + marginTop: marginTop ? `${marginTop}px` : '0px', + marginBottom: marginBottom ? `${marginBottom}px` : '0px', + }; +}); export const StyledPublishExplanation = styled('div')(() => { return { - ...displayFlex('row', 'center', 'center'), paddingRight: '48px', fontWeight: '500', fontSize: '18px', lineHeight: '26px', - flex: 1, - marginBottom: '22px', }; }); @@ -126,21 +125,14 @@ export const StyledWorkspaceType = styled('div')(() => { export const StyledPublishCopyContainer = styled('div')(() => { return { marginTop: '12px', - display: 'flex', - flexDirection: 'column', - alignItems: 'start', - justifyContent: 'center', marginBottom: '20px', paddingTop: '20px', + flex: 1, }; }); export const StyledStopPublishContainer = styled('div')(() => { return { - position: 'absolute', - bottom: '0', - left: '50%', - transform: 'translateX(-50%)', - marginBottom: '20px', + textAlign: 'center', }; });