From 53513ac8c2daa8c985d11d3c846402be93f252ea Mon Sep 17 00:00:00 2001 From: Mancee28 Date: Sat, 21 Mar 2026 00:46:59 +0100 Subject: [PATCH] Sono andato avanti. --- AGENTS.md | 2 +- src/lib/assets/ui/color-mode.svg | 5 ++ src/lib/components/board/BoardCanvas.svelte | 7 +- .../board/{Note.svelte => NoteCard.svelte} | 2 +- src/lib/components/board/script/constants.ts | 2 +- .../components/editor/ColorSelector.svelte | 62 ++++++++++++++ src/lib/components/editor/NoteEditor.svelte | 84 ++++++++++++------- src/lib/components/editor/script/constant.ts | 28 ++++++- src/lib/components/ui/ColorModeToggle.svelte | 52 ++++++++++++ src/lib/components/ui/Minimap.svelte | 24 +++--- src/lib/components/ui/Navbar.svelte | 29 ++++--- src/routes/+page.svelte | 22 +++-- 12 files changed, 255 insertions(+), 64 deletions(-) create mode 100644 src/lib/assets/ui/color-mode.svg rename src/lib/components/board/{Note.svelte => NoteCard.svelte} (94%) create mode 100644 src/lib/components/ui/ColorModeToggle.svelte diff --git a/AGENTS.md b/AGENTS.md index 2140b9b..d725619 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1 +1 @@ -- Puoi modificare direttamente i tag e lo stile di componenti e pagine. +- Puoi modificare direttamente i tag e lo stile di componenti e pagine, non puoi modificare la sezione di codice spontaneamente. diff --git a/src/lib/assets/ui/color-mode.svg b/src/lib/assets/ui/color-mode.svg new file mode 100644 index 0000000..3b2c50b --- /dev/null +++ b/src/lib/assets/ui/color-mode.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/lib/components/board/BoardCanvas.svelte b/src/lib/components/board/BoardCanvas.svelte index d91a1d1..4f5c5c4 100644 --- a/src/lib/components/board/BoardCanvas.svelte +++ b/src/lib/components/board/BoardCanvas.svelte @@ -1,5 +1,5 @@ + + + + diff --git a/src/lib/components/editor/NoteEditor.svelte b/src/lib/components/editor/NoteEditor.svelte index 027ab2d..010cf97 100644 --- a/src/lib/components/editor/NoteEditor.svelte +++ b/src/lib/components/editor/NoteEditor.svelte @@ -5,28 +5,19 @@ import imageSvg from '$lib/assets/composer/image.svg'; import fileSvg from '$lib/assets/composer/file.svg'; import paletteSvg from '$lib/assets/composer/palette.svg'; - import { palette } from './script/constant'; + import ColorSelector from './ColorSelector.svelte'; type Props = { - note?: Note; + note: Note; onSubmit: (note: Note) => void; - onClose?: () => void; + onClose: () => void; }; let { note, onSubmit, onClose }: Props = $props(); + let showColorSelector = $state(false); + let colorSelectorWrapper: HTMLDivElement | undefined = $state(); onMount(() => { - if (!note) { - note = { - id: nanoid(), - title: '', - content: '', - color: palette[0], - date: new Date(), - images: [], - files: [] - }; - } return () => {}; }); @@ -37,11 +28,32 @@ onSubmit({ ...note, date: new Date() }); } } - onClose?.(); + onClose(); }; + + const handleColorSelectorClick = (e : MouseEvent & {currentTarget: EventTarget & Window}) => { + if (!showColorSelector || !colorSelectorWrapper) return; + if (!colorSelectorWrapper.contains(e.target as Node)) { + showColorSelector = false; + } + } + + const handleColorSelectorKeydown = (e: KeyboardEvent & {currentTarget: EventTarget & Window} ) => { + if (e.key === 'Escape') { + showColorSelector = false; + } + } + + const onColorSelect = (color: string) => { + note = { ...note, color }; + } + - + {#if note}
@@ -62,14 +74,25 @@