diff --git a/packages/web/components/elements/Button.tsx b/packages/web/components/elements/Button.tsx index 7ad86281c..48f11221a 100644 --- a/packages/web/components/elements/Button.tsx +++ b/packages/web/components/elements/Button.tsx @@ -191,6 +191,7 @@ export const Button = styled('button', { color: 'transparent', border: 'none', bg: 'transparent', + cursor: 'pointer', '&:hover': { opacity: 0.8, }, diff --git a/packages/web/components/templates/Menu.tsx b/packages/web/components/templates/Menu.tsx index 1575a883c..7ac25a9f8 100644 --- a/packages/web/components/templates/Menu.tsx +++ b/packages/web/components/templates/Menu.tsx @@ -73,6 +73,7 @@ export const Menubar = () => { const [menuList, setMenuList] = useState>([]) const [dynamicMenuItems, setDynamicMenuItems] = useState({}) + const [activeItem, setActiveItem] = useState('Home') useEffect(() => { if (labels || subscriptions) { @@ -84,7 +85,6 @@ export const Menubar = () => { query: 'in:inbox', icon: null, href: '/home', - active: true, }, { label: 'Today', @@ -111,7 +111,7 @@ export const Menubar = () => { href: `?q=in:inbox+label:Newsletter`, }, ]) - },[labels, subscriptions]) + }, [labels, subscriptions]) return ( @@ -122,7 +122,10 @@ export const Menubar = () => { { + setActiveItem(item.label) + }} > {item.label} @@ -130,44 +133,46 @@ export const Menubar = () => { ) })} - {dynamicMenuItems.labels && - - {dynamicMenuItems.labels.map((item: MenuItems) => { - return ( + {dynamicMenuItems.labels.map((item: MenuItems) => { + return ( + { + setActiveItem(item.label) + }} > {item.label} - ) - })} - - } - {dynamicMenuItems.subscriptions && - - {dynamicMenuItems.subscriptions.map((item: MenuItems) => { - return ( - - - {item.label} - - - ) - })} - - } + + ) + })} + + )} + {dynamicMenuItems.subscriptions && ( + + {dynamicMenuItems.subscriptions.map((item: MenuItems) => { + return ( + { + setActiveItem(item.label) + }} + > + + {item.label} + + + ) + })} + + )} ) diff --git a/packages/web/components/templates/library/LibraryContainer.tsx b/packages/web/components/templates/library/LibraryContainer.tsx index e57a64428..6a9f1825e 100644 --- a/packages/web/components/templates/library/LibraryContainer.tsx +++ b/packages/web/components/templates/library/LibraryContainer.tsx @@ -1,4 +1,4 @@ -import { Box, HStack, SpanBox, VStack } from './../../elements/LayoutPrimitives' +import { HStack, SpanBox, VStack } from './../../elements/LayoutPrimitives' import { useGetViewerQuery } from '../../../lib/networking/queries/useGetViewerQuery' import { useGetUserPreferences } from '../../../lib/networking/queries/useGetUserPreferences' import { LibraryMenu } from './LibraryMenu' @@ -6,19 +6,58 @@ import { LibraryAvatar } from './LibraryAvatar' import { LibrarySearchBar } from './LibrarySearchBar' import { LibraryList } from './LibraryList' import { LibraryHeadline } from './LibraryHeadline' +import { useCallback, useState } from 'react' +import { LibraryItemsQueryInput } from '../../../lib/networking/queries/useGetLibraryItemsQuery' +import { usePersistedState } from '../../../lib/hooks/usePersistedState' + +export type SearchCoordinator = { + applySearch: (searchTerm: string) => void +} + +const useSearchCoordinator = () => { + const applySearch = useCallback((searchTerm: string) => { + console.log('applying search') + }, []) + + return { + applySearch + } +} + +export type LibraryLayoutType = 'LIST_LAYOUT' | 'GRID_LAYOUT' + +export type LayoutCoordinator = { + layout: LibraryLayoutType + setLayout: (type: LibraryLayoutType) => void +} + +const useLibraryLayoutCoordinator = () => { + const [layout, setLayout] = usePersistedState({ + key: 'libraryLayout', + initialValue: 'GRID_LAYOUT', + }) + + return { + layout, + setLayout + } +} + export function LibraryContainer(): JSX.Element { useGetUserPreferences() const { viewerData } = useGetViewerQuery() + const searchCoordinator = useSearchCoordinator() + const layoutCoordinator = useLibraryLayoutCoordinator() return ( <> - + @@ -27,8 +66,8 @@ export function LibraryContainer(): JSX.Element { - - + + diff --git a/packages/web/components/templates/library/LibraryHeadline.tsx b/packages/web/components/templates/library/LibraryHeadline.tsx index 28c2e22c9..608abb7e8 100644 --- a/packages/web/components/templates/library/LibraryHeadline.tsx +++ b/packages/web/components/templates/library/LibraryHeadline.tsx @@ -5,18 +5,34 @@ import { theme } from '../../tokens/stitches.config' import { LibraryListLayoutIcon } from '../../elements/images/LibraryListLayoutIcon' import { LibraryGridLayoutIcon } from '../../elements/images/LibraryGridLayoutIcon' import { Button } from '../../elements/Button' +import { LayoutCoordinator, LibraryLayoutType } from './LibraryContainer' +import { useCallback } from 'react' +export type LibraryHeadlineProps = { + layoutCoordinator: LayoutCoordinator +} -export function LibraryHeadline(): JSX.Element { - useGetUserPreferences() +export function LibraryHeadline(props: LibraryHeadlineProps): JSX.Element { + + const typeColor = useCallback((type: LibraryLayoutType) => { + return ( + props.layoutCoordinator.layout === type + ? theme.colors.omnivoreCtaYellow.toString() + : "#D6D6D6" + ) + }, [props.layoutCoordinator.layout]) return ( Home - - + + ) diff --git a/packages/web/components/templates/library/LibraryList.tsx b/packages/web/components/templates/library/LibraryList.tsx index d104bf572..c65ad80d6 100644 --- a/packages/web/components/templates/library/LibraryList.tsx +++ b/packages/web/components/templates/library/LibraryList.tsx @@ -1,21 +1,22 @@ import { Box } from '../../elements/LayoutPrimitives' import { useGetViewerQuery } from '../../../lib/networking/queries/useGetViewerQuery' import { useGetUserPreferences } from '../../../lib/networking/queries/useGetUserPreferences' -import { useMemo, useState } from 'react' +import { useMemo } from 'react' import { useGetLibraryItemsQuery } from '../../../lib/networking/queries/useGetLibraryItemsQuery' import { LinkedItemCardAction } from '../../patterns/LibraryCards/CardTypes' import { LibraryGridCard } from '../../patterns/LibraryCards/LibraryGridCard' +import { LayoutCoordinator } from './LibraryContainer' +import { EmptyLibrary } from '../homeFeed/EmptyLibrary' -export type LayoutType = 'LIST_LAYOUT' | 'GRID_LAYOUT' +export type LibraryListProps = { + layoutCoordinator: LayoutCoordinator +} - -export function LibraryList(): JSX.Element { +export function LibraryList(props: LibraryListProps): JSX.Element { useGetUserPreferences() - const [layout, setLayout] = useState('GRID_LAYOUT') const { viewerData } = useGetViewerQuery() - const defaultQuery = { limit: 50, sortDescending: true, @@ -33,40 +34,42 @@ export function LibraryList(): JSX.Element { return items }, [itemsPages, performActionOnItem]) + if (!isValidating && libraryItems.length == 0) { + return ( + { + console.log('onAddLinkClicked') + }} + /> + ) + } + return ( - {/* // {!isValidating && items.length == 0 ? ( - // { - - // }} - // /> - // ) : ( */} @@ -96,7 +99,7 @@ export function LibraryList(): JSX.Element { > {viewerData?.me && ( { diff --git a/packages/web/components/templates/library/LibrarySearchBar.tsx b/packages/web/components/templates/library/LibrarySearchBar.tsx index dbbc9d5d0..feaa2dde6 100644 --- a/packages/web/components/templates/library/LibrarySearchBar.tsx +++ b/packages/web/components/templates/library/LibrarySearchBar.tsx @@ -1,26 +1,22 @@ -import { Box, HStack, SpanBox, VStack } from './../../elements/LayoutPrimitives' -import { useGetViewerQuery } from '../../../lib/networking/queries/useGetViewerQuery' -import { useRouter } from 'next/router' -import { useGetUserPreferences } from '../../../lib/networking/queries/useGetUserPreferences' +import { HStack, SpanBox, VStack } from './../../elements/LayoutPrimitives' import { useState } from 'react' import { FormInput } from '../../elements/FormElements' import { Button } from '../../elements/Button' -import { X } from 'phosphor-react' +import { Sliders, SlidersHorizontal, X } from 'phosphor-react' import { theme } from '../../tokens/stitches.config' +import { SearchCoordinator } from './LibraryContainer' +export type LibrarySearchBarProps = { + coordinator: SearchCoordinator +} -export function LibrarySearchBar(): JSX.Element { - useGetUserPreferences() - - - const router = useRouter() - const [searchTerm, setSearchTerm] = useState('') - const { viewerData } = useGetViewerQuery() +export function LibrarySearchBar(props: LibrarySearchBarProps): JSX.Element { + const [searchTerm, setSearchTerm] = useState('') return ( <> - +
{ @@ -33,24 +29,34 @@ export function LibrarySearchBar(): JSX.Element { css={{ width: '100%', height: '80px', - fontFamily: 'Inter', fontSize: '24px', + fontFamily: 'Inter', }} type="text" + tabIndex={0} value={searchTerm} placeholder="Search" - // onFocus={(event) => { - // event.target.select() - // setFocused(true) - // }} - // onBlur={() => { - // setFocused(false) - // }} - // onChange={(event) => { - // setSearchTerm(event.target.value) - // }} + onChange={(event) => { + setSearchTerm(event.target.value) + }} />
+ {!searchTerm && ( + + )} {searchTerm && (