From 70d8f9a0a7b590366531d4a2743b66cbcea5dd9a Mon Sep 17 00:00:00 2001 From: Chi Zhang Date: Sun, 23 Apr 2023 06:24:18 +0800 Subject: [PATCH] feat: add shared page empty tip (#2077) Co-authored-by: himself65 --- .../components/affine/sidebar-switch/index.tsx | 16 ++++++++++++++-- .../block-suite-page-list/page-list/Empty.tsx | 3 +++ .../pure/workspace-slider-bar/index.tsx | 1 + packages/i18n/src/resources/en.json | 1 + 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/affine/sidebar-switch/index.tsx b/apps/web/src/components/affine/sidebar-switch/index.tsx index 6782acacf7..d9af30cac3 100644 --- a/apps/web/src/components/affine/sidebar-switch/index.tsx +++ b/apps/web/src/components/affine/sidebar-switch/index.tsx @@ -1,6 +1,7 @@ import { Tooltip } from '@affine/component'; +import { getEnvironment } from '@affine/env'; import { useTranslation } from '@affine/i18n'; -import { useCallback, useState } from 'react'; +import { useCallback, useEffect, useState } from 'react'; import { useGuideHidden, @@ -29,12 +30,23 @@ export const SidebarSwitch = ({ const [guideHiddenUntilNextUpdate, setGuideHiddenUntilNextUpdate] = useGuideHiddenUntilNextUpdate(); const { t } = useTranslation(); + const checkIsMac = () => { + const env = getEnvironment(); + return env.isBrowser && env.isMacOs; + }; + const [isMac, setIsMac] = useState(false); + const collapseKeyboardShortcuts = isMac ? ' ⌘+/' : ' Ctrl+/'; + + useEffect(() => { + setIsMac(checkIsMac()); + }, []); + tooltipContent = tooltipContent || (open ? t('Collapse sidebar') : t('Expand sidebar')); return ( { if (listType === 'trash') { return t('emptyTrash'); } + if (listType === 'shared') { + return t('emptySharedPages'); + } }; return ( diff --git a/apps/web/src/components/pure/workspace-slider-bar/index.tsx b/apps/web/src/components/pure/workspace-slider-bar/index.tsx index 0fd81ca42b..dc5f18e37d 100644 --- a/apps/web/src/components/pure/workspace-slider-bar/index.tsx +++ b/apps/web/src/components/pure/workspace-slider-bar/index.tsx @@ -94,6 +94,7 @@ export const WorkSpaceSliderBar: React.FC = ({ const [isScrollAtTop, setIsScrollAtTop] = useState(true); const show = isPublicWorkspace ? false : sidebarOpen; const actualWidth = floatingSlider ? 'calc(10vw + 400px)' : sliderWidth; + useEffect(() => { if (environment.isDesktop) { window.apis?.onSidebarVisibilityChange(sidebarOpen); diff --git a/packages/i18n/src/resources/en.json b/packages/i18n/src/resources/en.json index 209aa4b203..33d67f1a66 100644 --- a/packages/i18n/src/resources/en.json +++ b/packages/i18n/src/resources/en.json @@ -114,6 +114,7 @@ "Got it": "Got it", "emptyAllPages": "This workspace is empty. Create a new page to begin editing.", "emptyTrash": "Deleted pages will appear here.", + "emptySharedPages": "Shared pages will appear here.", "still designed": "(This page is still being designed.)", "My Workspaces": "My Workspaces", "Tips": "Tips: ",