From cdaa0c28764739496eb822768ea3c1bfcfd9bbcc Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Fri, 23 Jun 2023 20:37:31 +0800 Subject: [PATCH] Put the highlight menu in a container --- .../web/components/patterns/ArticleNotes.tsx | 1 - .../web/components/patterns/HighlightView.tsx | 41 ++++++++++++++++--- .../LibraryCards/LibraryHighlightGridCard.tsx | 2 + .../templates/article/HighlightViewItem.tsx | 17 ++++---- .../components/templates/article/Notebook.tsx | 5 ++- .../templates/homeFeed/HighlightItem.tsx | 1 + 6 files changed, 51 insertions(+), 16 deletions(-) diff --git a/packages/web/components/patterns/ArticleNotes.tsx b/packages/web/components/patterns/ArticleNotes.tsx index 81da54d14..8ed2a25bc 100644 --- a/packages/web/components/patterns/ArticleNotes.tsx +++ b/packages/web/components/patterns/ArticleNotes.tsx @@ -182,7 +182,6 @@ export function MarkdownNote(props: MarkdownNote): JSX.Element { css={{ width: '100%', ...RcEditorStyles(isDark, true), - pr: '25px', }} onKeyDown={(event: React.KeyboardEvent) => { if (event.code.toLowerCase() === 'escape') { diff --git a/packages/web/components/patterns/HighlightView.tsx b/packages/web/components/patterns/HighlightView.tsx index 3a581f978..cca4aec7b 100644 --- a/packages/web/components/patterns/HighlightView.tsx +++ b/packages/web/components/patterns/HighlightView.tsx @@ -15,12 +15,22 @@ 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' 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, { @@ -38,13 +48,14 @@ export function HighlightView(props: HighlightViewProps): JSX.Element { const [noteMode, setNoteMode] = useState<'preview' | 'edit'>('preview') return ( - + + + {/* - {/* */} - + */} - + ) } diff --git a/packages/web/components/patterns/LibraryCards/LibraryHighlightGridCard.tsx b/packages/web/components/patterns/LibraryCards/LibraryHighlightGridCard.tsx index 0d2de7109..63ab46060 100644 --- a/packages/web/components/patterns/LibraryCards/LibraryHighlightGridCard.tsx +++ b/packages/web/components/patterns/LibraryCards/LibraryHighlightGridCard.tsx @@ -130,6 +130,8 @@ export function LibraryHighlightGridCard( { console.log('updated highlight: ', highlight) diff --git a/packages/web/components/templates/article/HighlightViewItem.tsx b/packages/web/components/templates/article/HighlightViewItem.tsx index f94b45194..ac3cfab5c 100644 --- a/packages/web/components/templates/article/HighlightViewItem.tsx +++ b/packages/web/components/templates/article/HighlightViewItem.tsx @@ -2,7 +2,7 @@ import { useState } from 'react' import { Highlight } from '../../../lib/networking/fragments/highlightFragment' import { ReadableItem } from '../../../lib/networking/queries/useGetLibraryItemsQuery' import { UserBasicData } from '../../../lib/networking/queries/useGetViewerQuery' -import { HStack, SpanBox, VStack } from '../../elements/LayoutPrimitives' +import { Box, HStack, SpanBox, VStack } from '../../elements/LayoutPrimitives' import { HighlightView } from '../../patterns/HighlightView' import { HighlightsMenu } from '../homeFeed/HighlightItem' @@ -35,19 +35,18 @@ export function HighlightViewItem(props: HighlightViewItemProps): JSX.Element { > - ) } diff --git a/packages/web/components/templates/article/Notebook.tsx b/packages/web/components/templates/article/Notebook.tsx index 42b00e668..75f703d82 100644 --- a/packages/web/components/templates/article/Notebook.tsx +++ b/packages/web/components/templates/article/Notebook.tsx @@ -367,7 +367,10 @@ export function NotebookContent(props: NotebookContentProps): JSX.Element { setLabelsTarget(undefined)} + onOpenChange={() => { + mutate() + setLabelsTarget(undefined) + }} /> )} {props.showConfirmDeleteNote && ( diff --git a/packages/web/components/templates/homeFeed/HighlightItem.tsx b/packages/web/components/templates/homeFeed/HighlightItem.tsx index 2588de8b6..69af42634 100644 --- a/packages/web/components/templates/homeFeed/HighlightItem.tsx +++ b/packages/web/components/templates/homeFeed/HighlightItem.tsx @@ -66,6 +66,7 @@ export function HighlightsMenu(props: HighlightsMenuProps): JSX.Element { triggerElement={