From 766e32d872861bedeabae7edd2386579be96148f Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Mon, 28 Aug 2023 18:24:48 +0800 Subject: [PATCH] Improve empty state next action suggestions --- .../web/components/templates/ErrorLayout.tsx | 27 +-- .../templates/homeFeed/EmptyLibrary.tsx | 167 +++++++++++++++--- .../templates/homeFeed/HomeFeedContainer.tsx | 1 + 3 files changed, 156 insertions(+), 39 deletions(-) diff --git a/packages/web/components/templates/ErrorLayout.tsx b/packages/web/components/templates/ErrorLayout.tsx index 4c8881d5c..b0837c883 100644 --- a/packages/web/components/templates/ErrorLayout.tsx +++ b/packages/web/components/templates/ErrorLayout.tsx @@ -1,8 +1,4 @@ -import { - VStack, - HStack, - SpanBox, -} from '../elements/LayoutPrimitives' +import { VStack, HStack, SpanBox } from '../elements/LayoutPrimitives' import { StyledText } from '../elements/StyledText' import Link from 'next/link' import { Button } from '../elements/Button' @@ -22,11 +18,14 @@ export function ErrorLayout(props: ErrorLayoutProps): JSX.Element { return ( - + {props.statusCode} @@ -34,9 +33,11 @@ export function ErrorLayout(props: ErrorLayoutProps): JSX.Element { - - + + ) -} \ No newline at end of file +} diff --git a/packages/web/components/templates/homeFeed/EmptyLibrary.tsx b/packages/web/components/templates/homeFeed/EmptyLibrary.tsx index afe7b7b1e..92e04e1da 100644 --- a/packages/web/components/templates/homeFeed/EmptyLibrary.tsx +++ b/packages/web/components/templates/homeFeed/EmptyLibrary.tsx @@ -1,15 +1,20 @@ import Link from 'next/link' import { Book } from 'phosphor-react' import { Button } from '../../elements/Button' -import { VStack } from '../../elements/LayoutPrimitives' +import { Box, HStack, SpanBox, VStack } from '../../elements/LayoutPrimitives' import { StyledText } from '../../elements/StyledText' import { theme } from '../../tokens/stitches.config' import { useMemo } from 'react' import { searchQuery } from '../../../lib/networking/queries/search' +import { LIBRARY_LEFT_MENU_WIDTH } from './LibraryFilterMenu' +import { LayoutType } from './HomeFeedContainer' +import { ArrowRightIcon } from '../../elements/icons/ArrowRightIcon' type EmptyLibraryProps = { searchTerm: string | undefined onAddLinkClicked: () => void + + layoutType: LayoutType } type MessageType = 'feed' | 'newsletter' | 'library' @@ -75,6 +80,108 @@ const HelpMessage = (props: HelpMessageProps) => { return <> } +export const ErrorBox = (props: HelpMessageProps) => { + const errorTitle = useMemo(() => { + switch (props.type) { + case 'feed': + return 'You do not have any feed items matching this query.' + case 'newsletter': + return 'You do not have any newsletter item matching this query.' + } + return 'No results found for this query.' + }, [props.type]) + + return ( + + {errorTitle} + + ) +} + +export const SuggestionBox = (props: HelpMessageProps) => { + const helpMessage = useMemo(() => { + switch (props.type) { + case 'feed': + return 'Want to add an RSS or Atom Subscription?' + case 'newsletter': + return 'Create an Omnivore email address and subscribe to newsletters.' + } + return "Add a link or read more about Omnivore's Advanced Search." + }, [props.type]) + + const helpTarget = useMemo(() => { + switch (props.type) { + case 'feed': + return '/settings/feeds' + case 'newsletter': + return '/settings/emails' + } + return 'https://docs.omnivore.app/' + }, [props.type]) + + return ( + + {helpMessage} + + + + <>Click Here + + + + + + ) +} + export const EmptyLibrary = (props: EmptyLibraryProps) => { const type = useMemo(() => { if (props.searchTerm) { @@ -88,35 +195,43 @@ export const EmptyLibrary = (props: EmptyLibraryProps) => { return 'library' }, [props]) - const helpTitle = useMemo(() => { - switch (type) { - case 'feed': - return 'You do not have any feed items matching this query.' - case 'newsletter': - return 'You do not have any newsletter items.' - } - return 'No results found.' - }, [type]) - return ( - - - - {helpTitle} - - - - - - + + + ) } diff --git a/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx b/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx index dbfb16b20..338e3e833 100644 --- a/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx +++ b/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx @@ -1066,6 +1066,7 @@ function LibraryItemsLayout(props: LibraryItemsLayoutProps): JSX.Element { > {!props.isValidating && props.items.length == 0 ? ( { props.setShowAddLinkModal(true)