import { Box, VStack, HStack } from '../../elements/LayoutPrimitives' import { useState } from 'react' import { CaretDown, CaretUp } from 'phosphor-react' import { MetaStyle, timeAgo, TitleStyle } from './LibraryCardStyles' import { styled } from '@stitches/react' import { UserBasicData } from '../../../lib/networking/queries/useGetViewerQuery' import { LibraryItemNode } from '../../../lib/networking/queries/useGetLibraryItemsQuery' import { Button } from '../../elements/Button' import { theme } from '../../tokens/stitches.config' import { HighlightItem } from '../../templates/homeFeed/HighlightItem' export const GridSeparator = styled(Box, { height: '1px', marginTop: '15px', backgroundColor: '$thBorderColor', }) type LibraryHighlightGridCardProps = { viewer: UserBasicData item: LibraryItemNode } export function LibraryHighlightGridCard( props: LibraryHighlightGridCardProps ): JSX.Element { const [isHovered, setIsHovered] = useState(false) const [expanded, setExpanded] = useState(false) const higlightCount = props.item.highlights?.length ?? 0 return ( { setIsHovered(true) }} onMouseLeave={() => { setIsHovered(false) }} > {!expanded && ( {timeAgo(props.item.savedAt)} {` `} {props.item.wordsCount ?? 0 > 0 ? ` • ${Math.max( 1, Math.round((props.item.wordsCount ?? 0) / 235) )} min read` : null} {props.item.highlights?.length ?? 0 > 0 ? ` • ${props.item.highlights?.length} highlights` : null} )} {props.item.title} {expanded && ( <> {(props.item.highlights ?? []).map((highlight) => ( ))} )} {!expanded ? ( ) : ( )} ) }