/* eslint-disable react/no-children-prop */ import { useMemo, useState } from 'react' import type { Highlight } from '../../lib/networking/fragments/highlightFragment' import { LabelChip } from '../elements/LabelChip' import { Box, VStack, Blockquote, SpanBox, HStack, } from '../elements/LayoutPrimitives' import { styled, theme } from '../tokens/stitches.config' import { HighlightViewNote } from './HighlightNotes' import ReactMarkdown from 'react-markdown' import remarkGfm from 'remark-gfm' import { isDarkTheme } from '../../lib/themeUpdater' import { HighlightsMenu } from '../templates/homeFeed/HighlightItem' import { ReadableItem } from '../../lib/networking/queries/useGetLibraryItemsQuery' import { UserBasicData } from '../../lib/networking/queries/useGetViewerQuery' import { autoUpdate, offset, size, useFloating, useHover, useInteractions, } from '@floating-ui/react' import { LibraryHoverActions } from './LibraryCards/LibraryHoverActions' import { HighlightHoverActions } from './HighlightHoverActions' type HighlightViewProps = { item: ReadableItem viewer: UserBasicData highlight: Highlight author?: string title?: string updateHighlight: (highlight: Highlight) => void viewInReader: (highlightId: string) => void setLabelsTarget: (target: Highlight) => void setShowConfirmDeleteHighlightId: (set: string) => void } const StyledQuote = styled(Blockquote, { p: '0px', margin: '0px 0px 0px 0px', fontSize: '18px', lineHeight: '27px', borderRadius: '4px', width: '100%', }) export function HighlightView(props: HighlightViewProps): JSX.Element { const isDark = isDarkTheme() const [noteMode, setNoteMode] = useState<'preview' | 'edit'>('preview') const [isHovered, setIsHovered] = useState(false) const [isOpen, setIsOpen] = useState(false) const { refs, floatingStyles, context } = useFloating({ open: isOpen, onOpenChange: setIsOpen, middleware: [ offset({ mainAxis: -25, }), size(), ], placement: 'top-end', whileElementsMounted: autoUpdate, }) const hover = useHover(context) const { getReferenceProps, getFloatingProps } = useInteractions([hover]) const highlightAlpha = isDark ? 1.0 : 0.35 return ( {props.highlight.labels?.map(({ name, color }, index) => ( ))} ) }