From 1fd02f927c55155ecd8d1af6325995c4635e0a29 Mon Sep 17 00:00:00 2001 From: MAZE Date: Fri, 30 Aug 2024 22:14:15 +0330 Subject: [PATCH] feat: add notepad tool page --- src/components/tools/notepad/notepad.tsx | 32 +++--------------------- src/pages/tools/notepad.astro | 21 ++++++++++++++++ 2 files changed, 25 insertions(+), 28 deletions(-) create mode 100644 src/pages/tools/notepad.astro diff --git a/src/components/tools/notepad/notepad.tsx b/src/components/tools/notepad/notepad.tsx index 921556f..9ca334e 100644 --- a/src/components/tools/notepad/notepad.tsx +++ b/src/components/tools/notepad/notepad.tsx @@ -1,10 +1,8 @@ -import { useRef, useEffect } from 'react'; import { BiTrash } from 'react-icons/bi/index'; import { LuCopy, LuDownload } from 'react-icons/lu/index'; import { FaCheck } from 'react-icons/fa6/index'; import { FaUndo } from 'react-icons/fa/index'; -import { Modal } from '@/components/modal'; import { Button } from './button'; import { useNoteStore } from '@/stores/note'; @@ -12,15 +10,9 @@ import { useCopy } from '@/hooks/use-copy'; import { download } from '@/helpers/download'; import styles from './notepad.module.css'; +import { Container } from '@/components/container'; -interface NotepadProps { - onClose: () => void; - show: boolean; -} - -export function Notepad({ onClose, show }: NotepadProps) { - const textareaRef = useRef(null); - +export function Notepad() { const note = useNoteStore(state => state.note); const history = useNoteStore(state => state.history); const write = useNoteStore(state => state.write); @@ -31,22 +23,8 @@ export function Notepad({ onClose, show }: NotepadProps) { const { copy, copying } = useCopy(); - useEffect(() => { - if (show && textareaRef.current) { - setTimeout(() => { - textareaRef.current?.focus(); - }, 10); - } - }, [show]); - - const handleKeyDown = (e: React.KeyboardEvent) => { - e.stopPropagation(); - - if (e.key === 'Escape') onClose(); - }; - return ( - +

Your Note

@@ -74,17 +52,15 @@ export function Notepad({ onClose, show }: NotepadProps) { className={styles.textarea} dir="auto" placeholder="What is on your mind?" - ref={textareaRef} spellCheck={false} value={note} onChange={e => write(e.target.value)} - onKeyDown={handleKeyDown} />

{characters} character{characters !== 1 && 's'} • {words} word {words !== 1 && 's'}

- + ); } diff --git a/src/pages/tools/notepad.astro b/src/pages/tools/notepad.astro new file mode 100644 index 0000000..ccabc43 --- /dev/null +++ b/src/pages/tools/notepad.astro @@ -0,0 +1,21 @@ +--- +import Layout from '@/layouts/layout.astro'; + +import Donate from '@/components/donate.astro'; +import Hero from '@/components/tools/hero.astro'; +import { Notepad as NotepadComponent } from '@/components/tools/notepad'; +import Footer from '@/components/footer.astro'; +import About from '@/components/tools/about.astro'; +import Source from '@/components/source.astro'; +--- + + + + + + + +