diff --git a/CHANGELOG.md b/CHANGELOG.md index 1db9854c..106beb62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- [todo] Migrated todo route and all corresponding components (TodoList, TodoInput, Todo, TodoListOverlay, +page) to Svelte 5 runes syntax ($props, $state, $derived, $effect) for improved reactivity and type safety. +- [todo] Enhanced Todo component with improved UI/UX including clickable rows, better visual feedback, and proper accessibility. +- [todo] Improved TodoList with sorted todos (unchecked first), better state management using $derived, and enhanced history management. +- [todo] Enhanced TodoListOverlay with better form handling, proper state management, and automatic list selection after creation. +- [todo] Updated translations for global menu button text to be more descriptive. - [food-scan] Migrated food-scan route and all corresponding components (FoodScan, ContentOutput, DebugInformation) to Svelte 5 runes syntax ($props, $state, $derived, $effect) for improved reactivity and type safety. - [uno-sort] Migrated uno-sort route and ToggledApplicationInfo component to Svelte 5 runes syntax ($props, $state, $derived, $effect) for improved reactivity and type safety. - [settings] Migrated settings route and all corresponding components (+page, SettingsDashboard, OnlinePersistenceCheck, ThemeSwitch, LanguageSwitch, BackgroundSwitch, IdentifierInformation) to Svelte 5 runes syntax ($props, $state, $derived, $effect) for improved reactivity and type safety. diff --git a/frontend/src/lib/components/todo/Todo.svelte b/frontend/src/lib/components/todo/Todo.svelte index 1e755371..31025fa5 100644 --- a/frontend/src/lib/components/todo/Todo.svelte +++ b/frontend/src/lib/components/todo/Todo.svelte @@ -1,33 +1,55 @@ -
- - - {todo?.title} +
+
diff --git a/frontend/src/lib/components/todo/TodoInput.svelte b/frontend/src/lib/components/todo/TodoInput.svelte index 37b71cd1..0ae60261 100644 --- a/frontend/src/lib/components/todo/TodoInput.svelte +++ b/frontend/src/lib/components/todo/TodoInput.svelte @@ -1,35 +1,41 @@ {#if $initialized} diff --git a/frontend/src/lib/components/todo/TodoList.svelte b/frontend/src/lib/components/todo/TodoList.svelte index 615cb3ae..ed878045 100644 --- a/frontend/src/lib/components/todo/TodoList.svelte +++ b/frontend/src/lib/components/todo/TodoList.svelte @@ -1,4 +1,5 @@ @@ -126,7 +178,7 @@ {#if list?.history?.length > 0}
- {#each list?.history as entry} + {#each list.history as entry (entry)}
- {#each list?.todos as todo} - {#if todo} - deleteTodo(todo.id)} - todoChecked={() => checkTodo(todo.id)} - /> - {/if} + {#each list?.todos || [] as todo (todo.id)} + deleteTodo(todo.id)} + todoChecked={() => checkTodo(todo.id)} + /> {/each}
diff --git a/frontend/src/lib/components/todo/TodoListOverlay.svelte b/frontend/src/lib/components/todo/TodoListOverlay.svelte index 74bdb1cd..a4add8d8 100644 --- a/frontend/src/lib/components/todo/TodoListOverlay.svelte +++ b/frontend/src/lib/components/todo/TodoListOverlay.svelte @@ -1,4 +1,5 @@ @@ -98,9 +118,9 @@ : updateList} on:click:button--secondary={({ detail }) => { if (detail.text === $t('page.shared.abort')) closeOverlay(); - if (detail.text === $t('page.shared.delete')) deleteList(listIndex); + if (detail.text === $t('page.shared.delete')) deleteList(); }} - class={modalStates()} + class={modalStates} > {#if $initialized} {#if $listOverlayOptionsStore.type === 'new'} @@ -111,7 +131,7 @@

{$t('page.todos.overlay.createSubtitle', { - listName: listName, + listName: localListName, })}.

@@ -119,7 +139,7 @@
+ // 1. IMPORTS import ToggledApplicationInfo from '$lib/components/shared/ToggledApplicationInfo.svelte'; import TodoListComponent from '$lib/components/todo/TodoList.svelte'; import TodoListOverlay from '$lib/components/todo/TodoListOverlay.svelte'; @@ -15,18 +16,31 @@ import TaskAdd from 'carbon-icons-svelte/lib/TaskAdd.svelte'; import { onMount } from 'svelte'; + // 2. CONST (non-reactive constants) const { todo: todoRoute } = applicationRoutes; - let currentListId = ''; - let newListId = ''; - let openMenu = false; + // 4. STATE + let currentListId = $state(''); + let newListId = $state(''); + let openMenu = $state(false); + let locale = $state($languageStore); - $: locale = $languageStore; + // 6. EFFECTS + $effect(() => { + locale = $languageStore; + }); + // 7. LIFECYCLE onMount(async () => { await setLocale($languageStore); + + // Listen for list creation events + window.addEventListener('list-created', ((e: CustomEvent) => { + currentListId = e.detail.id; + }) as EventListener); }); + // 8. FUNCTIONS const showListOverlay = (type: 'new' | 'edit', id?: string) => { openMenu = false; if (type === 'new') { @@ -118,7 +132,7 @@