From e2aaaf5a08568004452a23ac439fa7754c685a92 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 23 Mar 2023 16:14:04 +0800 Subject: [PATCH] Sizing fixes on the note modal --- .../web/components/patterns/HighlightView.tsx | 43 +++----- .../components/templates/HighlightNoteBox.tsx | 22 +---- .../article/HighlightPostToFeedModal.tsx | 92 ----------------- .../templates/article/NotebookModal.tsx | 98 ++++++++++--------- 4 files changed, 71 insertions(+), 184 deletions(-) delete mode 100644 packages/web/components/templates/article/HighlightPostToFeedModal.tsx diff --git a/packages/web/components/patterns/HighlightView.tsx b/packages/web/components/patterns/HighlightView.tsx index 1f7c8555d..dcb8f1657 100644 --- a/packages/web/components/patterns/HighlightView.tsx +++ b/packages/web/components/patterns/HighlightView.tsx @@ -9,8 +9,8 @@ import { SpanBox, HStack, } from '../elements/LayoutPrimitives' -import { StyledText } from '../elements/StyledText' import { styled, theme } from '../tokens/stitches.config' +import { HighlightViewNote } from './HighlightViewNote' type HighlightViewProps = { highlight: Highlight @@ -27,6 +27,7 @@ const StyledQuote = styled(Blockquote, { }) export function HighlightView(props: HighlightViewProps): JSX.Element { + const [noteMode, setNoteMode] = useState<'preview' | 'edit'>('preview') const [isEditing, setIsEditing] = useState(false) const lines = useMemo( @@ -45,7 +46,7 @@ export function HighlightView(props: HighlightViewProps): JSX.Element { - + {lines.map((line: string, index: number) => ( {line} @@ -90,30 +96,13 @@ export function HighlightView(props: HighlightViewProps): JSX.Element { ))} - {!isEditing ? ( - setIsEditing(true)} - > - {props.highlight.annotation - ? props.highlight.annotation - : 'Add notes to this highlight...'} - - ) : null} - {isEditing && ( - {} /* props.updateHighlight */} - /> - )} + ) diff --git a/packages/web/components/templates/HighlightNoteBox.tsx b/packages/web/components/templates/HighlightNoteBox.tsx index ed1886895..7f61c84f4 100644 --- a/packages/web/components/templates/HighlightNoteBox.tsx +++ b/packages/web/components/templates/HighlightNoteBox.tsx @@ -9,7 +9,7 @@ import { import { formattedShortTime } from '../../lib/dateFormatting' import { createHighlightMutation } from '../../lib/networking/mutations/createHighlightMutation' import { updateHighlightMutation } from '../../lib/networking/mutations/updateHighlightMutation' -import { Box, HStack, SpanBox, VStack } from '../elements/LayoutPrimitives' +import { HStack, SpanBox, VStack } from '../elements/LayoutPrimitives' import MarkdownIt from 'markdown-it' import MdEditor from 'react-markdown-editor-lite' @@ -232,7 +232,6 @@ export function HighlightNoteBox(props: NoteSectionProps): JSX.Element { distribution="start" css={{ width: '100%', - // minHeight: '160px' }} > ) } - -// {!isEditing ? ( -// setIsEditing(true)} -// > -// {props.highlight.annotation -// ? props.highlight.annotation -// : 'Add notes to this highlight...'} -// -// ) : null} -// {isEditing && ( diff --git a/packages/web/components/templates/article/HighlightPostToFeedModal.tsx b/packages/web/components/templates/article/HighlightPostToFeedModal.tsx deleted file mode 100644 index 73812a544..000000000 --- a/packages/web/components/templates/article/HighlightPostToFeedModal.tsx +++ /dev/null @@ -1,92 +0,0 @@ -import { - ModalRoot, - ModalContent, - ModalOverlay, -} from './../../elements/ModalPrimitives' -import { Box, HStack } from '../../elements/LayoutPrimitives' -import { Button } from '../../elements/Button' -import { StyledText } from '../../elements/StyledText' -import { Highlight } from '../../../lib/networking/fragments/highlightFragment' -import { HighlightView } from '../../patterns/HighlightView' -import { useCallback, useState } from 'react' -import { StyledTextArea } from '../../elements/StyledTextArea' - -type HighlightPostToFeedModalProps = { - highlight: Highlight - author: string - title: string - onCommit: (highlight: Highlight, comment: string) => void - onOpenChange: (open: boolean) => void -} - -export function HighlightPostToFeedModal( - props: HighlightPostToFeedModalProps -): JSX.Element { - const [comment, setComment] = useState('') - - const handleCommentChange = useCallback( - (event: React.ChangeEvent): void => { - setComment(event.target.value) - }, - [setComment] - ) - - const postHighlight = useCallback(async () => { - props.onCommit(props.highlight, comment) - props.onOpenChange(false) - }, [comment, props]) - - return ( - - - { - event.preventDefault() - }} - css={{ overflow: 'auto' }} - > - - - - Post Highlight - - - - - - - - ) -} diff --git a/packages/web/components/templates/article/NotebookModal.tsx b/packages/web/components/templates/article/NotebookModal.tsx index 96d15f338..c07242a26 100644 --- a/packages/web/components/templates/article/NotebookModal.tsx +++ b/packages/web/components/templates/article/NotebookModal.tsx @@ -42,6 +42,7 @@ import { nanoid } from 'nanoid' import throttle from 'lodash/throttle' import { deleteHighlightMutation } from '../../../lib/networking/mutations/deleteHighlightMutation' import { LibraryItem } from '../../../lib/networking/queries/useGetLibraryItemsQuery' +import { HighlightNoteBox } from '../HighlightNoteBox' const mdParser = new MarkdownIt() @@ -77,7 +78,7 @@ export function NotebookModal(props: NotebookModalProps): JSX.Element { ) const [sizeMode, setSizeMode] = useState<'normal' | 'maximized'>('normal') const [showConfirmDeleteNote, setShowConfirmDeleteNote] = useState(false) - const [notesEditMode, setNotesEditMode] = useState(true) + const [notesEditMode, setNotesEditMode] = useState<'edit' | 'preview'>('edit') const [, updateState] = useState({}) const listReducer = ( @@ -190,63 +191,72 @@ export function NotebookModal(props: NotebookModalProps): JSX.Element { }} css={{ overflow: 'auto', - px: '20px', height: sizeMode === 'normal' ? 'unset' : '100%', maxWidth: sizeMode === 'normal' ? '640px' : '100%', + minHeight: '525px', }} > - + + + Notebook + - - Notebook - - - - }> - { - exportHighlights() - }} - title="Export Notebook" - /> - { - setShowConfirmDeleteNote(true) - }} - title="Delete Document Note" - /> - - props.onOpenChange(false)} /> - + + }> + { + exportHighlights() + }} + title="Export Notebook" + /> + { + setShowConfirmDeleteNote(true) + }} + title="Delete Document Note" + /> + + props.onOpenChange(false)} /> + + setNotesEditMode(edit ? 'edit' : 'preview')} /> - h.type == 'NOTE')} sizeMode={sizeMode} - mode={notesEditMode ? 'edit' : 'read'} + mode={notesEditMode} setEditMode={setNotesEditMode} - dispatchList={dispatchList} + // dispatchList={dispatchList} /> - {props.highlights.map((highlight) => ( + {/* {props.highlights.map((highlight) => ( {highlight.annotation}