feat(todo): add comprehensive settings page with 20+ preferences

- Add global settings: confirmOnDelete, keyboardShortcutsEnabled
- Create Todo-specific settings store with localStorage persistence
- Add new shared-ui components: SettingsSelect, SettingsNumberInput, SettingsTimeInput
- Redesign settings page with 6 new sections:
  - Task behavior (priority, due time, auto-archive, quick-add project)
  - View & display (default view, compact mode, task counts, subtask progress)
  - Kanban board (card size, labels, WIP limit)
  - Notifications (reminders, daily digest, overdue alerts)
  - Productivity (focus mode, pomodoro, daily goal, streak)
  - Keyboard shortcuts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Till-JS 2025-12-09 13:30:02 +01:00
parent 00dadc97d1
commit 863dd621f5
8 changed files with 1570 additions and 2 deletions

View file

@ -55,6 +55,9 @@ export {
SettingsCard,
SettingsRow,
SettingsToggle,
SettingsSelect,
SettingsNumberInput,
SettingsTimeInput,
SettingsDangerZone,
SettingsDangerButton,
GlobalSettingsSection,

View file

@ -0,0 +1,241 @@
<script lang="ts">
import type { Snippet } from 'svelte';
interface Props {
/** Row label */
label: string;
/** Optional description */
description?: string;
/** Optional icon (Snippet for flexibility) */
icon?: Snippet;
/** Current value (null = empty/disabled) */
value: number | null;
/** Change handler */
onchange: (value: number | null) => void;
/** Minimum value */
min?: number;
/** Maximum value */
max?: number;
/** Step increment */
step?: number;
/** Placeholder text when empty */
placeholder?: string;
/** Show border at bottom */
border?: boolean;
/** Disabled state */
disabled?: boolean;
/** Additional CSS classes */
class?: string;
}
let {
label,
description,
icon,
value,
onchange,
min,
max,
step = 1,
placeholder = '',
border = true,
disabled = false,
class: className = '',
}: Props = $props();
function handleInput(event: Event) {
const target = event.target as HTMLInputElement;
const rawValue = target.value.trim();
if (rawValue === '') {
onchange(null);
return;
}
const numValue = Number(rawValue);
if (!isNaN(numValue)) {
// Clamp to min/max if specified
let clampedValue = numValue;
if (min !== undefined && clampedValue < min) clampedValue = min;
if (max !== undefined && clampedValue > max) clampedValue = max;
onchange(clampedValue);
}
}
</script>
<div
class="settings-number {border ? 'settings-number--border' : ''} {disabled
? 'settings-number--disabled'
: ''} {className}"
>
<div class="settings-number__content">
{#if icon}
<span class="settings-number__icon">
{@render icon()}
</span>
{/if}
<div class="settings-number__text">
<span class="settings-number__label">{label}</span>
{#if description}
<span class="settings-number__description">{description}</span>
{/if}
</div>
</div>
<input
type="number"
class="settings-number__input"
value={value ?? ''}
oninput={handleInput}
{min}
{max}
{step}
{placeholder}
{disabled}
aria-label={label}
/>
</div>
<style>
.settings-number {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
padding: 1rem 1.25rem;
}
.settings-number--border {
border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
:global(.dark) .settings-number--border {
border-bottom-color: rgba(255, 255, 255, 0.1);
}
.settings-number--border:last-child {
border-bottom: none;
}
.settings-number--disabled {
opacity: 0.5;
cursor: not-allowed;
}
.settings-number__content {
display: flex;
align-items: center;
gap: 0.75rem;
flex: 1;
min-width: 0;
}
.settings-number__icon {
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
width: 2.25rem;
height: 2.25rem;
border-radius: 0.625rem;
background: rgba(0, 0, 0, 0.04);
color: hsl(var(--primary));
}
:global(.dark) .settings-number__icon {
background: rgba(255, 255, 255, 0.08);
}
.settings-number__icon :global(svg) {
width: 1.125rem;
height: 1.125rem;
}
.settings-number__text {
display: flex;
flex-direction: column;
gap: 0.125rem;
min-width: 0;
}
.settings-number__label {
font-size: 0.9375rem;
font-weight: 500;
color: #374151;
}
:global(.dark) .settings-number__label {
color: #f3f4f6;
}
.settings-number__description {
font-size: 0.8125rem;
color: #6b7280;
line-height: 1.4;
}
:global(.dark) .settings-number__description {
color: #9ca3af;
}
/* Number Input - Glass style */
.settings-number__input {
width: 5rem;
padding: 0.5rem 0.75rem;
font-size: 0.875rem;
font-weight: 500;
color: #374151;
text-align: center;
background-color: rgba(0, 0, 0, 0.04);
border: 1px solid rgba(0, 0, 0, 0.1);
border-radius: 0.5rem;
transition: all 0.2s ease;
}
:global(.dark) .settings-number__input {
color: #f3f4f6;
background-color: rgba(255, 255, 255, 0.08);
border-color: rgba(255, 255, 255, 0.15);
}
.settings-number__input:hover:not(:disabled) {
border-color: rgba(0, 0, 0, 0.2);
background-color: rgba(0, 0, 0, 0.06);
}
:global(.dark) .settings-number__input:hover:not(:disabled) {
border-color: rgba(255, 255, 255, 0.25);
background-color: rgba(255, 255, 255, 0.12);
}
.settings-number__input:focus-visible {
outline: 2px solid hsl(var(--primary) / 0.4);
outline-offset: 2px;
border-color: hsl(var(--primary));
}
.settings-number__input:disabled {
cursor: not-allowed;
opacity: 0.6;
}
.settings-number__input::placeholder {
color: #9ca3af;
font-weight: 400;
}
:global(.dark) .settings-number__input::placeholder {
color: #6b7280;
}
/* Hide spinner buttons */
.settings-number__input::-webkit-outer-spin-button,
.settings-number__input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
.settings-number__input[type='number'] {
-moz-appearance: textfield;
}
</style>

View file

@ -0,0 +1,232 @@
<script lang="ts">
import type { Snippet } from 'svelte';
interface SelectOption {
value: string | number | null;
label: string;
}
interface Props {
/** Row label */
label: string;
/** Optional description */
description?: string;
/** Optional icon (Snippet for flexibility) */
icon?: Snippet;
/** Available options */
options: SelectOption[];
/** Current selected value */
value: string | number | null;
/** Change handler */
onchange: (value: string | number | null) => void;
/** Show border at bottom */
border?: boolean;
/** Disabled state */
disabled?: boolean;
/** Additional CSS classes */
class?: string;
}
let {
label,
description,
icon,
options,
value,
onchange,
border = true,
disabled = false,
class: className = '',
}: Props = $props();
function handleChange(event: Event) {
const target = event.target as HTMLSelectElement;
const rawValue = target.value;
// Handle null values (stored as empty string in select)
if (rawValue === '') {
onchange(null);
return;
}
// Try to parse as number if the original options had numbers
const numValue = Number(rawValue);
if (!isNaN(numValue) && options.some((o) => o.value === numValue)) {
onchange(numValue);
} else {
onchange(rawValue);
}
}
</script>
<div
class="settings-select {border ? 'settings-select--border' : ''} {disabled
? 'settings-select--disabled'
: ''} {className}"
>
<div class="settings-select__content">
{#if icon}
<span class="settings-select__icon">
{@render icon()}
</span>
{/if}
<div class="settings-select__text">
<span class="settings-select__label">{label}</span>
{#if description}
<span class="settings-select__description">{description}</span>
{/if}
</div>
</div>
<select
class="settings-select__dropdown"
value={value ?? ''}
onchange={handleChange}
{disabled}
aria-label={label}
>
{#each options as option}
<option value={option.value ?? ''}>{option.label}</option>
{/each}
</select>
</div>
<style>
.settings-select {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
padding: 1rem 1.25rem;
}
.settings-select--border {
border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
:global(.dark) .settings-select--border {
border-bottom-color: rgba(255, 255, 255, 0.1);
}
.settings-select--border:last-child {
border-bottom: none;
}
.settings-select--disabled {
opacity: 0.5;
cursor: not-allowed;
}
.settings-select__content {
display: flex;
align-items: center;
gap: 0.75rem;
flex: 1;
min-width: 0;
}
.settings-select__icon {
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
width: 2.25rem;
height: 2.25rem;
border-radius: 0.625rem;
background: rgba(0, 0, 0, 0.04);
color: hsl(var(--primary));
}
:global(.dark) .settings-select__icon {
background: rgba(255, 255, 255, 0.08);
}
.settings-select__icon :global(svg) {
width: 1.125rem;
height: 1.125rem;
}
.settings-select__text {
display: flex;
flex-direction: column;
gap: 0.125rem;
min-width: 0;
}
.settings-select__label {
font-size: 0.9375rem;
font-weight: 500;
color: #374151;
}
:global(.dark) .settings-select__label {
color: #f3f4f6;
}
.settings-select__description {
font-size: 0.8125rem;
color: #6b7280;
line-height: 1.4;
}
:global(.dark) .settings-select__description {
color: #9ca3af;
}
/* Select Dropdown - Glass style */
.settings-select__dropdown {
min-width: 8rem;
padding: 0.5rem 2rem 0.5rem 0.75rem;
font-size: 0.875rem;
font-weight: 500;
color: #374151;
background-color: rgba(0, 0, 0, 0.04);
border: 1px solid rgba(0, 0, 0, 0.1);
border-radius: 0.5rem;
cursor: pointer;
appearance: none;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 0.5rem center;
background-size: 1rem;
transition: all 0.2s ease;
}
:global(.dark) .settings-select__dropdown {
color: #f3f4f6;
background-color: rgba(255, 255, 255, 0.08);
border-color: rgba(255, 255, 255, 0.15);
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
.settings-select__dropdown:hover:not(:disabled) {
border-color: rgba(0, 0, 0, 0.2);
background-color: rgba(0, 0, 0, 0.06);
}
:global(.dark) .settings-select__dropdown:hover:not(:disabled) {
border-color: rgba(255, 255, 255, 0.25);
background-color: rgba(255, 255, 255, 0.12);
}
.settings-select__dropdown:focus-visible {
outline: 2px solid hsl(var(--primary) / 0.4);
outline-offset: 2px;
border-color: hsl(var(--primary));
}
.settings-select__dropdown:disabled {
cursor: not-allowed;
opacity: 0.6;
}
.settings-select__dropdown option {
background-color: white;
color: #374151;
}
:global(.dark) .settings-select__dropdown option {
background-color: #1f2937;
color: #f3f4f6;
}
</style>

View file

@ -0,0 +1,287 @@
<script lang="ts">
import type { Snippet } from 'svelte';
interface Props {
/** Row label */
label: string;
/** Optional description */
description?: string;
/** Optional icon (Snippet for flexibility) */
icon?: Snippet;
/** Current value (HH:mm format, null = not set) */
value: string | null;
/** Change handler */
onchange: (value: string | null) => void;
/** Placeholder text when empty */
placeholder?: string;
/** Show border at bottom */
border?: boolean;
/** Disabled state */
disabled?: boolean;
/** Additional CSS classes */
class?: string;
}
let {
label,
description,
icon,
value,
onchange,
placeholder = '--:--',
border = true,
disabled = false,
class: className = '',
}: Props = $props();
function handleInput(event: Event) {
const target = event.target as HTMLInputElement;
const rawValue = target.value.trim();
if (rawValue === '') {
onchange(null);
return;
}
// Validate HH:mm format
if (/^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$/.test(rawValue)) {
onchange(rawValue);
}
}
function handleClear() {
onchange(null);
}
</script>
<div
class="settings-time {border ? 'settings-time--border' : ''} {disabled
? 'settings-time--disabled'
: ''} {className}"
>
<div class="settings-time__content">
{#if icon}
<span class="settings-time__icon">
{@render icon()}
</span>
{/if}
<div class="settings-time__text">
<span class="settings-time__label">{label}</span>
{#if description}
<span class="settings-time__description">{description}</span>
{/if}
</div>
</div>
<div class="settings-time__input-wrapper">
<input
type="time"
class="settings-time__input"
value={value ?? ''}
oninput={handleInput}
{placeholder}
{disabled}
aria-label={label}
/>
{#if value}
<button
type="button"
class="settings-time__clear"
onclick={handleClear}
aria-label="Clear time"
{disabled}
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="14"
height="14"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M18 6 6 18" />
<path d="m6 6 12 12" />
</svg>
</button>
{/if}
</div>
</div>
<style>
.settings-time {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
padding: 1rem 1.25rem;
}
.settings-time--border {
border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
:global(.dark) .settings-time--border {
border-bottom-color: rgba(255, 255, 255, 0.1);
}
.settings-time--border:last-child {
border-bottom: none;
}
.settings-time--disabled {
opacity: 0.5;
cursor: not-allowed;
}
.settings-time__content {
display: flex;
align-items: center;
gap: 0.75rem;
flex: 1;
min-width: 0;
}
.settings-time__icon {
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
width: 2.25rem;
height: 2.25rem;
border-radius: 0.625rem;
background: rgba(0, 0, 0, 0.04);
color: hsl(var(--primary));
}
:global(.dark) .settings-time__icon {
background: rgba(255, 255, 255, 0.08);
}
.settings-time__icon :global(svg) {
width: 1.125rem;
height: 1.125rem;
}
.settings-time__text {
display: flex;
flex-direction: column;
gap: 0.125rem;
min-width: 0;
}
.settings-time__label {
font-size: 0.9375rem;
font-weight: 500;
color: #374151;
}
:global(.dark) .settings-time__label {
color: #f3f4f6;
}
.settings-time__description {
font-size: 0.8125rem;
color: #6b7280;
line-height: 1.4;
}
:global(.dark) .settings-time__description {
color: #9ca3af;
}
/* Input wrapper */
.settings-time__input-wrapper {
display: flex;
align-items: center;
gap: 0.25rem;
}
/* Time Input - Glass style */
.settings-time__input {
width: 6rem;
padding: 0.5rem 0.75rem;
font-size: 0.875rem;
font-weight: 500;
color: #374151;
text-align: center;
background-color: rgba(0, 0, 0, 0.04);
border: 1px solid rgba(0, 0, 0, 0.1);
border-radius: 0.5rem;
transition: all 0.2s ease;
}
:global(.dark) .settings-time__input {
color: #f3f4f6;
background-color: rgba(255, 255, 255, 0.08);
border-color: rgba(255, 255, 255, 0.15);
}
.settings-time__input:hover:not(:disabled) {
border-color: rgba(0, 0, 0, 0.2);
background-color: rgba(0, 0, 0, 0.06);
}
:global(.dark) .settings-time__input:hover:not(:disabled) {
border-color: rgba(255, 255, 255, 0.25);
background-color: rgba(255, 255, 255, 0.12);
}
.settings-time__input:focus-visible {
outline: 2px solid hsl(var(--primary) / 0.4);
outline-offset: 2px;
border-color: hsl(var(--primary));
}
.settings-time__input:disabled {
cursor: not-allowed;
opacity: 0.6;
}
/* Clear button */
.settings-time__clear {
display: flex;
align-items: center;
justify-content: center;
width: 1.75rem;
height: 1.75rem;
padding: 0;
color: #6b7280;
background: transparent;
border: none;
border-radius: 0.375rem;
cursor: pointer;
transition: all 0.2s ease;
}
.settings-time__clear:hover:not(:disabled) {
color: #ef4444;
background-color: rgba(239, 68, 68, 0.1);
}
:global(.dark) .settings-time__clear {
color: #9ca3af;
}
:global(.dark) .settings-time__clear:hover:not(:disabled) {
color: #ef4444;
background-color: rgba(239, 68, 68, 0.2);
}
.settings-time__clear:disabled {
cursor: not-allowed;
opacity: 0.5;
}
/* Style the time input appearance */
.settings-time__input::-webkit-calendar-picker-indicator {
filter: invert(0.5);
cursor: pointer;
}
:global(.dark) .settings-time__input::-webkit-calendar-picker-indicator {
filter: invert(0.7);
}
</style>

View file

@ -4,6 +4,9 @@ export { default as SettingsSection } from './SettingsSection.svelte';
export { default as SettingsCard } from './SettingsCard.svelte';
export { default as SettingsRow } from './SettingsRow.svelte';
export { default as SettingsToggle } from './SettingsToggle.svelte';
export { default as SettingsSelect } from './SettingsSelect.svelte';
export { default as SettingsNumberInput } from './SettingsNumberInput.svelte';
export { default as SettingsTimeInput } from './SettingsTimeInput.svelte';
export { default as SettingsDangerZone } from './SettingsDangerZone.svelte';
export { default as SettingsDangerButton } from './SettingsDangerButton.svelte';
export { default as GlobalSettingsSection } from './GlobalSettingsSection.svelte';