diff --git a/apps/mana/apps/web/src/lib/modules/moodlit/ListView.svelte b/apps/mana/apps/web/src/lib/modules/moodlit/ListView.svelte index 26d7b99b6..06c1061ec 100644 --- a/apps/mana/apps/web/src/lib/modules/moodlit/ListView.svelte +++ b/apps/mana/apps/web/src/lib/modules/moodlit/ListView.svelte @@ -6,7 +6,8 @@ import { useLiveQueryWithDefault } from '@mana/local-store/svelte'; import { db } from '$lib/data/database'; import { BaseListView } from '@mana/shared-ui'; - import type { LocalMood } from './types'; + import type { LocalMood, AnimationType } from './types'; + import { ANIMATIONS } from './types'; import { moodsStore } from './stores/moods.svelte'; import { ContextMenu, type ContextMenuItem } from '@mana/shared-ui'; import { useItemContextMenu } from '$lib/data/item-context-menu.svelte'; @@ -28,6 +29,39 @@ return `background: linear-gradient(135deg, ${colors.join(', ')})`; } + // ── Inline create ────────────────────────────────────── + let creating = $state(false); + let newName = $state(''); + let newColors = $state(['#667eea', '#764ba2']); + let newAnimation = $state('gradient'); + + function addColor() { + if (newColors.length < 8) { + const hex = + '#' + + Math.floor(Math.random() * 16777215) + .toString(16) + .padStart(6, '0'); + newColors = [...newColors, hex]; + } + } + + function removeColor(index: number) { + if (newColors.length > 1) { + newColors = newColors.filter((_, i) => i !== index); + } + } + + async function handleCreate() { + const name = newName.trim(); + if (!name || newColors.length === 0) return; + await moodsStore.createMood({ name, colors: newColors, animation: newAnimation }); + newName = ''; + newColors = ['#667eea', '#764ba2']; + newAnimation = 'gradient'; + creating = false; + } + const ctxMenu = useItemContextMenu(); let ctxMenuItems = $derived( @@ -82,6 +116,88 @@

Kein Mood aktiv

{/if} + + +
+ {moods.length} Moods + +
+ + {#if creating} +
+ +
+ {newName || 'Vorschau'} +
+ + + + + +
+ {#each newColors as color, i} +
+ { + newColors = newColors.map((c, j) => (j === i ? e.currentTarget.value : c)); + }} + class="h-8 w-8 cursor-pointer rounded-md border border-white/10" + /> + {#if newColors.length > 1} + + {/if} +
+ {/each} + {#if newColors.length < 8} + + {/if} +
+ + + + + + +
+ {/if} {/snippet} {#snippet item(mood)}