mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 20:21:09 +02:00
feat(todo): redesign task input and items with glass-pill style
- QuickAddTask: Add glass-morphism pill design with date, priority, and project pickers. Auto-focus on mount, fixed position on mobile above navigation bar with dropdowns opening upward - TaskItem: Redesign with pill-shaped glass-morphism style, matching the navigation components. Includes hover effects, priority dot, and inline meta information - TaskList: Remove redundant spacing since TaskItem has its own margin - New tasks now default to today's date 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
eb98f8949f
commit
37039048f4
3 changed files with 810 additions and 127 deletions
|
|
@ -1,11 +1,63 @@
|
|||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { tasksStore } from '$lib/stores/tasks.svelte';
|
||||
import { viewStore } from '$lib/stores/view.svelte';
|
||||
import { projectsStore } from '$lib/stores/projects.svelte';
|
||||
import type { TaskPriority } from '@todo/shared';
|
||||
import { format, addDays } from 'date-fns';
|
||||
import { de } from 'date-fns/locale';
|
||||
|
||||
let inputValue = $state('');
|
||||
let isLoading = $state(false);
|
||||
let inputRef: HTMLInputElement;
|
||||
|
||||
// Task options
|
||||
let selectedDate = $state<Date>(new Date());
|
||||
let selectedPriority = $state<TaskPriority>('medium');
|
||||
let selectedProjectId = $state<string | undefined>(undefined);
|
||||
|
||||
// Dropdown states
|
||||
let showDatePicker = $state(false);
|
||||
let showPriorityPicker = $state(false);
|
||||
let showProjectPicker = $state(false);
|
||||
|
||||
// Priority options
|
||||
const priorities: { value: TaskPriority; label: string; color: string }[] = [
|
||||
{ value: 'low', label: 'Niedrig', color: '#22c55e' },
|
||||
{ value: 'medium', label: 'Mittel', color: '#eab308' },
|
||||
{ value: 'high', label: 'Hoch', color: '#f97316' },
|
||||
{ value: 'urgent', label: 'Dringend', color: '#ef4444' },
|
||||
];
|
||||
|
||||
// Quick date options
|
||||
const dateOptions = [
|
||||
{ label: 'Heute', date: new Date() },
|
||||
{ label: 'Morgen', date: addDays(new Date(), 1) },
|
||||
{ label: 'In 3 Tagen', date: addDays(new Date(), 3) },
|
||||
{ label: 'Nächste Woche', date: addDays(new Date(), 7) },
|
||||
];
|
||||
|
||||
// Derived values
|
||||
let currentPriority = $derived(priorities.find((p) => p.value === selectedPriority)!);
|
||||
let selectedProject = $derived(
|
||||
selectedProjectId ? projectsStore.getById(selectedProjectId) : undefined
|
||||
);
|
||||
let dateLabel = $derived(() => {
|
||||
const today = new Date();
|
||||
if (selectedDate.toDateString() === today.toDateString()) return 'Heute';
|
||||
if (selectedDate.toDateString() === addDays(today, 1).toDateString()) return 'Morgen';
|
||||
return format(selectedDate, 'dd. MMM', { locale: de });
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
inputRef?.focus();
|
||||
|
||||
// Set project if in project view
|
||||
if (viewStore.currentView === 'project' && viewStore.currentProjectId) {
|
||||
selectedProjectId = viewStore.currentProjectId;
|
||||
}
|
||||
});
|
||||
|
||||
async function handleSubmit(event: Event) {
|
||||
event.preventDefault();
|
||||
|
||||
|
|
@ -15,16 +67,20 @@
|
|||
isLoading = true;
|
||||
|
||||
try {
|
||||
// Create task with current project if in project view
|
||||
const projectId =
|
||||
viewStore.currentView === 'project' ? viewStore.currentProjectId : undefined;
|
||||
|
||||
await tasksStore.createTask({
|
||||
title,
|
||||
projectId: projectId || undefined,
|
||||
projectId: selectedProjectId,
|
||||
dueDate: selectedDate.toISOString(),
|
||||
priority: selectedPriority,
|
||||
});
|
||||
|
||||
// Reset form
|
||||
inputValue = '';
|
||||
selectedDate = new Date();
|
||||
selectedPriority = 'medium';
|
||||
if (viewStore.currentView !== 'project') {
|
||||
selectedProjectId = undefined;
|
||||
}
|
||||
inputRef?.focus();
|
||||
} catch (error) {
|
||||
console.error('Failed to create task:', error);
|
||||
|
|
@ -36,33 +92,510 @@
|
|||
function handleKeydown(event: KeyboardEvent) {
|
||||
if (event.key === 'Escape') {
|
||||
inputValue = '';
|
||||
showDatePicker = false;
|
||||
showPriorityPicker = false;
|
||||
showProjectPicker = false;
|
||||
inputRef?.blur();
|
||||
}
|
||||
}
|
||||
|
||||
function closeAllPickers() {
|
||||
showDatePicker = false;
|
||||
showPriorityPicker = false;
|
||||
showProjectPicker = false;
|
||||
}
|
||||
|
||||
function toggleDatePicker() {
|
||||
showDatePicker = !showDatePicker;
|
||||
showPriorityPicker = false;
|
||||
showProjectPicker = false;
|
||||
}
|
||||
|
||||
function togglePriorityPicker() {
|
||||
showPriorityPicker = !showPriorityPicker;
|
||||
showDatePicker = false;
|
||||
showProjectPicker = false;
|
||||
}
|
||||
|
||||
function toggleProjectPicker() {
|
||||
showProjectPicker = !showProjectPicker;
|
||||
showDatePicker = false;
|
||||
showPriorityPicker = false;
|
||||
}
|
||||
|
||||
function selectDate(date: Date) {
|
||||
selectedDate = date;
|
||||
showDatePicker = false;
|
||||
}
|
||||
|
||||
function selectPriority(priority: TaskPriority) {
|
||||
selectedPriority = priority;
|
||||
showPriorityPicker = false;
|
||||
}
|
||||
|
||||
function selectProject(projectId: string | undefined) {
|
||||
selectedProjectId = projectId;
|
||||
showProjectPicker = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<form onsubmit={handleSubmit} class="mb-6">
|
||||
<div class="relative">
|
||||
<div class="absolute left-4 top-1/2 -translate-y-1/2 text-muted-foreground">
|
||||
<svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<svelte:window onclick={closeAllPickers} />
|
||||
|
||||
<form onsubmit={handleSubmit} class="quick-add-form">
|
||||
<div class="quick-add-wrapper">
|
||||
<!-- Plus icon -->
|
||||
<div class="quick-add-icon">
|
||||
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<!-- Input -->
|
||||
<input
|
||||
bind:this={inputRef}
|
||||
bind:value={inputValue}
|
||||
onkeydown={handleKeydown}
|
||||
type="text"
|
||||
placeholder="Neue Aufgabe hinzufügen..."
|
||||
class="quick-add-input w-full pl-12 pr-4 py-3 rounded-lg border border-border bg-card text-foreground placeholder:text-muted-foreground focus:outline-none"
|
||||
class="quick-add-input"
|
||||
disabled={isLoading}
|
||||
/>
|
||||
{#if isLoading}
|
||||
<div class="absolute right-4 top-1/2 -translate-y-1/2">
|
||||
<div
|
||||
class="animate-spin h-5 w-5 border-2 border-primary border-r-transparent rounded-full"
|
||||
></div>
|
||||
|
||||
<!-- Options -->
|
||||
<div class="quick-add-options">
|
||||
<!-- Date picker -->
|
||||
<div class="option-wrapper">
|
||||
<button
|
||||
type="button"
|
||||
class="option-btn"
|
||||
class:active={showDatePicker}
|
||||
onclick={(e) => {
|
||||
e.stopPropagation();
|
||||
toggleDatePicker();
|
||||
}}
|
||||
title="Fälligkeitsdatum"
|
||||
>
|
||||
<svg class="option-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
|
||||
/>
|
||||
</svg>
|
||||
<span class="option-label">{dateLabel()}</span>
|
||||
</button>
|
||||
|
||||
{#if showDatePicker}
|
||||
<div class="dropdown" onclick={(e) => e.stopPropagation()} role="menu">
|
||||
{#each dateOptions as option}
|
||||
<button
|
||||
type="button"
|
||||
class="dropdown-item"
|
||||
class:selected={selectedDate.toDateString() === option.date.toDateString()}
|
||||
onclick={() => selectDate(option.date)}
|
||||
>
|
||||
{option.label}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Priority picker -->
|
||||
<div class="option-wrapper">
|
||||
<button
|
||||
type="button"
|
||||
class="option-btn"
|
||||
class:active={showPriorityPicker}
|
||||
onclick={(e) => {
|
||||
e.stopPropagation();
|
||||
togglePriorityPicker();
|
||||
}}
|
||||
title="Priorität"
|
||||
>
|
||||
<svg
|
||||
class="option-icon"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke={currentPriority.color}
|
||||
style="color: {currentPriority.color}"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M3 21v-4m0 0V5a2 2 0 012-2h6.5l1 1H21l-3 6 3 6h-8.5l-1-1H5a2 2 0 00-2 2zm9-13.5V9"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
{#if showPriorityPicker}
|
||||
<div class="dropdown" onclick={(e) => e.stopPropagation()} role="menu">
|
||||
{#each priorities as priority}
|
||||
<button
|
||||
type="button"
|
||||
class="dropdown-item"
|
||||
class:selected={selectedPriority === priority.value}
|
||||
onclick={() => selectPriority(priority.value)}
|
||||
>
|
||||
<span class="priority-dot" style="background-color: {priority.color}"></span>
|
||||
{priority.label}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- Project picker -->
|
||||
<div class="option-wrapper">
|
||||
<button
|
||||
type="button"
|
||||
class="option-btn"
|
||||
class:active={showProjectPicker}
|
||||
onclick={(e) => {
|
||||
e.stopPropagation();
|
||||
toggleProjectPicker();
|
||||
}}
|
||||
title="Projekt"
|
||||
>
|
||||
<svg
|
||||
class="option-icon"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke={selectedProject?.color || 'currentColor'}
|
||||
style={selectedProject ? `color: ${selectedProject.color}` : ''}
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
{#if showProjectPicker}
|
||||
<div class="dropdown" onclick={(e) => e.stopPropagation()} role="menu">
|
||||
<button
|
||||
type="button"
|
||||
class="dropdown-item"
|
||||
class:selected={!selectedProjectId}
|
||||
onclick={() => selectProject(undefined)}
|
||||
>
|
||||
<span class="project-dot" style="background-color: #6b7280"></span>
|
||||
Kein Projekt
|
||||
</button>
|
||||
{#each projectsStore.activeProjects as project}
|
||||
<button
|
||||
type="button"
|
||||
class="dropdown-item"
|
||||
class:selected={selectedProjectId === project.id}
|
||||
onclick={() => selectProject(project.id)}
|
||||
>
|
||||
<span class="project-dot" style="background-color: {project.color}"></span>
|
||||
{project.name}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- Divider -->
|
||||
<div class="option-divider"></div>
|
||||
|
||||
<!-- Submit button -->
|
||||
<button type="submit" class="submit-btn" disabled={isLoading || !inputValue.trim()}>
|
||||
{#if isLoading}
|
||||
<div
|
||||
class="animate-spin h-4 w-4 border-2 border-white border-r-transparent rounded-full"
|
||||
></div>
|
||||
{:else}
|
||||
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M13 7l5 5m0 0l-5 5m5-5H6"
|
||||
/>
|
||||
</svg>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<style>
|
||||
.quick-add-form {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
/* Mobile: Fixed at bottom */
|
||||
@media (max-width: 768px) {
|
||||
.quick-add-form {
|
||||
position: fixed;
|
||||
bottom: calc(env(safe-area-inset-bottom, 0px) + 70px);
|
||||
left: 1rem;
|
||||
right: 1rem;
|
||||
margin-bottom: 0;
|
||||
z-index: 100;
|
||||
}
|
||||
}
|
||||
|
||||
.quick-add-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.5rem 0.5rem 0.5rem 1rem;
|
||||
border-radius: 9999px;
|
||||
background: rgba(255, 255, 255, 0.85);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
box-shadow:
|
||||
0 4px 6px -1px rgba(0, 0, 0, 0.1),
|
||||
0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
:global(.dark) .quick-add-wrapper {
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 1px solid rgba(255, 255, 255, 0.15);
|
||||
}
|
||||
|
||||
.quick-add-wrapper:hover {
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
border-color: rgba(0, 0, 0, 0.15);
|
||||
transform: translateY(-1px);
|
||||
box-shadow:
|
||||
0 10px 15px -3px rgba(0, 0, 0, 0.1),
|
||||
0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
:global(.dark) .quick-add-wrapper:hover {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-color: rgba(255, 255, 255, 0.25);
|
||||
}
|
||||
|
||||
.quick-add-wrapper:focus-within {
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
border-color: rgba(139, 92, 246, 0.5);
|
||||
transform: translateY(-1px);
|
||||
box-shadow:
|
||||
0 10px 15px -3px rgba(0, 0, 0, 0.1),
|
||||
0 4px 6px -2px rgba(0, 0, 0, 0.05),
|
||||
0 0 0 3px rgba(139, 92, 246, 0.1);
|
||||
}
|
||||
|
||||
:global(.dark) .quick-add-wrapper:focus-within {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-color: rgba(139, 92, 246, 0.5);
|
||||
box-shadow:
|
||||
0 10px 15px -3px rgba(0, 0, 0, 0.3),
|
||||
0 0 0 3px rgba(139, 92, 246, 0.2);
|
||||
}
|
||||
|
||||
.quick-add-icon {
|
||||
color: var(--color-muted-foreground, #6b7280);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.quick-add-input {
|
||||
flex: 1;
|
||||
background: transparent;
|
||||
border: none;
|
||||
outline: none;
|
||||
font-size: 0.875rem;
|
||||
color: var(--color-foreground, #374151);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.quick-add-input::placeholder {
|
||||
color: var(--color-muted-foreground, #9ca3af);
|
||||
}
|
||||
|
||||
:global(.dark) .quick-add-input {
|
||||
color: #f3f4f6;
|
||||
}
|
||||
|
||||
:global(.dark) .quick-add-input::placeholder {
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
/* Options container */
|
||||
.quick-add-options {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.option-wrapper {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.option-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
padding: 0.375rem 0.5rem;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: #6b7280;
|
||||
cursor: pointer;
|
||||
border-radius: 9999px;
|
||||
transition: all 0.15s;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
:global(.dark) .option-btn {
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.option-btn:hover,
|
||||
.option-btn.active {
|
||||
background: rgba(0, 0, 0, 0.05);
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
:global(.dark) .option-btn:hover,
|
||||
:global(.dark) .option-btn.active {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
color: #f3f4f6;
|
||||
}
|
||||
|
||||
.option-icon {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.option-label {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (min-width: 640px) {
|
||||
.option-label {
|
||||
display: inline;
|
||||
}
|
||||
}
|
||||
|
||||
.option-divider {
|
||||
width: 1px;
|
||||
height: 1.25rem;
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
margin: 0 0.25rem;
|
||||
}
|
||||
|
||||
:global(.dark) .option-divider {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
}
|
||||
|
||||
/* Dropdown */
|
||||
.dropdown {
|
||||
position: absolute;
|
||||
top: calc(100% + 0.5rem);
|
||||
right: 0;
|
||||
min-width: 140px;
|
||||
padding: 0.375rem;
|
||||
border-radius: 0.75rem;
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
box-shadow:
|
||||
0 10px 15px -3px rgba(0, 0, 0, 0.1),
|
||||
0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
||||
z-index: 50;
|
||||
}
|
||||
|
||||
/* Mobile: Dropdown opens upward */
|
||||
@media (max-width: 768px) {
|
||||
.dropdown {
|
||||
top: auto;
|
||||
bottom: calc(100% + 0.5rem);
|
||||
box-shadow:
|
||||
0 -10px 15px -3px rgba(0, 0, 0, 0.1),
|
||||
0 -4px 6px -2px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
}
|
||||
|
||||
:global(.dark) .dropdown {
|
||||
background: rgba(40, 40, 40, 0.95);
|
||||
border: 1px solid rgba(255, 255, 255, 0.15);
|
||||
}
|
||||
|
||||
.dropdown-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
width: 100%;
|
||||
padding: 0.5rem 0.75rem;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: #374151;
|
||||
cursor: pointer;
|
||||
border-radius: 0.5rem;
|
||||
font-size: 0.8125rem;
|
||||
text-align: left;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
|
||||
:global(.dark) .dropdown-item {
|
||||
color: #f3f4f6;
|
||||
}
|
||||
|
||||
.dropdown-item:hover {
|
||||
background: rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
:global(.dark) .dropdown-item:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.dropdown-item.selected {
|
||||
background: rgba(139, 92, 246, 0.1);
|
||||
color: #8b5cf6;
|
||||
}
|
||||
|
||||
:global(.dark) .dropdown-item.selected {
|
||||
background: rgba(139, 92, 246, 0.2);
|
||||
}
|
||||
|
||||
.priority-dot,
|
||||
.project-dot {
|
||||
width: 0.5rem;
|
||||
height: 0.5rem;
|
||||
border-radius: 9999px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Submit button */
|
||||
.submit-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
border: none;
|
||||
background: #8b5cf6;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
border-radius: 9999px;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
|
||||
.submit-btn:hover:not(:disabled) {
|
||||
background: #7c3aed;
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.submit-btn:disabled {
|
||||
background: #d1d5db;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
:global(.dark) .submit-btn:disabled {
|
||||
background: #4b5563;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@
|
|||
|
||||
// Priority colors
|
||||
const priorityColors: Record<string, string> = {
|
||||
low: 'bg-green-500',
|
||||
medium: 'bg-yellow-500',
|
||||
high: 'bg-orange-500',
|
||||
urgent: 'bg-red-500',
|
||||
low: '#22c55e',
|
||||
medium: '#eab308',
|
||||
high: '#f97316',
|
||||
urgent: '#ef4444',
|
||||
};
|
||||
|
||||
// Format due date
|
||||
|
|
@ -51,131 +51,281 @@
|
|||
});
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="task-item group flex items-start gap-3 p-3 rounded-lg border border-border bg-card hover:bg-accent/5 transition-colors"
|
||||
class:opacity-60={task.isCompleted}
|
||||
>
|
||||
<div class="task-item group" class:completed={task.isCompleted}>
|
||||
<!-- Priority indicator -->
|
||||
<div class="priority-indicator {priorityColors[task.priority]} h-full min-h-[40px]"></div>
|
||||
<div
|
||||
class="priority-dot"
|
||||
style="background-color: {priorityColors[task.priority] || priorityColors.medium}"
|
||||
></div>
|
||||
|
||||
<!-- Checkbox -->
|
||||
<button
|
||||
class="task-checkbox flex-shrink-0 w-5 h-5 rounded-full border-2 border-muted-foreground hover:border-primary flex items-center justify-center mt-0.5"
|
||||
class:bg-primary={task.isCompleted}
|
||||
class:border-primary={task.isCompleted}
|
||||
onclick={onToggleComplete}
|
||||
>
|
||||
<button class="task-checkbox" class:checked={task.isCompleted} onclick={onToggleComplete}>
|
||||
{#if task.isCompleted}
|
||||
<svg class="w-3 h-3 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<svg class="check-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="3" d="M5 13l4 4L19 7" />
|
||||
</svg>
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex-1 min-w-0">
|
||||
<div class="flex items-start justify-between gap-2">
|
||||
<h3
|
||||
class="text-sm font-medium text-foreground truncate"
|
||||
class:line-through={task.isCompleted}
|
||||
>
|
||||
{task.title}
|
||||
</h3>
|
||||
<div class="task-content">
|
||||
<span class="task-title" class:line-through={task.isCompleted}>
|
||||
{task.title}
|
||||
</span>
|
||||
|
||||
<!-- Delete button (hidden by default, shown on hover) -->
|
||||
<button
|
||||
class="opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-red-500 transition-opacity"
|
||||
onclick={onDelete}
|
||||
>
|
||||
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<!-- Meta info inline -->
|
||||
{#if dueDateText() || subtaskProgress() || (task.labels && task.labels.length > 0)}
|
||||
<div class="task-meta">
|
||||
{#if dueDateText()}
|
||||
<span
|
||||
class="meta-item date"
|
||||
class:overdue={isOverdue()}
|
||||
class:today={isToday(new Date(task.dueDate || 0))}
|
||||
>
|
||||
<svg class="meta-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
|
||||
/>
|
||||
</svg>
|
||||
{dueDateText()}
|
||||
</span>
|
||||
{/if}
|
||||
|
||||
{#if task.description}
|
||||
<p class="text-xs text-muted-foreground mt-1 line-clamp-2">
|
||||
{task.description}
|
||||
</p>
|
||||
{/if}
|
||||
{#if subtaskProgress()}
|
||||
<span class="meta-item">
|
||||
<svg class="meta-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"
|
||||
/>
|
||||
</svg>
|
||||
{subtaskProgress()}
|
||||
</span>
|
||||
{/if}
|
||||
|
||||
<!-- Meta info -->
|
||||
<div class="flex items-center gap-3 mt-2 flex-wrap">
|
||||
{#if dueDateText()}
|
||||
<span
|
||||
class="text-xs flex items-center gap-1"
|
||||
class:text-red-500={isOverdue()}
|
||||
class:text-orange-500={isToday(new Date(task.dueDate || 0))}
|
||||
class:text-muted-foreground={!isOverdue() && !isToday(new Date(task.dueDate || 0))}
|
||||
>
|
||||
<svg class="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
|
||||
/>
|
||||
</svg>
|
||||
{dueDateText()}
|
||||
</span>
|
||||
{/if}
|
||||
|
||||
{#if subtaskProgress()}
|
||||
<span class="text-xs text-muted-foreground flex items-center gap-1">
|
||||
<svg class="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"
|
||||
/>
|
||||
</svg>
|
||||
{subtaskProgress()}
|
||||
</span>
|
||||
{/if}
|
||||
|
||||
{#if task.labels && task.labels.length > 0}
|
||||
<div class="flex items-center gap-1">
|
||||
{#each task.labels.slice(0, 3) as label}
|
||||
<span
|
||||
class="text-xs px-1.5 py-0.5 rounded"
|
||||
style="background-color: {label.color}20; color: {label.color}"
|
||||
>
|
||||
{#if task.labels && task.labels.length > 0}
|
||||
{#each task.labels.slice(0, 2) as label}
|
||||
<span class="label-tag" style="--label-color: {label.color}">
|
||||
{label.name}
|
||||
</span>
|
||||
{/each}
|
||||
{#if task.labels.length > 3}
|
||||
<span class="text-xs text-muted-foreground">+{task.labels.length - 3}</span>
|
||||
{#if task.labels.length > 2}
|
||||
<span class="meta-item">+{task.labels.length - 2}</span>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if task.recurrenceRule}
|
||||
<span class="text-xs text-muted-foreground flex items-center gap-1">
|
||||
<svg class="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
|
||||
/>
|
||||
</svg>
|
||||
Wiederkehrend
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- Project color indicator -->
|
||||
<!-- Project indicator -->
|
||||
{#if projectColor()}
|
||||
<div
|
||||
class="w-2 h-2 rounded-full flex-shrink-0"
|
||||
style="background-color: {projectColor()}"
|
||||
></div>
|
||||
<div class="project-dot" style="background-color: {projectColor()}"></div>
|
||||
{/if}
|
||||
|
||||
<!-- Delete button -->
|
||||
<button class="delete-btn" onclick={onDelete}>
|
||||
<svg class="delete-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M6 18L18 6M6 6l12 12"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.task-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 0.625rem 1rem;
|
||||
border-radius: 9999px;
|
||||
background: rgba(255, 255, 255, 0.85);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
box-shadow:
|
||||
0 4px 6px -1px rgba(0, 0, 0, 0.1),
|
||||
0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
||||
transition: all 0.2s;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
:global(.dark) .task-item {
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 1px solid rgba(255, 255, 255, 0.15);
|
||||
}
|
||||
|
||||
.task-item:hover {
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
border-color: rgba(0, 0, 0, 0.15);
|
||||
transform: translateY(-1px);
|
||||
box-shadow:
|
||||
0 10px 15px -3px rgba(0, 0, 0, 0.1),
|
||||
0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
:global(.dark) .task-item:hover {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-color: rgba(255, 255, 255, 0.25);
|
||||
}
|
||||
|
||||
.task-item.completed {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
/* Priority dot */
|
||||
.priority-dot {
|
||||
width: 0.5rem;
|
||||
height: 0.5rem;
|
||||
border-radius: 9999px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Checkbox */
|
||||
.task-checkbox {
|
||||
width: 1.25rem;
|
||||
height: 1.25rem;
|
||||
border-radius: 9999px;
|
||||
border: 2px solid rgba(0, 0, 0, 0.2);
|
||||
background: transparent;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
flex-shrink: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
:global(.dark) .task-checkbox {
|
||||
border-color: rgba(255, 255, 255, 0.3);
|
||||
}
|
||||
|
||||
.task-checkbox:hover {
|
||||
border-color: #8b5cf6;
|
||||
background: rgba(139, 92, 246, 0.1);
|
||||
}
|
||||
|
||||
.task-checkbox.checked {
|
||||
background: #8b5cf6;
|
||||
border-color: #8b5cf6;
|
||||
}
|
||||
|
||||
.check-icon {
|
||||
width: 0.75rem;
|
||||
height: 0.75rem;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Content */
|
||||
.task-content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.task-title {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
color: #374151;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
:global(.dark) .task-title {
|
||||
color: #f3f4f6;
|
||||
}
|
||||
|
||||
.task-title.line-through {
|
||||
text-decoration: line-through;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
/* Meta info */
|
||||
.task-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.meta-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
font-size: 0.75rem;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
:global(.dark) .meta-item {
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.meta-item.date.overdue {
|
||||
color: #ef4444;
|
||||
}
|
||||
|
||||
.meta-item.date.today {
|
||||
color: #f97316;
|
||||
}
|
||||
|
||||
.meta-icon {
|
||||
width: 0.75rem;
|
||||
height: 0.75rem;
|
||||
}
|
||||
|
||||
.label-tag {
|
||||
font-size: 0.625rem;
|
||||
padding: 0.125rem 0.5rem;
|
||||
border-radius: 9999px;
|
||||
background: color-mix(in srgb, var(--label-color) 15%, transparent);
|
||||
color: var(--label-color);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* Project dot */
|
||||
.project-dot {
|
||||
width: 0.5rem;
|
||||
height: 0.5rem;
|
||||
border-radius: 9999px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Delete button */
|
||||
.delete-btn {
|
||||
opacity: 0;
|
||||
padding: 0.25rem;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: #9ca3af;
|
||||
cursor: pointer;
|
||||
border-radius: 9999px;
|
||||
transition: all 0.15s;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.task-item:hover .delete-btn {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.delete-btn:hover {
|
||||
color: #ef4444;
|
||||
background: rgba(239, 68, 68, 0.1);
|
||||
}
|
||||
|
||||
.delete-icon {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
}
|
||||
</script>
|
||||
|
||||
<div class="task-list space-y-2">
|
||||
<div class="task-list">
|
||||
{#each tasks as task (task.id)}
|
||||
<TaskItem
|
||||
{task}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue