diff --git a/src/lib/ListItem.svelte b/src/lib/ListItem.svelte index 2df45c8..23f1b3a 100644 --- a/src/lib/ListItem.svelte +++ b/src/lib/ListItem.svelte @@ -1,35 +1,44 @@ -
+
{list.title}

{completed}/{list.tasks.length}

-
- + +
diff --git a/src/lib/stores.svelte.ts b/src/lib/stores.svelte.ts index acbf3ed..80a1621 100644 --- a/src/lib/stores.svelte.ts +++ b/src/lib/stores.svelte.ts @@ -26,10 +26,12 @@ export const local_lists = new PersistedState("local_lists", [ ]); export const pinned_list = new PersistedState("pinned_list", local_lists.current[0].id); +export const archived_lists = new PersistedState("archived_lists", []); const DEFAULT_USER_PREFERENCES = { theme: "dark", - openPinOnLoad: false + openPinOnLoad: false, + showArchiveAtHomeDefault: false }; export const user_preferences = new PersistedState("easyUserPreferences", DEFAULT_USER_PREFERENCES); diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 5338014..dbacf44 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,5 +1,5 @@ import toast from "svelte-french-toast"; -import { local_lists, pinned_list } from "./stores.svelte"; +import { archived_lists, local_lists, pinned_list } from "./stores.svelte"; import { alphabet, generateRandomString } from "oslo/crypto"; export function generateId() { @@ -44,3 +44,18 @@ export function deleteList(id: string) { export function pinList(id: string) { pinned_list.current = id; } + +export function toggleArchiveList(id: string) { + if (pinned_list.current === id) { + toast.error("Cannot archive pinned list"); + return; + } + + const archived = archived_lists.current; + if (archived.find(a => a === id)) { + archived_lists.current = archived.filter(a => a !== id); + } + else { + archived_lists.current!.push(id); + } +} diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 1114f00..e4212a0 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,16 +1,31 @@

Your Lists

+ + +
- {#each local_lists.current as list} - + {#each local_lists.current as list (list.id)} + {@const is_archived = !!archived_lists.current.find(a => a === list.id)} + {#if is_archived} + {#if show_archived} + + {/if} + {:else} + + {/if} {/each}
diff --git a/src/routes/[id]/+page.svelte b/src/routes/[id]/+page.svelte index e5f80ab..5362733 100644 --- a/src/routes/[id]/+page.svelte +++ b/src/routes/[id]/+page.svelte @@ -2,14 +2,14 @@ import { page } from "$app/state"; import { goto } from "$app/navigation"; import toast from "svelte-french-toast"; - import { createList, deleteList, generateId, pinList } from "$lib/utils"; - import { local_lists, pinned_list, type List } from "$lib/stores.svelte"; + import { createList, deleteList, generateId, pinList, toggleArchiveList } from "$lib/utils"; + import { archived_lists, local_lists, pinned_list, type List } from "$lib/stores.svelte"; import TaskItem from "$lib/TaskItem.svelte"; let is_menu_open = $state(false); let list : List | undefined = $derived(local_lists.current!.find((l) => l.id === page.params.id)); let task_input = $state(""); - let user_lists = $derived(local_lists.current) as List[]; + let is_archived = $derived(!!archived_lists.current.find(a => a === list?.id)) function addTask() { if (task_input.length === 0) { @@ -57,11 +57,11 @@ class="w-12 h-12 hover:bg-slate-500/10 rounded-full" /> -
{#if is_menu_open} + {@const archived_items = local_lists.current.filter(l => archived_lists.current.includes(l.id))} + {@const active_items = local_lists.current.filter(l => !archived_lists.current.includes(l.id))} - {#each user_lists as user_list : List (user_list.id)} - - {/each} +
+ Lists +
+ {#each active_items as user_list : List (user_list.id)} + + {/each} +
+
+
+ Archived +
+ {#each archived_items as inactive_list : List (inactive_list.id)} + + {/each} +
+
{/if} diff --git a/static/octicons--archive.svg b/static/octicons--archive.svg deleted file mode 100644 index 7148347..0000000 --- a/static/octicons--archive.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/static/tabler--archive-filled.svg b/static/tabler--archive-filled.svg new file mode 100644 index 0000000..345e64c --- /dev/null +++ b/static/tabler--archive-filled.svg @@ -0,0 +1,3 @@ + + + diff --git a/static/tabler--archive.svg b/static/tabler--archive.svg new file mode 100644 index 0000000..7241339 --- /dev/null +++ b/static/tabler--archive.svg @@ -0,0 +1,3 @@ + + +