From feb803ebefa9cabc7b6da768961860ef41979bc0 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Mon, 25 Jan 2021 10:03:20 +1100 Subject: [PATCH] Added note text only mode --- src/components/map/MapNotes.js | 1 + src/components/note/Note.js | 28 ++++++++++++++++------------ src/components/note/NoteMenu.js | 13 +++++++++++++ src/database.js | 14 ++++++++++++++ src/icons/NoteTextIcon.js | 19 +++++++++++++++++++ 5 files changed, 63 insertions(+), 12 deletions(-) create mode 100644 src/icons/NoteTextIcon.js diff --git a/src/components/map/MapNotes.js b/src/components/map/MapNotes.js index a95713c..3c527b4 100644 --- a/src/components/map/MapNotes.js +++ b/src/components/map/MapNotes.js @@ -57,6 +57,7 @@ function MapNotes({ visible: true, locked: false, color: "yellow", + textOnly: false, }); setIsBrushDown(true); } diff --git a/src/components/note/Note.js b/src/components/note/Note.js index c52e202..e3b84fa 100644 --- a/src/components/note/Note.js +++ b/src/components/note/Note.js @@ -149,7 +149,7 @@ function Note({ onClick={handleClick} onTap={handleClick} width={noteWidth} - height={noteHeight} + height={note.textOnly ? undefined : noteHeight} offsetX={noteWidth / 2} offsetY={noteHeight / 2} draggable={draggable} @@ -162,19 +162,23 @@ function Note({ onTouchEnd={handlePointerUp} opacity={note.visible ? 1.0 : 0.5} > - + {!note.textOnly && ( + + )} {/* Use an invisible text block to work out text sizing */} diff --git a/src/components/note/NoteMenu.js b/src/components/note/NoteMenu.js index 476616a..07a3b4c 100644 --- a/src/components/note/NoteMenu.js +++ b/src/components/note/NoteMenu.js @@ -13,6 +13,8 @@ import LockIcon from "../../icons/TokenLockIcon"; import UnlockIcon from "../../icons/TokenUnlockIcon"; import ShowIcon from "../../icons/TokenShowIcon"; import HideIcon from "../../icons/TokenHideIcon"; +import NoteIcon from "../../icons/NoteToolIcon"; +import TextIcon from "../../icons/NoteTextIcon"; import AuthContext from "../../contexts/AuthContext"; @@ -75,6 +77,10 @@ function NoteMenu({ note && onNoteChange({ ...note, locked: !note.locked }); } + function handleModeChange() { + note && onNoteChange({ ...note, textOnly: !note.textOnly }); + } + function handleModalContent(node) { if (node) { // Focus input @@ -209,6 +215,13 @@ function NoteMenu({ > {note && note.locked ? : } + + {note && note.textOnly ? : } + )} diff --git a/src/database.js b/src/database.js index 53e92b3..1c38512 100644 --- a/src/database.js +++ b/src/database.js @@ -304,6 +304,20 @@ function loadVersions(db) { } }); }); + + // 1.7.1 - Added note text only mode + db.version(18) + .stores({}) + .upgrade((tx) => { + return tx + .table("states") + .toCollection() + .modify((state) => { + for (let id in state.notes) { + state.notes[id].textOnly = false; + } + }); + }); } // Get the dexie database used in DatabaseContext diff --git a/src/icons/NoteTextIcon.js b/src/icons/NoteTextIcon.js new file mode 100644 index 0000000..0b3404f --- /dev/null +++ b/src/icons/NoteTextIcon.js @@ -0,0 +1,19 @@ +import React from "react"; + +function NoteTextIcon() { + return ( + + + + + + ); +} + +export default NoteTextIcon;