From 2975b80a9493bd8f17c0b509904023c2285fa33f Mon Sep 17 00:00:00 2001 From: gilles Date: Sun, 13 Sep 2026 16:49:13 +0200 Subject: [PATCH] refactor(notes): add shared types and component interfaces folders --- src/interfaces/delete-modal.ts | 6 ++++++ src/interfaces/floating-button.ts | 4 ++++ src/interfaces/note-editor.ts | 29 +++++++++++++++++++++++++++++ src/interfaces/note-list.ts | 6 ++++++ src/types/note.ts | 7 +++++++ 5 files changed, 52 insertions(+) create mode 100644 src/interfaces/delete-modal.ts create mode 100644 src/interfaces/floating-button.ts create mode 100644 src/interfaces/note-editor.ts create mode 100644 src/interfaces/note-list.ts create mode 100644 src/types/note.ts diff --git a/src/interfaces/delete-modal.ts b/src/interfaces/delete-modal.ts new file mode 100644 index 0000000..9b3bcf7 --- /dev/null +++ b/src/interfaces/delete-modal.ts @@ -0,0 +1,6 @@ +export interface DeleteModalProps { + open: boolean + title: string + onConfirm: () => void + onCancel: () => void +} \ No newline at end of file diff --git a/src/interfaces/floating-button.ts b/src/interfaces/floating-button.ts new file mode 100644 index 0000000..48a1c18 --- /dev/null +++ b/src/interfaces/floating-button.ts @@ -0,0 +1,4 @@ +export interface FloatingButtonProps { + onClick: () => void + label?: string +} \ No newline at end of file diff --git a/src/interfaces/note-editor.ts b/src/interfaces/note-editor.ts new file mode 100644 index 0000000..09a5ce0 --- /dev/null +++ b/src/interfaces/note-editor.ts @@ -0,0 +1,29 @@ +import type { Note, NotePatch } from '../types/note' + +export type EditorMode = 'create' | 'edit' + +export interface EditNoteEditorProps { + mode: 'edit' + note: Note + onUpdate: (id: number, patch: NotePatch) => void + onDelete: (id: number) => void +} + +export interface CreateNoteEditorProps { + mode: 'create' + onCreate: (title: string, content: string) => void + onCancelCreate: () => void +} + +export type NoteEditorProps = EditNoteEditorProps | CreateNoteEditorProps + +export interface NoteFormProps { + title: string + content: string + titleMissing: boolean + cancelLabel: string + onTitleChange: (value: string) => void + onContentChange: (value: string) => void + onCancel: () => void + onSubmit: () => void +} \ No newline at end of file diff --git a/src/interfaces/note-list.ts b/src/interfaces/note-list.ts new file mode 100644 index 0000000..234256f --- /dev/null +++ b/src/interfaces/note-list.ts @@ -0,0 +1,6 @@ +import type { Note } from '../types/note' + +export interface NoteListProps { + notes: Note[] + onSelect: (id: number) => void +} \ No newline at end of file diff --git a/src/types/note.ts b/src/types/note.ts new file mode 100644 index 0000000..1d75def --- /dev/null +++ b/src/types/note.ts @@ -0,0 +1,7 @@ +export interface Note { + id: number + title: string + content: string +} + +export type NotePatch = Partial> \ No newline at end of file