diff --git a/src/App.tsx b/src/App.tsx index 80022d4..48f4f8d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -18,7 +18,7 @@ function App() { focusThought, clearThought, rememberThought, - countThoughts + countThoughts, } = useThoughts() const [activeTab, setActiveTab] = useState('write') @@ -28,16 +28,15 @@ function App() { } const hasMultipleNotes = () => { - if (!sortedThoughts || !activeThought) - return false + if (!sortedThoughts || !activeThought) return false return sortedThoughts.length > 1 || activeThought.text.length > 0 } - const emptyActiveThought = () => !activeThought || activeThought.text.length > 0 + const emptyActiveThought = () => + !activeThought || activeThought.text.length > 0 const plusPressed = async () => { - if (emptyActiveThought()) - await createThought() + if (emptyActiveThought()) await createThought() setActiveTab('write') } @@ -49,8 +48,7 @@ function App() { const deletePressed = async (t: Thought) => { await clearThought(t) const numThoughts = await countThoughts() - if (numThoughts < 1) - setActiveTab('write') + if (numThoughts < 1) setActiveTab('write') } const rememberPressed = async (thoughtId: number, when: RememberWhen) => { @@ -68,37 +66,45 @@ function App() { onDeleteClicked={deletePressed} /> ), - write: ( - activeThought ? 6 && activeThought.text.length > 0} + showRememberButtons={ + sortedThoughts.length > 6 && activeThought.text.length > 0 + } onUpdate={updateThought} onRemember={rememberPressed} - /> : + /> + ) : ( + ), settings: , } return ( -
-
+
+
{tabs[activeTab]}
- {hasMultipleNotes() && tabPressed('list')} - />} + {hasMultipleNotes() && ( + tabPressed('list')} + /> + )} - {hasMultipleNotes() && tabPressed('settings')} - />} + {hasMultipleNotes() && ( + tabPressed('settings')} + /> + )}
) diff --git a/src/components/ThoughtList.tsx b/src/components/ThoughtList.tsx index 922e7d7..42abf8b 100644 --- a/src/components/ThoughtList.tsx +++ b/src/components/ThoughtList.tsx @@ -16,7 +16,6 @@ const ThoughtList = ({ onDeleteClicked, ...rest }: ThoughtListProps) => { - return (
Meditations
diff --git a/src/components/ThoughtPad.tsx b/src/components/ThoughtPad.tsx index bb4998a..cf46a7d 100644 --- a/src/components/ThoughtPad.tsx +++ b/src/components/ThoughtPad.tsx @@ -12,45 +12,57 @@ type ThoughtPadProps = { onRemember: RememberHandler } & React.HTMLAttributes -const ThoughtPad = ({ thought, showRememberButtons, onUpdate, onRemember, ...rest }: ThoughtPadProps) => { - - const textareaRef = useRef(null); +const ThoughtPad = ({ + thought, + showRememberButtons, + onUpdate, + onRemember, + ...rest +}: ThoughtPadProps) => { + const textareaRef = useRef(null) useEffect(() => { focusTextArea() }, []) useEffect(() => { - if (thought.text == '') - focusTextArea() + if (thought.text == '') focusTextArea() }, [thought]) const focusTextArea = () => { if (!textareaRef.current || window.isMobileDevice()) return textareaRef.current.focus() - textareaRef.current.selectionStart = textareaRef.current.selectionEnd = thought.text.length; + textareaRef.current.selectionStart = textareaRef.current.selectionEnd = + thought.text.length } return ( -
+