diff --git a/packages/web/components/elements/Button.tsx b/packages/web/components/elements/Button.tsx index 350362947..3da631f6c 100644 --- a/packages/web/components/elements/Button.tsx +++ b/packages/web/components/elements/Button.tsx @@ -1,4 +1,4 @@ -import { styled } from '../tokens/stitches.config' +import { styled, theme } from '../tokens/stitches.config' export const Button = styled('button', { fontFamily: 'inter', @@ -436,7 +436,12 @@ export const Button = styled('button', { cursor: 'pointer', p: '5px', borderRadius: '5px', - '&:hover': { bg: '$homeActionHoverBg', opacity: '1' }, + '&:hover': { + opacity: '1', + bg: '$homeActionHoverBg', + '--stroke': theme.colors.homeTextTitle.toString(), + }, + '--stroke': theme.colors.homeActionIcons.toString(), }, menuAction: { display: 'flex', diff --git a/packages/web/components/elements/icons/home/AddToLibraryActionIcon.tsx b/packages/web/components/elements/icons/home/AddToLibraryActionIcon.tsx index ae852aac8..6c191389d 100644 --- a/packages/web/components/elements/icons/home/AddToLibraryActionIcon.tsx +++ b/packages/web/components/elements/icons/home/AddToLibraryActionIcon.tsx @@ -6,8 +6,6 @@ import React from 'react' export class AddToLibraryActionIcon extends React.Component { render() { - const strokeColor = (this.props.color || '#D9D9D9').toString() - return ( { { render() { - const strokeColor = (this.props.color || '#D9D9D9').toString() - return ( { { render() { - const strokeColor = (this.props.color || '#D9D9D9').toString() - return ( { { render() { - const strokeColor = (this.props.color || '#D9D9D9').toString() - return ( { ) case 'top_picks': + if (homeSection.items.length < 1) { + return + } return ( ) case 'quick_links': + if (homeSection.items.length < 1) { + return + } return ( { ) } +const FromYourLibraryHomeSection = (): JSX.Element => { + const { itemsPages } = useGetLibraryItemsQuery('all', { + limit: 10, + includeContent: false, + sortDescending: true, + }) + + const searchItems = useMemo(() => { + return ( + itemsPages?.flatMap((ad) => { + return ad.search.edges.map((it) => ({ + ...it, + isLoading: it.node.state === 'PROCESSING', + })) + }) || [] + ).map((item) => { + return { + id: item.node.id, + date: item.node.savedAt, + title: item.node.title, + url: item.node.url, + slug: item.node.slug, + score: 1.0, + thumbnail: item.node.image, + source: { + name: + item.node.folder == 'following' + ? item.node.subscription + : item.node.siteName, + icon: item.node.siteIcon, + type: 'LIBRARY', + }, + canArchive: true, + canDelete: true, + canShare: true, + canMove: item.node.folder == 'following', + } as HomeItem + }) + }, [itemsPages]) + + const listReducer = ( + state: HomeItem[], + action: { + type: string + itemId?: string + items?: HomeItem[] + } + ) => { + switch (action.type) { + case 'RESET': + return action.items ?? [] + case 'REMOVE_ITEM': + return state.filter((item) => item.id !== action.itemId) + default: + throw new Error() + } + } + + const [items, dispatchList] = useReducer(listReducer, []) + + useEffect(() => { + dispatchList({ + type: 'RESET', + items: searchItems, + }) + }, [searchItems]) + + console.log('items: ', items) + + return ( + + {items.length > 0 && ( + + From your library + + )} + + ( + + )} + /> + + ) +} + const QuickLinksHomeSection = (props: HomeSectionProps): JSX.Element => { return ( - + )} {props.homeItem.canArchive && ( @@ -726,9 +842,7 @@ const TopPicksItemView = ( } }} > - + )} {props.homeItem.canDelete && ( @@ -757,7 +871,7 @@ const TopPicksItemView = ( } }} > - + )} {props.homeItem.canShare && ( @@ -767,11 +881,10 @@ const TopPicksItemView = ( onClick={async (event) => { event.preventDefault() event.stopPropagation() - await shareItem(props.homeItem.title, props.homeItem.url) }} > - + )} @@ -847,47 +960,55 @@ type SourceInfoProps = { subtle?: boolean } -const SourceInfo = (props: HomeItemViewProps & SourceInfoProps) => ( - - - - {props.homeItem.source.icon && ( - - )} +const SourceInfo = (props: HomeItemViewProps & SourceInfoProps) => { + const hasHover = useMemo(() => { + const type = props.homeItem.source.type + return type == 'RSS' || type == 'NEWSLETTER' + }, [props]) + return ( + + - {props.homeItem.source.name} + {props.homeItem.source.icon && ( + + )} + + {props.homeItem.source.name} + - - - - - - - - - -) + + {hasHover && ( + + + + + + + )} + + ) +} type SourceHoverContentProps = { source: HomeItemSource