diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 0c5e7f7..fcf84bd 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -22,6 +22,7 @@ import CompletedFilterPill from './components/CompletedFilterPill.vue' import CalendarPicker from './components/CalendarPicker.vue' import TaskDueDisplay from './components/TaskDueDisplay.vue' import { useTaskDueClock } from './lib/task-due-clock' +import { readTodaySectionCollapse, writeTodaySectionCollapse, type TodaySectionCollapse } from './lib/today-section-collapse' type FolderItem = { id: string; name: string } type TaskList = { id: string; folder_id: string | null; name: string; is_inbox: boolean } @@ -97,6 +98,8 @@ const markdownPreview = ref(false) const taskNoteEditor = ref(null) const SHOW_COMPLETED_STORAGE_KEY = 'dodo.show-completed' const showCompleted = ref(readStoredBoolean(window.localStorage, SHOW_COMPLETED_STORAGE_KEY, true)) +const TODAY_SECTION_COLLAPSE_KEY = 'dodo.today-section-collapse.v1' +const todaySectionCollapse = ref(readTodaySectionCollapse(window.localStorage, TODAY_SECTION_COLLAPSE_KEY)) const page = ref(1) const pageSize = 50 const totalTasks = ref(0) @@ -334,8 +337,23 @@ const todayHabitProgress = computed(() => `${todayHabitCompleted.value} / ${toda const progressWidth = (completed: number, total: number) => `${total > 0 ? Math.min(100, Math.round(completed / total * 100)) : 0}%` const todayTaskProgressPercent = computed(() => progressWidth(todayTaskCompleted.value, todayTaskTotal.value)) const todayHabitProgressPercent = computed(() => progressWidth(todayHabitCompleted.value, todayHabitTotal.value)) -function scrollTodaySection(id: 'today-tasks' | 'today-habits') { - document.getElementById(id)?.scrollIntoView({ behavior: 'smooth', block: 'start' }) +function persistTodaySectionCollapse() { + writeTodaySectionCollapse(window.localStorage, TODAY_SECTION_COLLAPSE_KEY, todaySectionCollapse.value) +} +function toggleTodaySection(section: keyof TodaySectionCollapse) { + todaySectionCollapse.value[section] = !todaySectionCollapse.value[section] + persistTodaySectionCollapse() +} +async function navigateTodaySection(section: 'tasks' | 'habits') { + if (todaySectionCollapse.value[section]) { + todaySectionCollapse.value[section] = false + persistTodaySectionCollapse() + } + await nextTick() + await new Promise((resolve) => requestAnimationFrame(() => resolve())) + const heading = document.getElementById(`today-${section}-heading`) + heading?.focus({ preventScroll: true }) + document.getElementById(`today-${section}`)?.scrollIntoView({ behavior: window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'smooth', block: 'start' }) } function updateTodayHabitSummary(value: { total: number; completed: number }) { todayHabitTotal.value = value.total @@ -1438,29 +1456,29 @@ onUnmounted(() => {