From b09cef19ac4ecdfe085bddf3b9551f994b9ff116 Mon Sep 17 00:00:00 2001 From: dragosiorgulescu Date: Wed, 27 Mar 2024 09:14:53 +0200 Subject: [PATCH] feat: add dropdown selector for history feeds - update layout margins to take into account the new sidebar for bookmarks and history --- .../src/components/BookmarkEmptyScreen.tsx | 11 ++- .../src/components/BookmarkFeedLayout.tsx | 5 +- .../shared/src/components/FeedSelector.tsx | 7 +- .../history/ReadingHistoryEmptyScreen.tsx | 11 ++- .../webapp/components/history/reading.tsx | 2 + packages/webapp/pages/history.tsx | 99 +++++++++++++++---- 6 files changed, 114 insertions(+), 21 deletions(-) diff --git a/packages/shared/src/components/BookmarkEmptyScreen.tsx b/packages/shared/src/components/BookmarkEmptyScreen.tsx index dcd73f0c9c..f6c01bed71 100644 --- a/packages/shared/src/components/BookmarkEmptyScreen.tsx +++ b/packages/shared/src/components/BookmarkEmptyScreen.tsx @@ -1,12 +1,21 @@ import React, { ReactElement } from 'react'; import Link from 'next/link'; +import classNames from 'classnames'; import { BookmarkIcon } from './icons'; import { Button, ButtonSize, ButtonVariant } from './buttons/Button'; import { EmptyScreenIcon } from './EmptyScreen'; +import { useMobileUxExperiment } from '../hooks/useMobileUxExperiment'; export default function BookmarkEmptyScreen(): ReactElement { + const { isNewMobileLayout } = useMobileUxExperiment(); + return ( -
+
>(() => { if (searchQuery) { return { @@ -86,7 +89,7 @@ export default function BookmarkFeedLayout({ ); return ( - + {children}

Bookmarks

diff --git a/packages/shared/src/components/FeedSelector.tsx b/packages/shared/src/components/FeedSelector.tsx index a1ed8fb59d..79e705be0d 100644 --- a/packages/shared/src/components/FeedSelector.tsx +++ b/packages/shared/src/components/FeedSelector.tsx @@ -58,7 +58,12 @@ export default function FeedSelector({ dynamicMenuWidth shouldIndicateSelected buttonSize={ButtonSize.Medium} - className={{ button: 'px-1', label: 'mr-5', container: className }} + className={{ + button: 'px-1', + label: 'mr-5', + container: className, + indicator: '!ml-2', + }} iconOnly={false} key="feed" icon={feedOptions[selectedFeedIdx].icon(true)} diff --git a/packages/shared/src/components/history/ReadingHistoryEmptyScreen.tsx b/packages/shared/src/components/history/ReadingHistoryEmptyScreen.tsx index 2249846a59..0651077bf4 100644 --- a/packages/shared/src/components/history/ReadingHistoryEmptyScreen.tsx +++ b/packages/shared/src/components/history/ReadingHistoryEmptyScreen.tsx @@ -1,5 +1,6 @@ import Link from 'next/link'; import React, { ReactElement } from 'react'; +import classNames from 'classnames'; import { EmptyScreenButton, EmptyScreenDescription, @@ -8,10 +9,18 @@ import { } from '../EmptyScreen'; import { EyeIcon } from '../icons'; import { ButtonSize } from '../buttons/common'; +import { useMobileUxExperiment } from '../../hooks/useMobileUxExperiment'; function ReadingHistoryEmptyScreen(): ReactElement { + const { isNewMobileLayout } = useMobileUxExperiment(); + return ( -
+
diff --git a/packages/webapp/pages/history.tsx b/packages/webapp/pages/history.tsx index 4a158667a0..4c2c760e35 100644 --- a/packages/webapp/pages/history.tsx +++ b/packages/webapp/pages/history.tsx @@ -6,7 +6,10 @@ import React, { useState, } from 'react'; import { NextSeo } from 'next-seo'; -import { ResponsivePageContainer } from '@dailydotdev/shared/src/components/utilities'; +import { + ResponsivePageContainer, + SharedFeedPage, +} from '@dailydotdev/shared/src/components/utilities'; import { useRouter } from 'next/router'; import { Tab, @@ -16,9 +19,28 @@ import { SearchHistory } from '@dailydotdev/shared/src/components'; import { useViewSize, ViewSize } from '@dailydotdev/shared/src/hooks'; import { AnalyticsEvent, Origin } from '@dailydotdev/shared/src/lib/analytics'; import AnalyticsContext from '@dailydotdev/shared/src/contexts/AnalyticsContext'; -import { getLayout } from '../components/layouts/MainLayout'; -import ProtectedPage from '../components/ProtectedPage'; +import classNames from 'classnames'; +import { useMobileUxExperiment } from '@dailydotdev/shared/src/hooks/useMobileUxExperiment'; +import { ButtonSize } from '@dailydotdev/shared/src/components/buttons/common'; +import { Dropdown } from '@dailydotdev/shared/src/components/fields/Dropdown'; +import { + DiscussIcon, + HotIcon, + UpvoteIcon, +} from '@dailydotdev/shared/src/components/icons'; +import { IconSize } from '@dailydotdev/shared/src/components/Icon'; import { HistoryType, ReadingHistory } from '../components/history'; +import ProtectedPage from '../components/ProtectedPage'; +import { getLayout } from '../components/layouts/MainLayout'; + +const feedOptions = [ + { + value: HistoryType.Reading, + }, + { + value: HistoryType.Search, + }, +]; const History = (): ReactElement => { const { trackEvent } = useContext(AnalyticsContext); @@ -27,6 +49,8 @@ const History = (): ReactElement => { const router = useRouter(); const tabQuery = router.query?.t?.toString() as HistoryType; const [page, setPage] = useState(HistoryType.Reading); + const { isNewMobileLayout } = useMobileUxExperiment(); + const selectedFeedIdx = feedOptions.findIndex((f) => f.value === page); const handleSetPage = useCallback( (active: HistoryType) => { @@ -54,20 +78,61 @@ const History = (): ReactElement => { return ( -
- - - controlledActive={page} - onActiveChange={handleSetPage} - showBorder={isLaptop} - > - - - - - - - + {!isNewMobileLayout && ( +
+ )} + + + {isNewMobileLayout && ( + <> + ( + {feedOptions[index].value} + )} + options={feedOptions.map((f) => f.value)} + onChange={(feed: HistoryType) => handleSetPage(feed)} + /> + + {page === HistoryType.Reading && } + + {page === HistoryType.Search && ( + + )} + + )} + + {!isNewMobileLayout && ( + + controlledActive={page} + onActiveChange={handleSetPage} + showBorder={isLaptop} + > + + + + + + + + )} );