mirror of
https://github.com/remvze/moodist.git
synced 2025-09-29 15:30:49 -04:00
feat: add notepad tool page
This commit is contained in:
parent
d56f8be448
commit
1fd02f927c
@ -1,10 +1,8 @@
|
|||||||
import { useRef, useEffect } from 'react';
|
|
||||||
import { BiTrash } from 'react-icons/bi/index';
|
import { BiTrash } from 'react-icons/bi/index';
|
||||||
import { LuCopy, LuDownload } from 'react-icons/lu/index';
|
import { LuCopy, LuDownload } from 'react-icons/lu/index';
|
||||||
import { FaCheck } from 'react-icons/fa6/index';
|
import { FaCheck } from 'react-icons/fa6/index';
|
||||||
import { FaUndo } from 'react-icons/fa/index';
|
import { FaUndo } from 'react-icons/fa/index';
|
||||||
|
|
||||||
import { Modal } from '@/components/modal';
|
|
||||||
import { Button } from './button';
|
import { Button } from './button';
|
||||||
|
|
||||||
import { useNoteStore } from '@/stores/note';
|
import { useNoteStore } from '@/stores/note';
|
||||||
@ -12,15 +10,9 @@ import { useCopy } from '@/hooks/use-copy';
|
|||||||
import { download } from '@/helpers/download';
|
import { download } from '@/helpers/download';
|
||||||
|
|
||||||
import styles from './notepad.module.css';
|
import styles from './notepad.module.css';
|
||||||
|
import { Container } from '@/components/container';
|
||||||
|
|
||||||
interface NotepadProps {
|
export function Notepad() {
|
||||||
onClose: () => void;
|
|
||||||
show: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function Notepad({ onClose, show }: NotepadProps) {
|
|
||||||
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
|
||||||
|
|
||||||
const note = useNoteStore(state => state.note);
|
const note = useNoteStore(state => state.note);
|
||||||
const history = useNoteStore(state => state.history);
|
const history = useNoteStore(state => state.history);
|
||||||
const write = useNoteStore(state => state.write);
|
const write = useNoteStore(state => state.write);
|
||||||
@ -31,22 +23,8 @@ export function Notepad({ onClose, show }: NotepadProps) {
|
|||||||
|
|
||||||
const { copy, copying } = useCopy();
|
const { copy, copying } = useCopy();
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (show && textareaRef.current) {
|
|
||||||
setTimeout(() => {
|
|
||||||
textareaRef.current?.focus();
|
|
||||||
}, 10);
|
|
||||||
}
|
|
||||||
}, [show]);
|
|
||||||
|
|
||||||
const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
|
|
||||||
if (e.key === 'Escape') onClose();
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal show={show} wide onClose={onClose}>
|
<Container>
|
||||||
<header className={styles.header}>
|
<header className={styles.header}>
|
||||||
<h2 className={styles.label}>Your Note</h2>
|
<h2 className={styles.label}>Your Note</h2>
|
||||||
<div className={styles.buttons}>
|
<div className={styles.buttons}>
|
||||||
@ -74,17 +52,15 @@ export function Notepad({ onClose, show }: NotepadProps) {
|
|||||||
className={styles.textarea}
|
className={styles.textarea}
|
||||||
dir="auto"
|
dir="auto"
|
||||||
placeholder="What is on your mind?"
|
placeholder="What is on your mind?"
|
||||||
ref={textareaRef}
|
|
||||||
spellCheck={false}
|
spellCheck={false}
|
||||||
value={note}
|
value={note}
|
||||||
onChange={e => write(e.target.value)}
|
onChange={e => write(e.target.value)}
|
||||||
onKeyDown={handleKeyDown}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<p className={styles.counter}>
|
<p className={styles.counter}>
|
||||||
{characters} character{characters !== 1 && 's'} • {words} word
|
{characters} character{characters !== 1 && 's'} • {words} word
|
||||||
{words !== 1 && 's'}
|
{words !== 1 && 's'}
|
||||||
</p>
|
</p>
|
||||||
</Modal>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
21
src/pages/tools/notepad.astro
Normal file
21
src/pages/tools/notepad.astro
Normal file
@ -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';
|
||||||
|
---
|
||||||
|
|
||||||
|
<Layout title="Online Notepad — Moodist">
|
||||||
|
<Donate />
|
||||||
|
<Hero desc="Distraction-free online notepad." title="Online Notepad" />
|
||||||
|
<NotepadComponent client:load />
|
||||||
|
<About
|
||||||
|
text="Capture your thoughts instantly with our simple online notepad. Lightweight and easy to use, it lets you jot down notes, ideas, and to-do lists anytime, anywhere, without distractions."
|
||||||
|
/>
|
||||||
|
<Source />
|
||||||
|
<Footer />
|
||||||
|
</Layout>
|
Loading…
x
Reference in New Issue
Block a user