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 @@