Skip to content

Commit

Permalink
Calendar: Week views should not scroll to clicked date (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
NeilRashbrook authored Jan 10, 2025
1 parent e81fb2a commit f43fd53
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/frontend/Calendar/CalendarApp.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<vbox flex class="calendar-app">
<vbox flex class="main">
<MainView {events} bind:start={$selectedDate} dateInterval={$selectedDateInterval}>
<MainView {events} bind:start={$startDate} dateInterval={$selectedDateInterval}>
<TitleBarLeft on:addEvent={() => catchErrors(addEvent)} slot="top-left" />
<ViewSelector bind:dateInterval={$selectedDateInterval} slot="top-right" />
</MainView>
Expand All @@ -9,7 +9,7 @@

<script lang="ts">
import { Event } from "../../logic/Calendar/Event";
import { selectedCalendar, selectedDate, selectedDateInterval } from "./selected";
import { selectedCalendar, selectedDate, selectedDateInterval, startDate } from "./selected";
import { calendarMustangApp } from "./CalendarMustangApp";
import { appGlobal } from "../../logic/app";
import MainView from "./MainView.svelte";
Expand Down
12 changes: 3 additions & 9 deletions app/frontend/Calendar/DualView.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<hbox flex class="dual-view">
<WeekView bind:start {events} showDays={2}>
<WeekView bind:start={$selectedDate} {events} showDays={2}>
<slot name="top-left" slot="top-left" />
</WeekView>
<MonthView start={monthStart} {events} showDays={35}>
<MonthView {start} {events} showDays={35}>
<slot name="top-right" slot="top-right" />
</MonthView>
</hbox>
Expand All @@ -12,16 +12,10 @@
import type { Collection } from "svelte-collections";
import WeekView from "./WeekView.svelte";
import MonthView from "./MonthView.svelte";
import { selectedDate } from "./selected";
export let start: Date;
export let events: Collection<Event>;
let monthStart: Date;
$: start, syncMonth();
function syncMonth() {
monthStart = start;
}
</script>

<style>
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/Calendar/selected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { writable, type Writable } from "svelte/store";
/** Which event is highlighted right now. */
export let selectedEvent: Writable<Event> = writable(null);

// TODO Move into observable prefs?
export let selectedDate = writable(new Date());
export type DateInterval = 0 | 1 | 2 | 7 | 31 | 28;
export let selectedDateInterval = writable(2 as DateInterval);
export let startDate = writable(new Date());
export let selectedCalendar = writable<Calendar | null>(null);

0 comments on commit f43fd53

Please sign in to comment.