feat(schedules): add continuous calendar sliding, inline details, and full-height year view

- Unify Day, Week, Month, Year, and mini-calendar navigation on continuous unit-by-unit track sliding with keyed view containers to prevent transform leaks.
- Replace card bottom resize handle with inline pull/click detail expansion and add collapsible calendar sidebar, fit/expand grid density, and year/month quick jump.
- Stretch Year view quarter columns evenly across the viewport height (min-h 612px) and size TimeSelect to content width.
This commit is contained in:
ji ruo committed 2026-12-03 14:15:52 +08:00
1 parent e6241dda09
commit 9870859698
6 files changed
+1999 -361

No files matched your search

File diff suppressed because it is too large. Load diff
+14 -11
View File
@@ -210,7 +210,7 @@ function ScheduleForm({
));
}
return (
<div className="grid gap-4 rounded-lg border p-4">
<div className="grid gap-4">
<div className="grid gap-2">
<Label>{translate("schedule.name")}</Label>
<Input
@@ -219,7 +219,7 @@ function ScheduleForm({
placeholder={translate("schedule.nameExample")}
/>
</div>
<div className="grid grid-cols-2 gap-3">
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
<div className="grid gap-2">
<Label>{translate("schedule.rule")}</Label>
<Select
@@ -252,7 +252,7 @@ function ScheduleForm({
</div>
</div>
{draft.schedule_type === "once" ? (
<div className="grid grid-cols-2 gap-3">
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
<div className="grid gap-2">
<Label>{translate("schedule.startDate")}</Label>
<DateSelect
@@ -289,7 +289,7 @@ function ScheduleForm({
</div>
</div>
)}
<div className="grid grid-cols-2 gap-3">
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
<div className="grid gap-2">
<Label>{translate("schedule.startTime")}</Label>
<TimeSelect
@@ -981,14 +981,17 @@ export default function SchedulesPage() {
);
}
return (
<div className="flex flex-1 flex-col gap-3 p-4">
<div className="flex items-center justify-between gap-3">
<div>
<h1 className="flex items-center gap-2 font-semibold text-lg">
<CalendarClock className="size-5" />
<div
data-content-padding="false"
className="flex h-[calc(100dvh-var(--dashboard-header-height))] min-h-0 min-w-0 flex-col overflow-hidden"
>
<div className="flex shrink-0 items-center justify-between gap-2 border-b bg-background px-4 py-2">
<div className="flex min-w-0 items-baseline gap-2.5">
<h1 className="flex shrink-0 items-center gap-1.5 font-semibold text-base">
<CalendarClock className="size-4" />
{translate("schedule.title")}
</h1>
<p className="text-muted-foreground text-xs">{translate("schedule.description")}</p>
<p className="hidden truncate text-muted-foreground text-xs md:block">{translate("schedule.description")}</p>
</div>
</div>
@@ -1015,7 +1018,7 @@ export default function SchedulesPage() {
/>
<Dialog open={!!editing} onOpenChange={(open) => !open && setEditing(null)}>
<DialogContent className="max-h-[90vh] max-w-2xl overflow-y-auto">
<DialogContent className="max-h-[90dvh] w-[calc(100%-2rem)] overflow-y-auto p-6 sm:max-w-2xl">
<DialogHeader>
<DialogTitle>{editing?.id ? translate("schedule.editSchedule") : translate("schedule.create")}</DialogTitle>
<DialogDescription>{translate("schedule.pauseHelp")}</DialogDescription>
+1 -1
View File
@@ -110,7 +110,7 @@ export function TimeSelect({
return (
<div
className="flex w-[9.25rem] min-w-0 items-center gap-1.5"
className="flex w-fit min-w-0 items-center gap-1.5"
title={optional && !hasValue ? (placeholder ?? t("time.select")) : undefined}
>
<TimePart
+16
View File
@@ -217,6 +217,7 @@ export const scheduleMessages = {
"schedule.calendar.view.week": ["周", "Week"],
"schedule.calendar.view.month": ["月", "Month"],
"schedule.calendar.view.list": ["列表", "Agenda"],
"schedule.calendar.view.year": ["年", "Year"],
"schedule.calendar.allDay": ["全天 / 持续", "All day"],
"schedule.calendar.filters": ["计划状态", "Calendars"],
"schedule.calendar.upNext": ["即将执行", "Up next"],
@@ -256,4 +257,19 @@ export const scheduleMessages = {
"schedule.calendar.weekdayShort.5": ["五", "F"],
"schedule.calendar.weekdayShort.6": ["六", "S"],
"schedule.calendar.weekdayShort.7": ["日", "S"],
"schedule.calendar.densityFit": ["自适应", "Fit"],
"schedule.calendar.densityExpand": ["展开", "Expand"],
"schedule.calendar.currentTimeTooltip": ["当前服务器时间 {{time}}", "Current time {{time}}"],
"schedule.calendar.dayEventCount": ["当日 {{count}} 个计划", "{{count}} schedule(s) on this day"],
"schedule.calendar.allDayShort": ["全天", "All day"],
"schedule.calendar.yearPickerHint": ["点击切换年/月", "Click to switch year / month"],
"schedule.calendar.swipeHint": ["支持左右滑动切换", "Swipe left/right to navigate"],
"schedule.calendar.monthSchedulesCount": ["{{count}} 项", "{{count}}"],
"schedule.calendar.prevYear": ["上一年", "Previous year"],
"schedule.calendar.nextYear": ["下一年", "Next year"],
"schedule.calendar.expandDetails": ["下拉或点击展开详情", "Pull down or click to expand details"],
"schedule.calendar.collapseDetails": ["上拉或点击收起详情", "Pull up or click to collapse details"],
"schedule.calendar.fullDetails": ["更多详情", "Full details"],
"schedule.calendar.collapseSidebar": ["收起侧边栏", "Collapse sidebar"],
"schedule.calendar.expandSidebar": ["展开侧边栏", "Expand sidebar"],
} as const;
+9
View File
@@ -1,6 +1,7 @@
import assert from "node:assert/strict";
import test from "node:test";
import {
buildRollingDateKeys,
buildScheduleInputFromDrag,
buildWeekDateKeys,
expandSchedulesForDateKeys,
@@ -25,6 +26,9 @@ test("weekly, cross-midnight, open-ended, and timezone shift expansion work accu
const weekKeys = buildWeekDateKeys("2026-12-02"); // Mon 2026-11-30 .. Sun 2026-12-06
assert.equal(weekKeys[0], "2026-11-30");
assert.equal(weekKeys[6], "2026-12-06");
const rolling = buildRollingDateKeys("2026-12-01", 7);
assert.equal(rolling[0], "2026-12-01");
assert.equal(rolling[6], "2026-12-07");
const schedules = [
{
@@ -69,6 +73,11 @@ test("weekly, cross-midnight, open-ended, and timezone shift expansion work accu
assert.equal(openOcc.length, 1);
assert.equal(openOcc[0].allDay, true);
assert.equal(openOcc[0].dateKey, "2026-12-02");
// Full-year expansion (365 days) must include December, not stop at 60 days.
const yearDays = buildRollingDateKeys("2026-01-01", 365);
const yearOccs = expandSchedulesForDateKeys([schedules[1]], yearDays, 480, 480);
assert.ok(yearOccs.some((o) => o.dateKey.startsWith("2026-12-")));
});
test("overlap layout and drag/resize schedule update preserve timezone and weekday", () => {
+7 -4
View File
@@ -1,7 +1,7 @@
import type { ScheduleInput } from "./api";
import type { TaskSchedule } from "./types";
export type CalendarViewMode = "day" | "week" | "month" | "list";
export type CalendarViewMode = "day" | "week" | "month" | "year" | "list";
export type CalendarClockMode = "server" | "beijing" | "local";
export interface ZonedDateParts {
@@ -125,9 +125,12 @@ export function startOfWeekDateKey(dateKey: string): string {
return addDaysToDateKey(dateKey, -(wd - 1));
}
export function buildRollingDateKeys(startDateKey: string, count: number): string[] {
return Array.from({ length: Math.max(0, count) }, (_, i) => addDaysToDateKey(startDateKey, i));
}
export function buildWeekDateKeys(anchorDateKey: string): string[] {
const monday = startOfWeekDateKey(anchorDateKey);
return Array.from({ length: 7 }, (_, i) => addDaysToDateKey(monday, i));
return buildRollingDateKeys(startOfWeekDateKey(anchorDateKey), 7);
}
export function buildMonthGridDateKeys(year: number, month: number): string[] {
@@ -201,7 +204,7 @@ export function expandSchedulesForDateKeys(
const scanDays: string[] = [];
let cur = minDate;
for (let guard = 0; guard < 60 && cur <= maxDate; guard++) {
for (let guard = 0; guard < 420 && cur <= maxDate; guard++) {
scanDays.push(cur);
cur = addDaysToDateKey(cur, 1);
}