From 0f4043f4455083c8e00454203018b1d1dc72414c Mon Sep 17 00:00:00 2001 From: Christopher Loverich <1010084+cloverich@users.noreply.github.com> Date: Tue, 6 Aug 2024 07:35:19 -0700 Subject: [PATCH] wip: more incremental titlebar refactoring working in 30-60 minute increments in the early AM / late PM. Nearly done, then a bunch of clean-up --- src/components/Sidesheet.tsx | 4 +- src/electron/index.js | 2 +- src/index.css | 1 + src/layout.tsx | 2 - src/titlebar/macos.tsx | 28 +++---- src/titlebar/styles.css | 37 -------- src/views/documents/Layout.tsx | 6 +- src/views/documents/search/index.tsx | 2 +- src/views/edit/FrontMatter.tsx | 29 ------- src/views/edit/PlateContainer.tsx | 1 - src/views/edit/SaveActions.tsx | 40 --------- src/views/edit/editor/components/Toolbar.tsx | 43 ++++------ .../read-only-editor/ReadonlyToolbar.tsx | 7 +- .../edit/editor/toolbar/EditorToolbar.tsx | 73 +++++++++------- .../components/ChangeBlockDropdown.tsx | 44 ++++++---- .../toolbar/components/DebugDropdown.tsx | 66 ++++++++++----- .../toolbar/components/DropdownMenu.tsx | 10 +-- .../toolbar/components/LinkToolbarButton.tsx | 4 +- src/views/edit/index.tsx | 48 ++++++++--- src/views/edit/loading.tsx | 84 +++++-------------- tailwind.config.js | 20 ++++- 21 files changed, 241 insertions(+), 310 deletions(-) delete mode 100644 src/titlebar/styles.css delete mode 100644 src/views/edit/SaveActions.tsx diff --git a/src/components/Sidesheet.tsx b/src/components/Sidesheet.tsx index 3b0945e..02ed872 100644 --- a/src/components/Sidesheet.tsx +++ b/src/components/Sidesheet.tsx @@ -21,7 +21,7 @@ const SheetOverlay = React.forwardRef< // Initial use case is for side bar (journal selection) -- imo looks better when backgroud is not faded / covered w/ animation; may want to re-enable // for other use cases // "fixed inset-0 z-50 bg-slate-400 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", - "no-drag", + "drag-none", className, )} {...props} @@ -31,7 +31,7 @@ const SheetOverlay = React.forwardRef< SheetOverlay.displayName = SheetPrimitive.Overlay.displayName; const sheetVariants = cva( - "no-drag fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-300", + "drag-none fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-300", { variants: { side: { diff --git a/src/electron/index.js b/src/electron/index.js index fcde979..93a3f4c 100644 --- a/src/electron/index.js +++ b/src/electron/index.js @@ -198,7 +198,7 @@ function createWindow() { // titleBarStyle: "hidden", - trafficLightPosition: { x: 10, y: 18 }, + trafficLightPosition: { x: 10, y: 16 }, webPreferences: { nodeIntegration: false, sandbox: false, diff --git a/src/index.css b/src/index.css index 3a3024e..3a2397a 100644 --- a/src/index.css +++ b/src/index.css @@ -26,6 +26,7 @@ --secondary: 210 40% 96.1%; --secondary-foreground: 222.2 47.4% 11.2%; + /* --accent: 255, 89%, 62%; */ --accent: 210 40% 96.1%; --accent-foreground: 222.2 47.4% 11.2%; diff --git a/src/layout.tsx b/src/layout.tsx index ce8fa5d..5f4269e 100644 --- a/src/layout.tsx +++ b/src/layout.tsx @@ -1,8 +1,6 @@ import React, { PropsWithChildren } from "react"; import { Pane, Tablist, Tab } from "evergreen-ui"; import ErrorBoundary from "./error"; -import { NavLink, useLocation } from "react-router-dom"; -import Titlebar from "./titlebar/macos"; interface Props2 { children: any; diff --git a/src/titlebar/macos.tsx b/src/titlebar/macos.tsx index 9d871c6..6ed5b0f 100644 --- a/src/titlebar/macos.tsx +++ b/src/titlebar/macos.tsx @@ -1,24 +1,20 @@ import React, { PropsWithChildren } from "react"; -import { Pane } from "evergreen-ui"; -import { NavLink, useLocation } from "react-router-dom"; -import "./styles.css"; +import { cn } from "@udecode/cn"; -interface Props2 extends PropsWithChildren {} - -export default function Titlebar({ children }: Props2) { - const location = useLocation(); +interface Props extends PropsWithChildren { + className?: string; +} +export default function Titlebar({ children, className }: Props) { return ( -
+
{children} - {/* - - chronicles - - - - - */}
); } diff --git a/src/titlebar/styles.css b/src/titlebar/styles.css deleted file mode 100644 index 4ceabcc..0000000 --- a/src/titlebar/styles.css +++ /dev/null @@ -1,37 +0,0 @@ -/* - no-drag: titlebar otherwise overrides click and everything drags the app around - - After making the title bar draggable, buttons inside of it, and the sidesheet that - overlays it, lose their clickability and result in app dragging. This undoes that. -*/ -.no-drag { - -webkit-app-region: no-drag; -} - -.TitleBar-macos { - background-color: #f8f8f8; - border-bottom: 1px solid #6c6a8a; - color: #333; - /* height: 22px; */ - padding: 0 10px; - -webkit-app-region: drag; - - display: flex; - justify-content: space-between; - align-items: center; - padding: 12px 10px 12px 10px; - /* elevation: 1; */ - - /* account for traffic lights */ - padding-left: 80px; - padding-right: 70px; - - /* Fix top and be full width */ - position: fixed; - width: 100%; - - /* Stay above editor and dropdown; not much thought put into number */ - z-index: 1; - - height: 55px; -} diff --git a/src/views/documents/Layout.tsx b/src/views/documents/Layout.tsx index a4ae834..9d687c6 100644 --- a/src/views/documents/Layout.tsx +++ b/src/views/documents/Layout.tsx @@ -25,7 +25,7 @@ export function Layout(props: Props) { return ( <> - + Select Journals @@ -48,7 +48,7 @@ export function Layout(props: Props) { backgroundColor="transparent" border="none" icon={EditIcon} - className="no-drag" + className="drag-none" onClick={() => navigate("/documents/edit/new")} marginRight={8} > diff --git a/src/views/documents/search/index.tsx b/src/views/documents/search/index.tsx index c720129..a13be62 100644 --- a/src/views/documents/search/index.tsx +++ b/src/views/documents/search/index.tsx @@ -35,7 +35,7 @@ const SearchDocuments = (props: Props) => { return ( { - const navigate = useNavigate(); - const searchStore = useSearchStore()!; - function onAddTag(tokens: string[]) { if (tokens.length > 1) { // https://evergreen.segment.com/components/tag-input @@ -152,34 +149,8 @@ const FrontMatter = observer( ); } - function goBack() { - if ( - !document.dirty || - confirm( - "Document is unsaved, exiting will discard document. Stop editing anyways?", - ) - ) { - // This handles the edit case but hmm... if its new... it should be added to the search... - // but in what order? Well... if we aren't paginated... it should be at the top. - searchStore.updateSearch(document); - navigate(-1); - } - } - return ( <> - {/* back button */} - - {/* Document title */}
- - - - ); -} diff --git a/src/views/edit/editor/components/Toolbar.tsx b/src/views/edit/editor/components/Toolbar.tsx index 5830ead..d481771 100644 --- a/src/views/edit/editor/components/Toolbar.tsx +++ b/src/views/edit/editor/components/Toolbar.tsx @@ -10,7 +10,7 @@ import { withTooltip } from "./Tooltip"; export const Toolbar = withCn( ToolbarPrimitive.Root, - "relative flex select-none items-center gap-1 bg-background", + "relative flex select-none items-center gap-1", ); export const ToolbarToggleGroup = withCn( @@ -30,21 +30,24 @@ export const ToolbarSeparator = withCn( const toolbarButtonVariants = cva( cn( - "inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", + "inline-flex items-center justify-center text-xs ring-offset-background transition-colors disabled:pointer-events-none disabled:opacity-50", + "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", "[&_svg:not([data-icon])]:h-5 [&_svg:not([data-icon])]:w-5", + "rounded-sm border border-transparent", ), { variants: { variant: { default: - "bg-transparent hover:bg-muted hover:text-muted-foreground aria-checked:bg-accent aria-checked:text-accent-foreground", + "hover:bg-slate-50 hover:border-slate-400 hover:border hover:text-accent-foreground aria-checked:text-accent-foreground ", //border-1 border-transparent bg-transparent outline: "border border-input bg-transparent hover:bg-accent hover:text-accent-foreground", }, size: { - default: "h-10 px-3", - sm: "h-9 px-2", - lg: "h-11 px-5", + default: "h-7 p-1.5", + xs: "h-5 p-1.5", + sm: "h-7 p-1.5", + lg: "h-9 p-1.5", }, }, defaultVariants: { @@ -54,8 +57,10 @@ const toolbarButtonVariants = cva( }, ); -// todo: fix any -const ToolbarButton: any = withTooltip( +/** + * A styled button for the toolbar. + */ +const ToolbarButton = withTooltip( // eslint-disable-next-line react/display-name React.forwardRef< React.ElementRef, @@ -85,22 +90,12 @@ const ToolbarButton: any = withTooltip( variant, size, }), - isDropdown && "my-1 justify-between pr-1", className, )} value={pressed ? "single" : ""} {...props} > - {isDropdown ? ( - <> -
{children}
-
- -
- - ) : ( - children - )} + {children} ) : ( @@ -122,7 +117,9 @@ const ToolbarButton: any = withTooltip( }, ), ); + ToolbarButton.displayName = "ToolbarButton"; + export { ToolbarButton }; export const ToolbarToggleItem = withVariants( @@ -148,13 +145,7 @@ export const ToolbarGroup = withRef<
)} -
{children}
+
{children}
); }); - -// Also https://platejs.org/docs/components/toolbar -export const FixedToolbar = withCn( - Toolbar, - "supports-backdrop-blur:bg-background/60 sticky left-0 top-[57px] z-50 w-full overflow-x-auto rounded-t-lg border-b border-b-border bg-background/95 backdrop-blur", -); diff --git a/src/views/edit/editor/read-only-editor/ReadonlyToolbar.tsx b/src/views/edit/editor/read-only-editor/ReadonlyToolbar.tsx index e2ce371..ed7120b 100644 --- a/src/views/edit/editor/read-only-editor/ReadonlyToolbar.tsx +++ b/src/views/edit/editor/read-only-editor/ReadonlyToolbar.tsx @@ -1,5 +1,5 @@ import React from "react"; -import { ToolbarGroup, FixedToolbar } from "../components/Toolbar"; +import { ToolbarGroup, Toolbar } from "../components/Toolbar"; import { TooltipProvider } from "../components/Tooltip"; import DebugDropdown from "../toolbar/components/DebugDropdown"; import { EditorMode } from "../../EditorMode"; @@ -36,14 +36,15 @@ export function ReadonlyToolbar({ >
<> - + {}} /> - +
diff --git a/src/views/edit/editor/toolbar/EditorToolbar.tsx b/src/views/edit/editor/toolbar/EditorToolbar.tsx index d69027f..fa67ab0 100644 --- a/src/views/edit/editor/toolbar/EditorToolbar.tsx +++ b/src/views/edit/editor/toolbar/EditorToolbar.tsx @@ -13,17 +13,32 @@ import { Icons } from "../../../../components/icons"; import { LinkToolbarButton } from "./components/LinkToolbarButton"; import { MarkToolbarButton } from "./components/MarkToolbarButton"; -import { ToolbarGroup, FixedToolbar } from "../components/Toolbar"; +import { ToolbarGroup, Toolbar } from "../components/Toolbar"; // I think this needs to be on the root, wherever Theme would be added (if we had a theme) import { TooltipProvider } from "../components/Tooltip"; import ChangeBlockDropdown from "./components/ChangeBlockDropdown"; import DebugDropdown from "./components/DebugDropdown"; import { EditorMode } from "../../EditorMode"; +import { + BoldIcon, + ItalicIcon, + UnderlineIcon, + StrikethroughIcon, + CodeIcon, + LinkIcon, + MoreIcon, +} from "evergreen-ui"; +import { Underline } from "lucide-react"; +import { EditableDocument } from "../../EditableDocument"; +import { useIsMounted } from "../../../../hooks/useIsMounted"; +import { useNavigate } from "react-router-dom"; +import { useSearchStore } from "../../../documents/SearchStore"; interface Props { selectedEditorMode: EditorMode; setSelectedEditorMode: (s: EditorMode) => any; + document: EditableDocument; } /** @@ -34,40 +49,53 @@ interface Props { export function EditorToolbar({ selectedEditorMode, setSelectedEditorMode, + document, }: Props) { + const isMounted = useIsMounted(); + const navigate = useNavigate(); + const searchStore = useSearchStore()!; + + async function deleteDocument() { + if (confirm("Are you sure?")) { + await document.del(); + searchStore.updateSearch(document, "del"); + if (isMounted()) navigate(-1); + } + } + return ( - {/* NOTE: Unclear why I cant use Tailwind class mb-24 here */} -
+
+
<> - - + + - + - + - + <> @@ -75,41 +103,24 @@ export function EditorToolbar({ tooltip="Strikethrough (⌘+⇧+M)" nodeType={MARK_STRIKETHROUGH} > - + - + - - {/* NOTE: id prop was removed, probably was for Playground to support multiple editors */} - {/* */} - {/* {isEnabled("indentlist", id) && indentList && ( - <> - - - - )} */} - - {/* NOTE: id prop was removed, probably was for Playground to support multiple editors */} - {/* <> - - - */} - - + - + - -
diff --git a/src/views/edit/editor/toolbar/components/ChangeBlockDropdown.tsx b/src/views/edit/editor/toolbar/components/ChangeBlockDropdown.tsx index 8260cd2..da21c48 100644 --- a/src/views/edit/editor/toolbar/components/ChangeBlockDropdown.tsx +++ b/src/views/edit/editor/toolbar/components/ChangeBlockDropdown.tsx @@ -24,6 +24,21 @@ import { import { Icons } from "../../../../../components/icons"; +import { + MoreIcon, + HeaderOneIcon, + HeaderTwoIcon, + HeaderThreeIcon, + CodeBlockIcon, + CitationIcon, + NumberedListIcon, + PropertiesIcon, + FontIcon, + DeleteIcon, + TrashIcon, + ParagraphIcon, +} from "evergreen-ui"; + import { DropdownMenu, DropdownMenuContent, @@ -38,51 +53,51 @@ import { ToolbarButton } from "../../components/Toolbar"; const items = [ { description: "Paragraph", - icon: Icons.paragraph, + icon: ParagraphIcon, label: "Paragraph", value: ELEMENT_PARAGRAPH, }, { description: "Heading 1", - icon: Icons.h1, + icon: HeaderOneIcon, label: "Heading 1", value: ELEMENT_H1, }, { description: "Heading 2", - icon: Icons.h2, + icon: HeaderTwoIcon, label: "Heading 2", value: ELEMENT_H2, }, { description: "Heading 3", - icon: Icons.h3, + icon: HeaderThreeIcon, label: "Heading 3", value: ELEMENT_H3, }, { description: "Quote (⌘+⇧+.)", - icon: Icons.blockquote, + icon: CitationIcon, label: "Quote", value: ELEMENT_BLOCKQUOTE, }, { description: "Code (```)", - icon: Icons.codeblock, + icon: CodeBlockIcon, label: "Code", value: ELEMENT_CODE_BLOCK, }, { - value: "ul", - label: "Bulleted list", description: "Bulleted list", - icon: Icons.ul, + icon: PropertiesIcon, + label: "Bulleted list", + value: "ul", }, { - value: "ol", - label: "Numbered list", description: "Numbered list", - icon: Icons.ol, + icon: NumberedListIcon, + label: "Numbered list", + value: "ol", }, ]; @@ -91,9 +106,6 @@ const defaultItem = items.find((item) => item.value === ELEMENT_PARAGRAPH)!; /** * Toolbar dropdown for toggling block types, e.g. paragraph, heading, blockquote. * - * Unlike the InsertBlockDropdown, this dropdown is for toggling existing blocks, not - * creating new ones. - * * Referred to as "Turn into" dropdown in Plate UI docs. * https://platejs.org/docs/components/turn-into-dropdown-menu */ @@ -129,7 +141,7 @@ export default function ChangeBlockDropdown(props: DropdownMenuProps) { className="lg:min-w-[130px]" isDropdown pressed={openState.open} - tooltip="Turn into" + tooltip="Change type" > {selectedItemLabel} diff --git a/src/views/edit/editor/toolbar/components/DebugDropdown.tsx b/src/views/edit/editor/toolbar/components/DebugDropdown.tsx index 16164dc..c77adbb 100644 --- a/src/views/edit/editor/toolbar/components/DebugDropdown.tsx +++ b/src/views/edit/editor/toolbar/components/DebugDropdown.tsx @@ -4,12 +4,29 @@ import { ToolbarButton } from "../../components/Toolbar"; import { useOpenState, DropdownMenu, + DropdownMenuLabel, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, + DropdownMenuRadioGroup, + DropdownMenuRadioItem, } from "./DropdownMenu"; -import { Icons } from "../../../../../components/icons"; + +import { + MoreIcon, + HeaderOneIcon, + HeaderTwoIcon, + HeaderThreeIcon, + CodeBlockIcon, + CitationIcon, + NumberedListIcon, + PropertiesIcon, + FontIcon, + DeleteIcon, + TrashIcon, +} from "evergreen-ui"; + import { EditorMode } from "../../../EditorMode"; const options = Object.freeze([ @@ -22,6 +39,7 @@ const options = Object.freeze([ interface Props { selectedEditorMode: EditorMode; setSelectedEditorMode: (s: EditorMode) => any; + deleteDocument: () => void; } /** @@ -30,6 +48,7 @@ interface Props { export default function DebugDropdown({ selectedEditorMode, setSelectedEditorMode, + deleteDocument, }: Props) { const openState = useOpenState(); @@ -40,29 +59,38 @@ export default function DebugDropdown({ isDropdown pressed={openState.open} tooltip="Change editor debug mode" + size="xs" > - + - + + Toggle debug mode + + {options.map(({ key, label }) => ( + + { + setSelectedEditorMode(key); + }} + > + {label} + + + ))} + + - {options.map(({ key, label }) => ( - - { - setSelectedEditorMode(key); - }} - > - {label} - - - ))} + + + ); diff --git a/src/views/edit/editor/toolbar/components/DropdownMenu.tsx b/src/views/edit/editor/toolbar/components/DropdownMenu.tsx index 3e0a00f..59fa373 100644 --- a/src/views/edit/editor/toolbar/components/DropdownMenu.tsx +++ b/src/views/edit/editor/toolbar/components/DropdownMenu.tsx @@ -56,12 +56,12 @@ export const DropdownMenuSubTrigger = withRef< export const DropdownMenuSubContent = withCn( DropdownMenuPrimitive.SubContent, - "z-50 min-w-32 overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", + "z-50 min-w-32 overflow-hidden border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", ); const DropdownMenuContentVariants = withProps(DropdownMenuPrimitive.Content, { className: cn( - "z-50 min-w-32 overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", + "z-50 min-w-32 overflow-hidden border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", ), sideOffset: 4, }); @@ -76,7 +76,7 @@ export const DropdownMenuContent = withRef< const menuItemVariants = cva( cn( - "relative flex h-9 cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors", + "relative flex h-9 cursor-pointer select-none items-center px-2 py-1.5 text-sm outline-none transition-colors", "focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", ), { @@ -99,7 +99,7 @@ export const DropdownMenuCheckboxItem = withRef< >(({ children, className, ...props }, ref) => ( (({ children, className, hideIcon, ...props }, ref) => ( ((rest, ref) => { const state = useLinkToolbarButtonState(); @@ -14,7 +14,7 @@ export const LinkToolbarButton = withRef((rest, ref) => { return ( - + ); }); diff --git a/src/views/edit/index.tsx b/src/views/edit/index.tsx index 9db9f0d..d0d37cf 100644 --- a/src/views/edit/index.tsx +++ b/src/views/edit/index.tsx @@ -1,12 +1,11 @@ import React, { useContext, useState, useEffect } from "react"; import { observer } from "mobx-react-lite"; import Editor from "./editor"; -import { Pane } from "evergreen-ui"; +import { IconButton, Pane, ChevronLeftIcon } from "evergreen-ui"; import { useEditableDocument } from "./useEditableDocument"; import { EditableDocument } from "./EditableDocument"; import { JournalResponse } from "../../preload/client/journals"; import { EditLoadingComponent } from "./loading"; -import { useIsMounted } from "../../hooks/useIsMounted"; import { JournalsStoreContext } from "../../hooks/useJournalsLoader"; import { useParams, useNavigate } from "react-router-dom"; import { useSearchStore } from "../documents/SearchStore"; @@ -15,8 +14,8 @@ import { EditorMode } from "./EditorMode"; import Titlebar from "../../titlebar/macos"; import PlateContainer from "./PlateContainer"; import { EditorToolbar } from "./editor/toolbar/EditorToolbar"; -import { SaveActions } from "./SaveActions"; import FrontMatter from "./FrontMatter"; +import { Separator } from "./editor/components/Separator"; // Loads document, with loading and error placeholders function DocumentLoadingContainer() { @@ -70,6 +69,8 @@ const DocumentEditView = observer((props: DocumentEditProps) => { const [selectedViewMode, setSelectedViewMode] = React.useState( EditorMode.Editor, ); + const navigate = useNavigate(); + const searchStore = useSearchStore()!; function renderEditor(tab: string) { switch (tab) { @@ -102,6 +103,20 @@ const DocumentEditView = observer((props: DocumentEditProps) => { } } + function goBack() { + if ( + !document.dirty || + confirm( + "Document is unsaved, exiting will discard document. Stop editing anyways?", + ) + ) { + // This handles the edit case but hmm... if its new... it should be added to the search... + // but in what order? Well... if we aren't paginated... it should be at the top. + searchStore.updateSearch(document); + navigate(-1); + } + } + // flexGrows are needed so save / edit buttons are at bottom on both empty documents // and scrollable documents return ( @@ -115,25 +130,32 @@ const DocumentEditView = observer((props: DocumentEditProps) => { setSelectedEditorMode={setSelectedViewMode} > + + Back to documents + + + - + - {/* Saving / Delete, todo: move to toolbar*/} - + + {renderEditor(selectedViewMode)} + - - - - {renderEditor(selectedViewMode)} ); diff --git a/src/views/edit/loading.tsx b/src/views/edit/loading.tsx index a3dab21..3130ac4 100644 --- a/src/views/edit/loading.tsx +++ b/src/views/edit/loading.tsx @@ -1,8 +1,9 @@ import React from "react"; import { observer } from "mobx-react-lite"; -import { Pane, Button, Alert } from "evergreen-ui"; -import { css } from "emotion"; +import { Pane, IconButton, ChevronLeftIcon } from "evergreen-ui"; import { useNavigate } from "react-router-dom"; +import Titlebar from "../../titlebar/macos"; +import { Separator } from "./editor/components/Separator"; export interface LoadingComponentProps { error?: Error | null; @@ -15,68 +16,27 @@ export const EditLoadingComponent = observer((props: LoadingComponentProps) => { const navigate = useNavigate(); return ( - - navigate("/documents")}>Back - -
+ + {}} + marginRight={8} > -
- {placeholderDate}/ -
- - Loading... - -
-
- -
- - {/* note: its not actually clear to me whether toJS is necessary here. */} - - {props.error && ( - - {JSON.stringify(props.error)} - - )} - - - + Back to documents + + + + + + +

Coming soon...

+
-
+ ); }); diff --git a/tailwind.config.js b/tailwind.config.js index 11a57d0..b5605e1 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,6 +1,8 @@ import { fontFamily } from "tailwindcss/defaultTheme"; /** @type {import('tailwindcss').Config} */ +const plugin = require("tailwindcss/plugin"); + export const darkMode = ["class"]; export const content = ["src/**/*.{ts,tsx}"]; export const theme = { @@ -73,4 +75,20 @@ export const theme = { }, }, }; -export const plugins = [require("tailwindcss-animate")]; +export const plugins = [ + require("tailwindcss-animate"), + plugin(function ({ addUtilities }) { + addUtilities({ + // The titlebar which replaces the native (default) titlebar is draggable; set .drag-none on + // inner elements that need to be clickable / interactive, like buttons, inputs, etc. + ".drag-none": { + "-webkit-app-region": "no-drag", + // "-webkit-user-drag": "none", + // "-khtml-user-drag": "none", + // "-moz-user-drag": "none", + // "-o-user-drag": "none", + // "user-drag": "none", + }, + }); + }), +];