mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-16 15:59:40 +02:00
refactor(todo-web): unify FilterStrip and KanbanFilters into TaskFilters
Replace two separate filter components with a single TaskFilters component
that supports both layouts via a variant prop ("strip" for bottom pill bar,
"bar" for inline kanban-style). Fixes a bug where FilterStrip's priority
and project filters were dead local state that never actually filtered tasks.
- Add filter state (priorities, project, labels, search) to viewStore
- Apply filters to all derived task lists in the list view
- Delete FilterStrip.svelte and KanbanFilters.svelte
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e00e6ee8b7
commit
f5842ea50e
7 changed files with 841 additions and 761 deletions
|
|
@ -1,421 +0,0 @@
|
|||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import type { TaskPriority } from '@todo/shared';
|
||||
import { projectsStore } from '$lib/stores/projects.svelte';
|
||||
import { labelsStore } from '$lib/stores/labels.svelte';
|
||||
import { viewStore, type SortBy } from '$lib/stores/view.svelte';
|
||||
import { todoSettings } from '$lib/stores/settings.svelte';
|
||||
import { X, DotsThree } from '@manacore/shared-icons';
|
||||
|
||||
// Filter dropdown states
|
||||
let showFilterDropdown = $state(false);
|
||||
let selectedPriorityFilters = $state<TaskPriority[]>([]);
|
||||
let selectedProjectFilter = $state<string | null>(null);
|
||||
let selectedLabelFilters = $state<string[]>([]);
|
||||
|
||||
const priorities: { value: TaskPriority; label: string; color: string }[] = [
|
||||
{ value: 'urgent', label: 'Dringend', color: '#ef4444' },
|
||||
{ value: 'high', label: 'Hoch', color: '#f97316' },
|
||||
{ value: 'medium', label: 'Normal', color: '#eab308' },
|
||||
{ value: 'low', label: 'Niedrig', color: '#3b82f6' },
|
||||
];
|
||||
|
||||
// Sort options
|
||||
const sortOptions: { id: SortBy; label: string }[] = [
|
||||
{ id: 'dueDate', label: 'Datum' },
|
||||
{ id: 'priority', label: 'Priorit.' },
|
||||
{ id: 'title', label: 'Name' },
|
||||
];
|
||||
|
||||
// Count active filters
|
||||
let activeFilterCount = $derived(
|
||||
selectedPriorityFilters.length + (selectedProjectFilter ? 1 : 0) + selectedLabelFilters.length
|
||||
);
|
||||
|
||||
function togglePriorityFilter(priority: TaskPriority) {
|
||||
if (selectedPriorityFilters.includes(priority)) {
|
||||
selectedPriorityFilters = selectedPriorityFilters.filter((p) => p !== priority);
|
||||
} else {
|
||||
selectedPriorityFilters = [...selectedPriorityFilters, priority];
|
||||
}
|
||||
}
|
||||
|
||||
function clearAllFilters() {
|
||||
selectedPriorityFilters = [];
|
||||
selectedProjectFilter = null;
|
||||
selectedLabelFilters = [];
|
||||
}
|
||||
|
||||
function handleSortChange(sortBy: SortBy) {
|
||||
viewStore.setSort(sortBy, viewStore.sortOrder);
|
||||
}
|
||||
|
||||
function closeFilterDropdown() {
|
||||
showFilterDropdown = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window onclick={closeFilterDropdown} />
|
||||
|
||||
<div class="filter-strip-wrapper">
|
||||
<div class="filter-strip-container">
|
||||
<!-- Clear Filter Button (always rendered to prevent layout shift) -->
|
||||
<button
|
||||
class="clear-filter-pill glass-pill"
|
||||
class:hidden={activeFilterCount === 0}
|
||||
onclick={clearAllFilters}
|
||||
title="Filter löschen"
|
||||
disabled={activeFilterCount === 0}
|
||||
>
|
||||
<X size={16} weight="bold" />
|
||||
<span class="pill-label">Filter</span>
|
||||
</button>
|
||||
|
||||
<!-- Kanban View Button -->
|
||||
<button class="glass-pill" onclick={() => goto('/kanban')} title="Kanban-Ansicht">
|
||||
<svg class="pill-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M9 17V7m0 10a2 2 0 01-2 2H5a2 2 0 01-2-2V7a2 2 0 012-2h2a2 2 0 012 2m0 10a2 2 0 002 2h2a2 2 0 002-2M9 7a2 2 0 012-2h2a2 2 0 012 2m0 10V7m0 10a2 2 0 002 2h2a2 2 0 002-2V7a2 2 0 00-2-2h-2a2 2 0 00-2 2"
|
||||
/>
|
||||
</svg>
|
||||
<span class="pill-label">Kanban</span>
|
||||
</button>
|
||||
|
||||
<!-- Priority Filter Pills -->
|
||||
{#each priorities as priority (priority.value)}
|
||||
<button
|
||||
class="priority-pill glass-pill"
|
||||
class:selected={selectedPriorityFilters.includes(priority.value)}
|
||||
onclick={() => togglePriorityFilter(priority.value)}
|
||||
title={priority.label}
|
||||
style="--priority-color: {priority.color}"
|
||||
>
|
||||
<span class="priority-dot"></span>
|
||||
<span class="pill-label">{priority.label}</span>
|
||||
</button>
|
||||
{/each}
|
||||
|
||||
<!-- Sort Pills -->
|
||||
{#each sortOptions as option (option.id)}
|
||||
<button
|
||||
class="sort-pill glass-pill"
|
||||
class:active={viewStore.sortBy === option.id}
|
||||
onclick={() => handleSortChange(option.id)}
|
||||
title="Nach {option.label} sortieren"
|
||||
>
|
||||
<span class="pill-label">{option.label}</span>
|
||||
</button>
|
||||
{/each}
|
||||
|
||||
<!-- Show Completed Toggle -->
|
||||
<button
|
||||
class="glass-pill"
|
||||
class:active={viewStore.showCompleted}
|
||||
onclick={() => viewStore.toggleShowCompleted()}
|
||||
title={viewStore.showCompleted ? 'Erledigte ausblenden' : 'Erledigte anzeigen'}
|
||||
>
|
||||
<svg
|
||||
class="pill-icon"
|
||||
fill={viewStore.showCompleted ? 'currentColor' : 'none'}
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
|
||||
/>
|
||||
</svg>
|
||||
<span class="pill-label">Erledigt</span>
|
||||
</button>
|
||||
|
||||
<!-- More Options (Project Filter) -->
|
||||
<div class="filter-dropdown-container" onclick={(e) => e.stopPropagation()}>
|
||||
<button
|
||||
class="more-pill glass-pill"
|
||||
onclick={() => (showFilterDropdown = !showFilterDropdown)}
|
||||
title="Weitere Filter"
|
||||
>
|
||||
<DotsThree size={18} weight="bold" />
|
||||
<span class="pill-label">Mehr</span>
|
||||
</button>
|
||||
|
||||
{#if showFilterDropdown}
|
||||
<div class="filter-dropdown" onclick={(e) => e.stopPropagation()}>
|
||||
<div class="filter-section">
|
||||
<div class="filter-section-header">Projekt</div>
|
||||
<select
|
||||
class="filter-select"
|
||||
value={selectedProjectFilter || ''}
|
||||
onchange={(e) => (selectedProjectFilter = e.currentTarget.value || null)}
|
||||
>
|
||||
<option value="">Alle Projekte</option>
|
||||
{#each projectsStore.activeProjects as project}
|
||||
<option value={project.id}>{project.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.filter-strip-wrapper {
|
||||
position: fixed;
|
||||
bottom: calc(70px + env(safe-area-inset-bottom, 0px)); /* Directly above PillNav */
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 49;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
pointer-events: none;
|
||||
transition: bottom 0.2s ease;
|
||||
}
|
||||
|
||||
.filter-strip-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
background: transparent;
|
||||
pointer-events: auto;
|
||||
width: fit-content;
|
||||
max-width: 100%;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
padding: 0.5rem 2rem;
|
||||
overflow-x: auto;
|
||||
scrollbar-width: none;
|
||||
-ms-overflow-style: none;
|
||||
}
|
||||
|
||||
.filter-strip-container::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Glass pill styling - same as PillNavigation pills */
|
||||
.glass-pill {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 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);
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
|
||||
:global(.dark) .glass-pill {
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 1px solid rgba(255, 255, 255, 0.15);
|
||||
}
|
||||
|
||||
.glass-pill:hover {
|
||||
transform: scale(1.05);
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
border-color: rgba(0, 0, 0, 0.15);
|
||||
box-shadow:
|
||||
0 10px 15px -3px rgba(0, 0, 0, 0.1),
|
||||
0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
:global(.dark) .glass-pill:hover {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-color: rgba(255, 255, 255, 0.25);
|
||||
}
|
||||
|
||||
.glass-pill:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
.glass-pill.active {
|
||||
background: rgba(139, 92, 246, 0.15);
|
||||
border-color: rgba(139, 92, 246, 0.3);
|
||||
color: #8b5cf6;
|
||||
}
|
||||
|
||||
:global(.dark) .glass-pill.active {
|
||||
background: rgba(139, 92, 246, 0.25);
|
||||
border-color: rgba(139, 92, 246, 0.4);
|
||||
}
|
||||
|
||||
.pill-icon {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.pill-label {
|
||||
font-size: 0.9375rem;
|
||||
font-weight: 500;
|
||||
color: #374151;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
:global(.dark) .pill-label {
|
||||
color: #f3f4f6;
|
||||
}
|
||||
|
||||
.glass-pill.active .pill-label {
|
||||
color: #8b5cf6;
|
||||
}
|
||||
|
||||
/* Priority pills */
|
||||
.priority-pill.selected {
|
||||
background: var(--priority-color) !important;
|
||||
border-color: var(--priority-color) !important;
|
||||
}
|
||||
|
||||
.priority-pill.selected .priority-dot {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.priority-pill.selected .pill-label {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.priority-dot {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
background-color: var(--priority-color);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Clear filter pill */
|
||||
.clear-filter-pill {
|
||||
color: #ef4444;
|
||||
background: rgba(239, 68, 68, 0.1) !important;
|
||||
border-color: rgba(239, 68, 68, 0.3) !important;
|
||||
}
|
||||
|
||||
.clear-filter-pill .pill-label {
|
||||
color: #ef4444;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
:global(.dark) .clear-filter-pill {
|
||||
color: #f87171;
|
||||
background: rgba(239, 68, 68, 0.15) !important;
|
||||
border-color: rgba(239, 68, 68, 0.3) !important;
|
||||
}
|
||||
|
||||
:global(.dark) .clear-filter-pill .pill-label {
|
||||
color: #f87171;
|
||||
}
|
||||
|
||||
.clear-filter-pill:hover:not(.hidden) {
|
||||
background: rgba(239, 68, 68, 0.2) !important;
|
||||
border-color: rgba(239, 68, 68, 0.5) !important;
|
||||
}
|
||||
|
||||
.clear-filter-pill.hidden {
|
||||
visibility: hidden;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Filter dropdown */
|
||||
.filter-dropdown-container {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.filter-dropdown {
|
||||
position: absolute;
|
||||
bottom: calc(100% + 0.5rem);
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
min-width: 220px;
|
||||
padding: 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);
|
||||
border-radius: 0.75rem;
|
||||
box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
:global(.dark) .filter-dropdown {
|
||||
background: rgba(30, 30, 30, 0.95);
|
||||
border-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.filter-section {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.filter-section:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.filter-section-header {
|
||||
font-size: 0.6875rem;
|
||||
font-weight: 600;
|
||||
color: #6b7280;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
:global(.dark) .filter-section-header {
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.filter-select {
|
||||
width: 100%;
|
||||
padding: 0.5rem 0.75rem;
|
||||
font-size: 0.8125rem;
|
||||
color: #374151;
|
||||
background: rgba(0, 0, 0, 0.05);
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-radius: 0.5rem;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s;
|
||||
}
|
||||
|
||||
:global(.dark) .filter-select {
|
||||
color: #f3f4f6;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.filter-select:hover {
|
||||
border-color: rgba(139, 92, 246, 0.5);
|
||||
}
|
||||
|
||||
.filter-select:focus {
|
||||
outline: none;
|
||||
border-color: #8b5cf6;
|
||||
}
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 640px) {
|
||||
.filter-strip-wrapper {
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.filter-strip-container {
|
||||
padding: 0.5rem 1rem;
|
||||
}
|
||||
|
||||
.pill-label {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
728
apps/todo/apps/web/src/lib/components/TaskFilters.svelte
Normal file
728
apps/todo/apps/web/src/lib/components/TaskFilters.svelte
Normal file
|
|
@ -0,0 +1,728 @@
|
|||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import type { TaskPriority } from '@todo/shared';
|
||||
import { projectsStore } from '$lib/stores/projects.svelte';
|
||||
import { labelsStore } from '$lib/stores/labels.svelte';
|
||||
import type { SortBy, SortOrder } from '$lib/stores/view.svelte';
|
||||
import { X, DotsThree } from '@manacore/shared-icons';
|
||||
|
||||
interface Props {
|
||||
// Layout
|
||||
variant: 'strip' | 'bar';
|
||||
|
||||
// Filter state (owned by parent)
|
||||
selectedPriorities: TaskPriority[];
|
||||
selectedProjectId: string | null;
|
||||
selectedLabelIds: string[];
|
||||
searchQuery: string;
|
||||
|
||||
// Callbacks
|
||||
onPrioritiesChange: (priorities: TaskPriority[]) => void;
|
||||
onProjectChange: (projectId: string | null) => void;
|
||||
onLabelsChange: (labelIds: string[]) => void;
|
||||
onSearchChange: (query: string) => void;
|
||||
onClearFilters: () => void;
|
||||
|
||||
// Sort (strip variant)
|
||||
sortBy?: SortBy;
|
||||
sortOrder?: SortOrder;
|
||||
onSortChange?: (sortBy: SortBy) => void;
|
||||
|
||||
// Feature toggles
|
||||
showSort?: boolean;
|
||||
showSearch?: boolean;
|
||||
showLabels?: boolean;
|
||||
showCompleted?: boolean;
|
||||
showKanbanNav?: boolean;
|
||||
|
||||
// Completed toggle
|
||||
isCompletedVisible?: boolean;
|
||||
onToggleCompleted?: () => void;
|
||||
}
|
||||
|
||||
let {
|
||||
variant,
|
||||
selectedPriorities,
|
||||
selectedProjectId,
|
||||
selectedLabelIds,
|
||||
searchQuery,
|
||||
onPrioritiesChange,
|
||||
onProjectChange,
|
||||
onLabelsChange,
|
||||
onSearchChange,
|
||||
onClearFilters,
|
||||
sortBy,
|
||||
sortOrder,
|
||||
onSortChange,
|
||||
showSort = false,
|
||||
showSearch = false,
|
||||
showLabels = false,
|
||||
showCompleted = false,
|
||||
showKanbanNav = false,
|
||||
isCompletedVisible = false,
|
||||
onToggleCompleted,
|
||||
}: Props = $props();
|
||||
|
||||
const priorities: { value: TaskPriority; label: string; color: string; bgColor: string }[] = [
|
||||
{ value: 'urgent', label: 'Dringend', color: '#ef4444', bgColor: 'bg-red-500' },
|
||||
{ value: 'high', label: 'Hoch', color: '#f97316', bgColor: 'bg-orange-500' },
|
||||
{ value: 'medium', label: 'Normal', color: '#eab308', bgColor: 'bg-yellow-500' },
|
||||
{ value: 'low', label: 'Niedrig', color: '#3b82f6', bgColor: 'bg-blue-500' },
|
||||
];
|
||||
|
||||
const sortOptions: { id: SortBy; label: string }[] = [
|
||||
{ id: 'dueDate', label: 'Datum' },
|
||||
{ id: 'priority', label: 'Priorit.' },
|
||||
{ id: 'title', label: 'Name' },
|
||||
];
|
||||
|
||||
// Dropdown states
|
||||
let showFilterDropdown = $state(false);
|
||||
let showLabelsDropdown = $state(false);
|
||||
|
||||
let hasActiveFilters = $derived(
|
||||
selectedPriorities.length > 0 ||
|
||||
selectedProjectId !== null ||
|
||||
selectedLabelIds.length > 0 ||
|
||||
searchQuery.trim() !== ''
|
||||
);
|
||||
|
||||
function togglePriority(priority: TaskPriority) {
|
||||
if (selectedPriorities.includes(priority)) {
|
||||
onPrioritiesChange(selectedPriorities.filter((p) => p !== priority));
|
||||
} else {
|
||||
onPrioritiesChange([...selectedPriorities, priority]);
|
||||
}
|
||||
}
|
||||
|
||||
function toggleLabel(labelId: string) {
|
||||
if (selectedLabelIds.includes(labelId)) {
|
||||
onLabelsChange(selectedLabelIds.filter((id) => id !== labelId));
|
||||
} else {
|
||||
onLabelsChange([...selectedLabelIds, labelId]);
|
||||
}
|
||||
}
|
||||
|
||||
function closeFilterDropdown() {
|
||||
showFilterDropdown = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window onclick={closeFilterDropdown} />
|
||||
|
||||
{#if variant === 'strip'}
|
||||
<!-- ==================== STRIP VARIANT ==================== -->
|
||||
<div class="filter-strip-wrapper">
|
||||
<div class="filter-strip-container">
|
||||
<!-- Clear Filter Button -->
|
||||
<button
|
||||
class="clear-filter-pill glass-pill"
|
||||
class:hidden={!hasActiveFilters}
|
||||
onclick={onClearFilters}
|
||||
title="Filter löschen"
|
||||
disabled={!hasActiveFilters}
|
||||
>
|
||||
<X size={16} weight="bold" />
|
||||
<span class="pill-label">Filter</span>
|
||||
</button>
|
||||
|
||||
<!-- Kanban View Button -->
|
||||
{#if showKanbanNav}
|
||||
<button class="glass-pill" onclick={() => goto('/kanban')} title="Kanban-Ansicht">
|
||||
<svg class="pill-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M9 17V7m0 10a2 2 0 01-2 2H5a2 2 0 01-2-2V7a2 2 0 012-2h2a2 2 0 012 2m0 10a2 2 0 002 2h2a2 2 0 002-2M9 7a2 2 0 012-2h2a2 2 0 012 2m0 10V7m0 10a2 2 0 002 2h2a2 2 0 002-2V7a2 2 0 00-2-2h-2a2 2 0 00-2 2"
|
||||
/>
|
||||
</svg>
|
||||
<span class="pill-label">Kanban</span>
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
<!-- Priority Filter Pills -->
|
||||
{#each priorities as priority (priority.value)}
|
||||
<button
|
||||
class="priority-pill glass-pill"
|
||||
class:selected={selectedPriorities.includes(priority.value)}
|
||||
onclick={() => togglePriority(priority.value)}
|
||||
title={priority.label}
|
||||
style="--priority-color: {priority.color}"
|
||||
>
|
||||
<span class="priority-dot"></span>
|
||||
<span class="pill-label">{priority.label}</span>
|
||||
</button>
|
||||
{/each}
|
||||
|
||||
<!-- Sort Pills -->
|
||||
{#if showSort && onSortChange}
|
||||
{#each sortOptions as option (option.id)}
|
||||
<button
|
||||
class="sort-pill glass-pill"
|
||||
class:active={sortBy === option.id}
|
||||
onclick={() => onSortChange(option.id)}
|
||||
title="Nach {option.label} sortieren"
|
||||
>
|
||||
<span class="pill-label">{option.label}</span>
|
||||
</button>
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
<!-- Show Completed Toggle -->
|
||||
{#if showCompleted && onToggleCompleted}
|
||||
<button
|
||||
class="glass-pill"
|
||||
class:active={isCompletedVisible}
|
||||
onclick={onToggleCompleted}
|
||||
title={isCompletedVisible ? 'Erledigte ausblenden' : 'Erledigte anzeigen'}
|
||||
>
|
||||
<svg
|
||||
class="pill-icon"
|
||||
fill={isCompletedVisible ? 'currentColor' : 'none'}
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
|
||||
/>
|
||||
</svg>
|
||||
<span class="pill-label">Erledigt</span>
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
<!-- More Options (Project Filter + Labels) -->
|
||||
<div class="filter-dropdown-container" onclick={(e) => e.stopPropagation()}>
|
||||
<button
|
||||
class="more-pill glass-pill"
|
||||
onclick={() => (showFilterDropdown = !showFilterDropdown)}
|
||||
title="Weitere Filter"
|
||||
>
|
||||
<DotsThree size={18} weight="bold" />
|
||||
<span class="pill-label">Mehr</span>
|
||||
</button>
|
||||
|
||||
{#if showFilterDropdown}
|
||||
<div class="filter-dropdown" onclick={(e) => e.stopPropagation()}>
|
||||
<div class="filter-section">
|
||||
<div class="filter-section-header">Projekt</div>
|
||||
<select
|
||||
class="filter-select"
|
||||
value={selectedProjectId || ''}
|
||||
onchange={(e) => onProjectChange(e.currentTarget.value || null)}
|
||||
>
|
||||
<option value="">Alle Projekte</option>
|
||||
{#each projectsStore.activeProjects as project}
|
||||
<option value={project.id}>{project.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<!-- ==================== BAR VARIANT ==================== -->
|
||||
<div class="kanban-filters glass-pill-bar rounded-2xl p-4">
|
||||
<div class="flex flex-col gap-4">
|
||||
<!-- Row 1: Search and Clear -->
|
||||
{#if showSearch}
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="relative flex-1 max-w-xs">
|
||||
<svg
|
||||
class="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="currentColor"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
|
||||
/>
|
||||
</svg>
|
||||
<input
|
||||
type="text"
|
||||
value={searchQuery}
|
||||
oninput={(e) => onSearchChange(e.currentTarget.value)}
|
||||
placeholder="Aufgaben suchen..."
|
||||
class="w-full pl-10 pr-8 py-2 text-sm bg-background border border-border rounded-lg outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary placeholder:text-muted-foreground transition-all"
|
||||
/>
|
||||
{#if searchQuery}
|
||||
<button
|
||||
class="absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground rounded-full hover:bg-muted transition-colors"
|
||||
onclick={() => onSearchChange('')}
|
||||
>
|
||||
<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="M6 18L18 6M6 6l12 12"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if hasActiveFilters}
|
||||
<button
|
||||
class="ml-auto px-3 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-muted rounded-lg transition-colors flex items-center gap-2"
|
||||
onclick={onClearFilters}
|
||||
>
|
||||
<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="M6 18L18 6M6 6l12 12"
|
||||
/>
|
||||
</svg>
|
||||
Zurücksetzen
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Row 2: Filter Pills -->
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<!-- Priority filters -->
|
||||
<div class="filter-group flex items-center gap-2">
|
||||
<span class="text-xs font-medium text-muted-foreground uppercase tracking-wide"
|
||||
>Priorität</span
|
||||
>
|
||||
<div class="flex items-center gap-1">
|
||||
{#each priorities as priority}
|
||||
<button
|
||||
class="filter-pill px-3 py-1.5 text-xs font-medium rounded-full transition-all border {selectedPriorities.includes(
|
||||
priority.value
|
||||
)
|
||||
? `${priority.bgColor} text-white border-transparent shadow-sm`
|
||||
: 'bg-background border-border text-foreground hover:border-primary/50 hover:bg-muted/50'}"
|
||||
onclick={() => togglePriority(priority.value)}
|
||||
>
|
||||
{priority.label}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="h-6 w-px bg-border hidden sm:block"></div>
|
||||
|
||||
<!-- Project filter -->
|
||||
<div class="filter-group flex items-center gap-2">
|
||||
<span class="text-xs font-medium text-muted-foreground uppercase tracking-wide"
|
||||
>Projekt</span
|
||||
>
|
||||
<select
|
||||
class="px-3 py-1.5 text-sm bg-background border border-border rounded-lg outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary transition-all cursor-pointer"
|
||||
value={selectedProjectId || ''}
|
||||
onchange={(e) => onProjectChange(e.currentTarget.value || null)}
|
||||
>
|
||||
<option value="">Alle Projekte</option>
|
||||
{#each projectsStore.activeProjects as project}
|
||||
<option value={project.id}>{project.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Labels filter -->
|
||||
{#if showLabels}
|
||||
<div class="h-6 w-px bg-border hidden sm:block"></div>
|
||||
|
||||
<div class="filter-group flex items-center gap-2 relative">
|
||||
<span class="text-xs font-medium text-muted-foreground uppercase tracking-wide"
|
||||
>Tags</span
|
||||
>
|
||||
<button
|
||||
class="flex items-center gap-2 px-3 py-1.5 text-sm bg-background border border-border rounded-lg hover:border-primary/50 hover:bg-muted/50 transition-all"
|
||||
onclick={() => (showLabelsDropdown = !showLabelsDropdown)}
|
||||
>
|
||||
{#if selectedLabelIds.length > 0}
|
||||
<div class="flex items-center gap-1">
|
||||
{#each selectedLabelIds.slice(0, 3) as labelId}
|
||||
{@const label = labelsStore.labels.find((l) => l.id === labelId)}
|
||||
{#if label}
|
||||
<div
|
||||
class="w-3 h-3 rounded-full ring-2 ring-background"
|
||||
style="background-color: {label.color}"
|
||||
></div>
|
||||
{/if}
|
||||
{/each}
|
||||
{#if selectedLabelIds.length > 3}
|
||||
<span class="text-xs text-muted-foreground">+{selectedLabelIds.length - 3}</span
|
||||
>
|
||||
{/if}
|
||||
</div>
|
||||
{:else}
|
||||
<span class="text-muted-foreground">Auswählen</span>
|
||||
{/if}
|
||||
<svg
|
||||
class="w-4 h-4 text-muted-foreground transition-transform {showLabelsDropdown
|
||||
? 'rotate-180'
|
||||
: ''}"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="currentColor"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M19 9l-7 7-7-7"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
{#if showLabelsDropdown}
|
||||
<!-- svelte-ignore a11y_click_events_have_key_events a11y_no_static_element_interactions -->
|
||||
<div class="fixed inset-0 z-40" onclick={() => (showLabelsDropdown = false)}></div>
|
||||
<div
|
||||
class="absolute top-full left-0 mt-2 z-50 min-w-[220px] bg-popover border border-border rounded-xl shadow-lg p-2 animate-in fade-in slide-in-from-top-2 duration-150"
|
||||
>
|
||||
{#if labelsStore.labels.length === 0}
|
||||
<p class="text-sm text-muted-foreground p-3 text-center">Keine Tags vorhanden</p>
|
||||
{:else}
|
||||
<div class="max-h-[200px] overflow-y-auto">
|
||||
{#each labelsStore.labels as label}
|
||||
<button
|
||||
class="w-full flex items-center gap-3 px-3 py-2 text-sm rounded-lg hover:bg-muted/50 transition-colors"
|
||||
onclick={() => toggleLabel(label.id)}
|
||||
>
|
||||
<div
|
||||
class="w-4 h-4 rounded-full flex-shrink-0 ring-2 ring-offset-2 ring-offset-popover transition-all {selectedLabelIds.includes(
|
||||
label.id
|
||||
)
|
||||
? 'ring-primary'
|
||||
: 'ring-transparent'}"
|
||||
style="background-color: {label.color}"
|
||||
></div>
|
||||
<span class="flex-1 text-left truncate">{label.name}</span>
|
||||
{#if selectedLabelIds.includes(label.id)}
|
||||
<svg
|
||||
class="w-4 h-4 text-primary flex-shrink-0"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="currentColor"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M5 13l4 4L19 7"
|
||||
/>
|
||||
</svg>
|
||||
{/if}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
/* ==================== STRIP VARIANT STYLES ==================== */
|
||||
.filter-strip-wrapper {
|
||||
position: fixed;
|
||||
bottom: calc(70px + env(safe-area-inset-bottom, 0px));
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 49;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
pointer-events: none;
|
||||
transition: bottom 0.2s ease;
|
||||
}
|
||||
|
||||
.filter-strip-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
background: transparent;
|
||||
pointer-events: auto;
|
||||
width: fit-content;
|
||||
max-width: 100%;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
padding: 0.5rem 2rem;
|
||||
overflow-x: auto;
|
||||
scrollbar-width: none;
|
||||
-ms-overflow-style: none;
|
||||
}
|
||||
|
||||
.filter-strip-container::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Glass pill styling */
|
||||
.glass-pill {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 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);
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
|
||||
:global(.dark) .glass-pill {
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 1px solid rgba(255, 255, 255, 0.15);
|
||||
}
|
||||
|
||||
.glass-pill:hover {
|
||||
transform: scale(1.05);
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
border-color: rgba(0, 0, 0, 0.15);
|
||||
box-shadow:
|
||||
0 10px 15px -3px rgba(0, 0, 0, 0.1),
|
||||
0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
:global(.dark) .glass-pill:hover {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-color: rgba(255, 255, 255, 0.25);
|
||||
}
|
||||
|
||||
.glass-pill:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
.glass-pill.active {
|
||||
background: rgba(139, 92, 246, 0.15);
|
||||
border-color: rgba(139, 92, 246, 0.3);
|
||||
color: #8b5cf6;
|
||||
}
|
||||
|
||||
:global(.dark) .glass-pill.active {
|
||||
background: rgba(139, 92, 246, 0.25);
|
||||
border-color: rgba(139, 92, 246, 0.4);
|
||||
}
|
||||
|
||||
.pill-icon {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.pill-label {
|
||||
font-size: 0.9375rem;
|
||||
font-weight: 500;
|
||||
color: #374151;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
:global(.dark) .pill-label {
|
||||
color: #f3f4f6;
|
||||
}
|
||||
|
||||
.glass-pill.active .pill-label {
|
||||
color: #8b5cf6;
|
||||
}
|
||||
|
||||
/* Priority pills */
|
||||
.priority-pill.selected {
|
||||
background: var(--priority-color) !important;
|
||||
border-color: var(--priority-color) !important;
|
||||
}
|
||||
|
||||
.priority-pill.selected .priority-dot {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.priority-pill.selected .pill-label {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.priority-dot {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
background-color: var(--priority-color);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Clear filter pill */
|
||||
.clear-filter-pill {
|
||||
color: #ef4444;
|
||||
background: rgba(239, 68, 68, 0.1) !important;
|
||||
border-color: rgba(239, 68, 68, 0.3) !important;
|
||||
}
|
||||
|
||||
.clear-filter-pill .pill-label {
|
||||
color: #ef4444;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
:global(.dark) .clear-filter-pill {
|
||||
color: #f87171;
|
||||
background: rgba(239, 68, 68, 0.15) !important;
|
||||
border-color: rgba(239, 68, 68, 0.3) !important;
|
||||
}
|
||||
|
||||
:global(.dark) .clear-filter-pill .pill-label {
|
||||
color: #f87171;
|
||||
}
|
||||
|
||||
.clear-filter-pill:hover:not(.hidden) {
|
||||
background: rgba(239, 68, 68, 0.2) !important;
|
||||
border-color: rgba(239, 68, 68, 0.5) !important;
|
||||
}
|
||||
|
||||
.clear-filter-pill.hidden {
|
||||
visibility: hidden;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Filter dropdown */
|
||||
.filter-dropdown-container {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.filter-dropdown {
|
||||
position: absolute;
|
||||
bottom: calc(100% + 0.5rem);
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
min-width: 220px;
|
||||
padding: 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);
|
||||
border-radius: 0.75rem;
|
||||
box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
:global(.dark) .filter-dropdown {
|
||||
background: rgba(30, 30, 30, 0.95);
|
||||
border-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.filter-section {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.filter-section:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.filter-section-header {
|
||||
font-size: 0.6875rem;
|
||||
font-weight: 600;
|
||||
color: #6b7280;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
:global(.dark) .filter-section-header {
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.filter-select {
|
||||
width: 100%;
|
||||
padding: 0.5rem 0.75rem;
|
||||
font-size: 0.8125rem;
|
||||
color: #374151;
|
||||
background: rgba(0, 0, 0, 0.05);
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-radius: 0.5rem;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s;
|
||||
}
|
||||
|
||||
:global(.dark) .filter-select {
|
||||
color: #f3f4f6;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.filter-select:hover {
|
||||
border-color: rgba(139, 92, 246, 0.5);
|
||||
}
|
||||
|
||||
.filter-select:focus {
|
||||
outline: none;
|
||||
border-color: #8b5cf6;
|
||||
}
|
||||
|
||||
/* Responsive strip */
|
||||
@media (max-width: 640px) {
|
||||
.filter-strip-wrapper {
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.filter-strip-container {
|
||||
padding: 0.5rem 1rem;
|
||||
}
|
||||
|
||||
.pill-label {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
}
|
||||
|
||||
/* ==================== BAR VARIANT STYLES ==================== */
|
||||
.glass-pill-bar {
|
||||
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);
|
||||
}
|
||||
|
||||
:global(.dark) .glass-pill-bar {
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 1px solid rgba(255, 255, 255, 0.15);
|
||||
}
|
||||
|
||||
/* Animation utilities */
|
||||
.animate-in {
|
||||
animation: animateIn 0.15s ease-out;
|
||||
}
|
||||
|
||||
.fade-in {
|
||||
--tw-enter-opacity: 0;
|
||||
}
|
||||
|
||||
.slide-in-from-top-2 {
|
||||
--tw-enter-translate-y: -0.5rem;
|
||||
}
|
||||
|
||||
@keyframes animateIn {
|
||||
from {
|
||||
opacity: var(--tw-enter-opacity, 1);
|
||||
transform: translateY(var(--tw-enter-translate-y, 0));
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,319 +0,0 @@
|
|||
<script lang="ts">
|
||||
import type { TaskPriority } from '@todo/shared';
|
||||
import { projectsStore } from '$lib/stores/projects.svelte';
|
||||
import { labelsStore } from '$lib/stores/labels.svelte';
|
||||
|
||||
interface Props {
|
||||
selectedPriorities: TaskPriority[];
|
||||
selectedProjectId: string | null;
|
||||
selectedLabelIds: string[];
|
||||
searchQuery: string;
|
||||
onPrioritiesChange: (priorities: TaskPriority[]) => void;
|
||||
onProjectChange: (projectId: string | null) => void;
|
||||
onLabelsChange: (labelIds: string[]) => void;
|
||||
onSearchChange: (query: string) => void;
|
||||
onClearFilters: () => void;
|
||||
}
|
||||
|
||||
let {
|
||||
selectedPriorities,
|
||||
selectedProjectId,
|
||||
selectedLabelIds,
|
||||
searchQuery,
|
||||
onPrioritiesChange,
|
||||
onProjectChange,
|
||||
onLabelsChange,
|
||||
onSearchChange,
|
||||
onClearFilters,
|
||||
}: Props = $props();
|
||||
|
||||
const priorities: { value: TaskPriority; label: string; color: string; bgColor: string }[] = [
|
||||
{
|
||||
value: 'urgent',
|
||||
label: 'Dringend',
|
||||
color: 'text-red-600 dark:text-red-400',
|
||||
bgColor: 'bg-red-500',
|
||||
},
|
||||
{
|
||||
value: 'high',
|
||||
label: 'Wichtig',
|
||||
color: 'text-orange-600 dark:text-orange-400',
|
||||
bgColor: 'bg-orange-500',
|
||||
},
|
||||
{
|
||||
value: 'medium',
|
||||
label: 'Normal',
|
||||
color: 'text-yellow-600 dark:text-yellow-400',
|
||||
bgColor: 'bg-yellow-500',
|
||||
},
|
||||
{
|
||||
value: 'low',
|
||||
label: 'Später',
|
||||
color: 'text-blue-600 dark:text-blue-400',
|
||||
bgColor: 'bg-blue-500',
|
||||
},
|
||||
];
|
||||
|
||||
let showLabelsDropdown = $state(false);
|
||||
|
||||
function togglePriority(priority: TaskPriority) {
|
||||
if (selectedPriorities.includes(priority)) {
|
||||
onPrioritiesChange(selectedPriorities.filter((p) => p !== priority));
|
||||
} else {
|
||||
onPrioritiesChange([...selectedPriorities, priority]);
|
||||
}
|
||||
}
|
||||
|
||||
function toggleLabel(labelId: string) {
|
||||
if (selectedLabelIds.includes(labelId)) {
|
||||
onLabelsChange(selectedLabelIds.filter((id) => id !== labelId));
|
||||
} else {
|
||||
onLabelsChange([...selectedLabelIds, labelId]);
|
||||
}
|
||||
}
|
||||
|
||||
let hasActiveFilters = $derived(
|
||||
selectedPriorities.length > 0 ||
|
||||
selectedProjectId !== null ||
|
||||
selectedLabelIds.length > 0 ||
|
||||
searchQuery.trim() !== ''
|
||||
);
|
||||
</script>
|
||||
|
||||
<div class="kanban-filters glass-pill rounded-full p-4">
|
||||
<div class="flex flex-col gap-4">
|
||||
<!-- Row 1: Search and Clear -->
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="relative flex-1 max-w-xs">
|
||||
<svg
|
||||
class="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="currentColor"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
|
||||
/>
|
||||
</svg>
|
||||
<input
|
||||
type="text"
|
||||
value={searchQuery}
|
||||
oninput={(e) => onSearchChange(e.currentTarget.value)}
|
||||
placeholder="Aufgaben suchen..."
|
||||
class="w-full pl-10 pr-8 py-2 text-sm bg-background border border-border rounded-lg outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary placeholder:text-muted-foreground transition-all"
|
||||
/>
|
||||
{#if searchQuery}
|
||||
<button
|
||||
class="absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground rounded-full hover:bg-muted transition-colors"
|
||||
onclick={() => onSearchChange('')}
|
||||
>
|
||||
<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="M6 18L18 6M6 6l12 12"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if hasActiveFilters}
|
||||
<button
|
||||
class="ml-auto px-3 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-muted rounded-lg transition-colors flex items-center gap-2"
|
||||
onclick={onClearFilters}
|
||||
>
|
||||
<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="M6 18L18 6M6 6l12 12"
|
||||
/>
|
||||
</svg>
|
||||
Zurücksetzen
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- Row 2: Filter Pills -->
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<!-- Priority filters -->
|
||||
<div class="filter-group flex items-center gap-2">
|
||||
<span class="text-xs font-medium text-muted-foreground uppercase tracking-wide"
|
||||
>Priorität</span
|
||||
>
|
||||
<div class="flex items-center gap-1">
|
||||
{#each priorities as priority}
|
||||
<button
|
||||
class="filter-pill px-3 py-1.5 text-xs font-medium rounded-full transition-all border {selectedPriorities.includes(
|
||||
priority.value
|
||||
)
|
||||
? `${priority.bgColor} text-white border-transparent shadow-sm`
|
||||
: 'bg-background border-border text-foreground hover:border-primary/50 hover:bg-muted/50'}"
|
||||
onclick={() => togglePriority(priority.value)}
|
||||
>
|
||||
{priority.label}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="h-6 w-px bg-border hidden sm:block"></div>
|
||||
|
||||
<!-- Project filter -->
|
||||
<div class="filter-group flex items-center gap-2">
|
||||
<span class="text-xs font-medium text-muted-foreground uppercase tracking-wide"
|
||||
>Projekt</span
|
||||
>
|
||||
<select
|
||||
class="px-3 py-1.5 text-sm bg-background border border-border rounded-lg outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary transition-all cursor-pointer"
|
||||
value={selectedProjectId || ''}
|
||||
onchange={(e) => onProjectChange(e.currentTarget.value || null)}
|
||||
>
|
||||
<option value="">Alle Projekte</option>
|
||||
{#each projectsStore.activeProjects as project}
|
||||
<option value={project.id}>{project.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="h-6 w-px bg-border hidden sm:block"></div>
|
||||
|
||||
<!-- Tags filter -->
|
||||
<div class="filter-group flex items-center gap-2 relative">
|
||||
<span class="text-xs font-medium text-muted-foreground uppercase tracking-wide">Tags</span>
|
||||
<button
|
||||
class="flex items-center gap-2 px-3 py-1.5 text-sm bg-background border border-border rounded-lg hover:border-primary/50 hover:bg-muted/50 transition-all"
|
||||
onclick={() => (showLabelsDropdown = !showLabelsDropdown)}
|
||||
>
|
||||
{#if selectedLabelIds.length > 0}
|
||||
<div class="flex items-center gap-1">
|
||||
{#each selectedLabelIds.slice(0, 3) as labelId}
|
||||
{@const label = labelsStore.labels.find((l) => l.id === labelId)}
|
||||
{#if label}
|
||||
<div
|
||||
class="w-3 h-3 rounded-full ring-2 ring-background"
|
||||
style="background-color: {label.color}"
|
||||
></div>
|
||||
{/if}
|
||||
{/each}
|
||||
{#if selectedLabelIds.length > 3}
|
||||
<span class="text-xs text-muted-foreground">+{selectedLabelIds.length - 3}</span>
|
||||
{/if}
|
||||
</div>
|
||||
{:else}
|
||||
<span class="text-muted-foreground">Auswählen</span>
|
||||
{/if}
|
||||
<svg
|
||||
class="w-4 h-4 text-muted-foreground transition-transform {showLabelsDropdown
|
||||
? 'rotate-180'
|
||||
: ''}"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="currentColor"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M19 9l-7 7-7-7"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
{#if showLabelsDropdown}
|
||||
<!-- svelte-ignore a11y_click_events_have_key_events a11y_no_static_element_interactions -->
|
||||
<div class="fixed inset-0 z-40" onclick={() => (showLabelsDropdown = false)}></div>
|
||||
<div
|
||||
class="absolute top-full left-0 mt-2 z-50 min-w-[220px] bg-popover border border-border rounded-xl shadow-lg p-2 animate-in fade-in slide-in-from-top-2 duration-150"
|
||||
>
|
||||
{#if labelsStore.labels.length === 0}
|
||||
<p class="text-sm text-muted-foreground p-3 text-center">Keine Tags vorhanden</p>
|
||||
{:else}
|
||||
<div class="max-h-[200px] overflow-y-auto">
|
||||
{#each labelsStore.labels as label}
|
||||
<button
|
||||
class="w-full flex items-center gap-3 px-3 py-2 text-sm rounded-lg hover:bg-muted/50 transition-colors"
|
||||
onclick={() => toggleLabel(label.id)}
|
||||
>
|
||||
<div
|
||||
class="w-4 h-4 rounded-full flex-shrink-0 ring-2 ring-offset-2 ring-offset-popover transition-all {selectedLabelIds.includes(
|
||||
label.id
|
||||
)
|
||||
? 'ring-primary'
|
||||
: 'ring-transparent'}"
|
||||
style="background-color: {label.color}"
|
||||
></div>
|
||||
<span class="flex-1 text-left truncate">{label.name}</span>
|
||||
{#if selectedLabelIds.includes(label.id)}
|
||||
<svg
|
||||
class="w-4 h-4 text-primary flex-shrink-0"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="currentColor"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M5 13l4 4L19 7"
|
||||
/>
|
||||
</svg>
|
||||
{/if}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
/* Glass pill effect matching PillNavigation */
|
||||
.glass-pill {
|
||||
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);
|
||||
}
|
||||
|
||||
:global(.dark) .glass-pill {
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 1px solid rgba(255, 255, 255, 0.15);
|
||||
}
|
||||
|
||||
/* Animation utilities */
|
||||
.animate-in {
|
||||
animation: animateIn 0.15s ease-out;
|
||||
}
|
||||
|
||||
.fade-in {
|
||||
--tw-enter-opacity: 0;
|
||||
}
|
||||
|
||||
.slide-in-from-top-2 {
|
||||
--tw-enter-translate-y: -0.5rem;
|
||||
}
|
||||
|
||||
@keyframes animateIn {
|
||||
from {
|
||||
opacity: var(--tw-enter-opacity, 1);
|
||||
transform: translateY(var(--tw-enter-translate-y, 0));
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -3,5 +3,4 @@ export { default as KanbanColumn } from './KanbanColumn.svelte';
|
|||
export { default as KanbanColumnHeader } from './KanbanColumnHeader.svelte';
|
||||
export { default as KanbanTaskCard } from './KanbanTaskCard.svelte';
|
||||
export { default as AddColumnButton } from './AddColumnButton.svelte';
|
||||
export { default as KanbanFilters } from './KanbanFilters.svelte';
|
||||
export { default as BoardNavigation } from './BoardNavigation.svelte';
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
* View Store - Manages current view state using Svelte 5 runes
|
||||
*/
|
||||
|
||||
import type { TaskPriority } from '@todo/shared';
|
||||
|
||||
export type ViewType =
|
||||
| 'inbox'
|
||||
| 'today'
|
||||
|
|
@ -22,6 +24,12 @@ let sortBy = $state<SortBy>('order');
|
|||
let sortOrder = $state<SortOrder>('asc');
|
||||
let showCompleted = $state(false);
|
||||
|
||||
// Filter state (used by TaskFilters strip in list view)
|
||||
let filterPriorities = $state<TaskPriority[]>([]);
|
||||
let filterProjectId = $state<string | null>(null);
|
||||
let filterLabelIds = $state<string[]>([]);
|
||||
let filterSearchQuery = $state('');
|
||||
|
||||
export const viewStore = {
|
||||
// Getters
|
||||
get currentView() {
|
||||
|
|
@ -45,6 +53,18 @@ export const viewStore = {
|
|||
get showCompleted() {
|
||||
return showCompleted;
|
||||
},
|
||||
get filterPriorities() {
|
||||
return filterPriorities;
|
||||
},
|
||||
get filterProjectId() {
|
||||
return filterProjectId;
|
||||
},
|
||||
get filterLabelIds() {
|
||||
return filterLabelIds;
|
||||
},
|
||||
get filterSearchQuery() {
|
||||
return filterSearchQuery;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set current view to inbox
|
||||
|
|
@ -145,6 +165,44 @@ export const viewStore = {
|
|||
showCompleted = !showCompleted;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set filter priorities
|
||||
*/
|
||||
setFilterPriorities(priorities: TaskPriority[]) {
|
||||
filterPriorities = priorities;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set filter project
|
||||
*/
|
||||
setFilterProjectId(id: string | null) {
|
||||
filterProjectId = id;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set filter label IDs
|
||||
*/
|
||||
setFilterLabelIds(ids: string[]) {
|
||||
filterLabelIds = ids;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set filter search query
|
||||
*/
|
||||
setFilterSearchQuery(query: string) {
|
||||
filterSearchQuery = query;
|
||||
},
|
||||
|
||||
/**
|
||||
* Clear all filters
|
||||
*/
|
||||
clearFilters() {
|
||||
filterPriorities = [];
|
||||
filterProjectId = null;
|
||||
filterLabelIds = [];
|
||||
filterSearchQuery = '';
|
||||
},
|
||||
|
||||
/**
|
||||
* Reset to default state
|
||||
*/
|
||||
|
|
@ -156,5 +214,9 @@ export const viewStore = {
|
|||
sortBy = 'order';
|
||||
sortOrder = 'asc';
|
||||
showCompleted = false;
|
||||
filterPriorities = [];
|
||||
filterProjectId = null;
|
||||
filterLabelIds = [];
|
||||
filterSearchQuery = '';
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,6 +12,29 @@
|
|||
|
||||
let isLoading = $state(true);
|
||||
|
||||
// Apply viewStore filters to task lists
|
||||
function applyFilters(tasks: Task[]): Task[] {
|
||||
let filtered = tasks;
|
||||
if (viewStore.filterPriorities.length > 0) {
|
||||
filtered = filtered.filter((t) => viewStore.filterPriorities.includes(t.priority));
|
||||
}
|
||||
if (viewStore.filterProjectId) {
|
||||
filtered = filtered.filter((t) => t.projectId === viewStore.filterProjectId);
|
||||
}
|
||||
if (viewStore.filterLabelIds.length > 0) {
|
||||
filtered = filtered.filter((t) =>
|
||||
t.labels?.some((l) => viewStore.filterLabelIds.includes(l.id))
|
||||
);
|
||||
}
|
||||
if (viewStore.filterSearchQuery.trim()) {
|
||||
const q = viewStore.filterSearchQuery.toLowerCase();
|
||||
filtered = filtered.filter(
|
||||
(t) => t.title.toLowerCase().includes(q) || t.description?.toLowerCase().includes(q)
|
||||
);
|
||||
}
|
||||
return filtered;
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
viewStore.setToday();
|
||||
|
||||
|
|
@ -25,20 +48,22 @@
|
|||
isLoading = false;
|
||||
});
|
||||
|
||||
// Derived task lists
|
||||
let overdueTasks = $derived(tasksStore.overdueTasks);
|
||||
let todayTasks = $derived(tasksStore.todayTasks);
|
||||
let completedTasks = $derived(tasksStore.completedTasks);
|
||||
// Derived task lists (with filters applied)
|
||||
let overdueTasks = $derived(applyFilters(tasksStore.overdueTasks));
|
||||
let todayTasks = $derived(applyFilters(tasksStore.todayTasks));
|
||||
let completedTasks = $derived(applyFilters(tasksStore.completedTasks));
|
||||
|
||||
// Tomorrow's tasks
|
||||
let tomorrowDate = $derived(addDays(startOfDay(new Date()), 1));
|
||||
let dayAfterTomorrowDate = $derived(addDays(startOfDay(new Date()), 2));
|
||||
let tomorrowTasks = $derived(
|
||||
tasksStore.tasks.filter((task) => {
|
||||
if (!task.dueDate || task.isCompleted) return false;
|
||||
const taskDate = startOfDay(new Date(task.dueDate));
|
||||
return taskDate.getTime() === tomorrowDate.getTime();
|
||||
})
|
||||
applyFilters(
|
||||
tasksStore.tasks.filter((task) => {
|
||||
if (!task.dueDate || task.isCompleted) return false;
|
||||
const taskDate = startOfDay(new Date(task.dueDate));
|
||||
return taskDate.getTime() === tomorrowDate.getTime();
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
// Group upcoming tasks by day (starting from day after tomorrow)
|
||||
|
|
@ -49,11 +74,13 @@
|
|||
// Start from day after tomorrow (day 2) through day 7
|
||||
for (let i = 2; i <= 7; i++) {
|
||||
const date = addDays(today, i);
|
||||
const dayTasks = tasksStore.tasks.filter((task) => {
|
||||
if (!task.dueDate || task.isCompleted) return false;
|
||||
const taskDate = startOfDay(new Date(task.dueDate));
|
||||
return taskDate.getTime() === date.getTime();
|
||||
});
|
||||
const dayTasks = applyFilters(
|
||||
tasksStore.tasks.filter((task) => {
|
||||
if (!task.dueDate || task.isCompleted) return false;
|
||||
const taskDate = startOfDay(new Date(task.dueDate));
|
||||
return taskDate.getTime() === date.getTime();
|
||||
})
|
||||
);
|
||||
|
||||
if (dayTasks.length > 0) {
|
||||
const label = format(date, 'EEEE, d. MMMM', { locale: de });
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
import { onMount, onDestroy } from 'svelte';
|
||||
import type { TaskPriority } from '@todo/shared';
|
||||
import { kanbanStore } from '$lib/stores/kanban.svelte';
|
||||
import { KanbanBoard, KanbanFilters, BoardNavigation } from '$lib/components/kanban';
|
||||
import { KanbanBoard, BoardNavigation } from '$lib/components/kanban';
|
||||
import TaskFilters from '$lib/components/TaskFilters.svelte';
|
||||
|
||||
// Filter state
|
||||
let filterPriorities = $state<TaskPriority[]>([]);
|
||||
|
|
@ -218,16 +219,19 @@
|
|||
<!-- Collapsible Filters -->
|
||||
{#if showFilters}
|
||||
<div class="mb-6 px-4 sm:px-6 lg:px-8 animate-in slide-in-from-top-2 duration-200">
|
||||
<KanbanFilters
|
||||
<TaskFilters
|
||||
variant="bar"
|
||||
selectedPriorities={filterPriorities}
|
||||
selectedProjectId={filterProjectId}
|
||||
selectedLabelIds={filterLabelIds}
|
||||
searchQuery={filterSearchQuery}
|
||||
onPrioritiesChange={(priorities) => (filterPriorities = priorities)}
|
||||
onProjectChange={(projectId) => (filterProjectId = projectId)}
|
||||
onLabelsChange={(labelIds) => (filterLabelIds = labelIds)}
|
||||
onSearchChange={(query) => (filterSearchQuery = query)}
|
||||
onPrioritiesChange={(priorities: TaskPriority[]) => (filterPriorities = priorities)}
|
||||
onProjectChange={(projectId: string | null) => (filterProjectId = projectId)}
|
||||
onLabelsChange={(labelIds: string[]) => (filterLabelIds = labelIds)}
|
||||
onSearchChange={(query: string) => (filterSearchQuery = query)}
|
||||
onClearFilters={clearFilters}
|
||||
showSearch={true}
|
||||
showLabels={true}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue