mirror of
https://github.com/remvze/moodist.git
synced 2025-09-29 15:30:49 -04:00
feat: add notepad tool
This commit is contained in:
parent
9208663050
commit
a80289db57
45
src/components/tools/notepad/button/button.module.css
Normal file
45
src/components/tools/notepad/button/button.module.css
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
.button {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 30px;
|
||||||
|
height: 30px;
|
||||||
|
font-size: var(--font-sm);
|
||||||
|
color: var(--color-foreground);
|
||||||
|
cursor: pointer;
|
||||||
|
background-color: var(--color-neutral-100);
|
||||||
|
border: 1px solid var(--color-neutral-200);
|
||||||
|
border-radius: 4px;
|
||||||
|
outline: none;
|
||||||
|
transition: 0.2s;
|
||||||
|
transition-property: border-color, color, background-color;
|
||||||
|
|
||||||
|
&:focus-visible {
|
||||||
|
outline: 2px solid var(--color-neutral-400);
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.critical {
|
||||||
|
color: #f43f5e;
|
||||||
|
border-color: #f43f5e;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: rgb(244 63 94 / 10%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.recommended {
|
||||||
|
font-size: var(--font-xsm);
|
||||||
|
color: #22c55e;
|
||||||
|
border-color: #22c55e;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: rgb(34 197 94 / 10%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&:focus-visible {
|
||||||
|
background-color: var(--color-neutral-200);
|
||||||
|
}
|
||||||
|
}
|
36
src/components/tools/notepad/button/button.tsx
Normal file
36
src/components/tools/notepad/button/button.tsx
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { Tooltip } from '@/components/tooltip';
|
||||||
|
|
||||||
|
import { cn } from '@/helpers/styles';
|
||||||
|
|
||||||
|
import styles from './button.module.css';
|
||||||
|
|
||||||
|
interface ButtonProps {
|
||||||
|
critical?: boolean;
|
||||||
|
icon: React.ReactElement;
|
||||||
|
onClick: () => void;
|
||||||
|
recommended?: boolean;
|
||||||
|
tooltip: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Button({
|
||||||
|
critical,
|
||||||
|
icon,
|
||||||
|
onClick,
|
||||||
|
recommended,
|
||||||
|
tooltip,
|
||||||
|
}: ButtonProps) {
|
||||||
|
return (
|
||||||
|
<Tooltip content={tooltip} placement="bottom" showDelay={0}>
|
||||||
|
<button
|
||||||
|
className={cn(
|
||||||
|
styles.button,
|
||||||
|
critical && styles.critical,
|
||||||
|
recommended && styles.recommended,
|
||||||
|
)}
|
||||||
|
onClick={onClick}
|
||||||
|
>
|
||||||
|
{icon}
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
}
|
1
src/components/tools/notepad/button/index.ts
Normal file
1
src/components/tools/notepad/button/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { Button } from './button';
|
1
src/components/tools/notepad/index.ts
Normal file
1
src/components/tools/notepad/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { Notepad } from './notepad';
|
44
src/components/tools/notepad/notepad.module.css
Normal file
44
src/components/tools/notepad/notepad.module.css
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
.header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
|
||||||
|
& .label {
|
||||||
|
font-size: var(--font-sm);
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--color-foreground-subtle);
|
||||||
|
}
|
||||||
|
|
||||||
|
& .buttons {
|
||||||
|
display: flex;
|
||||||
|
column-gap: 4px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.textarea {
|
||||||
|
width: 100%;
|
||||||
|
height: 350px;
|
||||||
|
padding: 12px;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: var(--color-foreground-subtle);
|
||||||
|
resize: none;
|
||||||
|
background-color: var(--color-neutral-50);
|
||||||
|
border: 1px solid var(--color-neutral-200);
|
||||||
|
border-radius: 4px;
|
||||||
|
outline: none;
|
||||||
|
scroll-padding-bottom: 12px;
|
||||||
|
|
||||||
|
&:focus-visible {
|
||||||
|
outline: 2px solid var(--color-neutral-400);
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.counter {
|
||||||
|
margin-top: 8px;
|
||||||
|
font-size: var(--font-xsm);
|
||||||
|
color: var(--color-foreground-subtle);
|
||||||
|
text-align: center;
|
||||||
|
}
|
66
src/components/tools/notepad/notepad.tsx
Normal file
66
src/components/tools/notepad/notepad.tsx
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
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 { Button } from './button';
|
||||||
|
|
||||||
|
import { useNoteStore } from '@/stores/note';
|
||||||
|
import { useCopy } from '@/hooks/use-copy';
|
||||||
|
import { download } from '@/helpers/download';
|
||||||
|
|
||||||
|
import styles from './notepad.module.css';
|
||||||
|
import { Container } from '@/components/container';
|
||||||
|
|
||||||
|
export function Notepad() {
|
||||||
|
const note = useNoteStore(state => state.note);
|
||||||
|
const history = useNoteStore(state => state.history);
|
||||||
|
const write = useNoteStore(state => state.write);
|
||||||
|
const words = useNoteStore(state => state.words());
|
||||||
|
const characters = useNoteStore(state => state.characters());
|
||||||
|
const clear = useNoteStore(state => state.clear);
|
||||||
|
const restore = useNoteStore(state => state.restore);
|
||||||
|
|
||||||
|
const { copy, copying } = useCopy();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container>
|
||||||
|
<header className={styles.header}>
|
||||||
|
<h2 className={styles.label}>Your Note</h2>
|
||||||
|
<div className={styles.buttons}>
|
||||||
|
<Button
|
||||||
|
icon={copying ? <FaCheck /> : <LuCopy />}
|
||||||
|
tooltip="Copy Note"
|
||||||
|
onClick={() => copy(note)}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
icon={<LuDownload />}
|
||||||
|
tooltip="Download Note"
|
||||||
|
onClick={() => download('Moodit Note.txt', note)}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
critical={!history}
|
||||||
|
icon={history ? <FaUndo /> : <BiTrash />}
|
||||||
|
recommended={!!history}
|
||||||
|
tooltip={history ? 'Restore Note' : 'Clear Note'}
|
||||||
|
onClick={() => (history ? restore() : clear())}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<textarea
|
||||||
|
className={styles.textarea}
|
||||||
|
dir="auto"
|
||||||
|
placeholder="What is on your mind?"
|
||||||
|
spellCheck={false}
|
||||||
|
value={note}
|
||||||
|
onChange={e => write(e.target.value)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<p className={styles.counter}>
|
||||||
|
{characters} character{characters !== 1 && 's'} • {words} word
|
||||||
|
{words !== 1 && 's'}
|
||||||
|
</p>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
19
src/pages/tools/notepad.astro
Normal file
19
src/pages/tools/notepad.astro
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
import Layout from '@/layouts/layout.astro';
|
||||||
|
|
||||||
|
import Donate from '@/components/donate.astro';
|
||||||
|
import Hero from '@/components/tools/hero.astro';
|
||||||
|
import Footer from '@/components/footer.astro';
|
||||||
|
import About from '@/components/tools/about.astro';
|
||||||
|
import { Notepad as NotepadComponent } from '@/components/tools/notepad';
|
||||||
|
---
|
||||||
|
|
||||||
|
<Layout title="Online Notepad — Moodist">
|
||||||
|
<Donate />
|
||||||
|
<Hero desc="Distraction-free online notepad." title="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."
|
||||||
|
/>
|
||||||
|
<Footer />
|
||||||
|
</Layout>
|
Loading…
x
Reference in New Issue
Block a user