forge
Explore
Log in

Don't you dare go Hollow

📱 day/week/month calendar, and a denser menu sheet

Browse files at this commit

4448c0633bc8af87f783f58976e79eae15f6fe2cBurak BoduroğluParent: 76992e4
  • feat
    • 📱 day/week/month calendar, and a denser menu sheet
Show full message
feat: 📱 day/week/month calendar, and a denser menu sheet
- the calendar gains a day / week / month switch: the month grid alone is
  unreadable at 45px a cell, so a phone can now zoom to a week strip of
  seven tappable days or to one day's list, and the arrows step by whatever
  view is on screen
- month cells mark their days with category dots on phones and keep the
  titled chips from sm: up, where they fit
- the menu sheet is compact: 28px icon tiles, 40px rows, and a hairline
  between groups instead of a gap, so a group reads as a block and ten
  entries fit where six did
- the tab that opens it is labelled Menu, which is what it opens — it was
  called Account but never showed one
src/components/layout/mobile-nav-sheet.tsxmodified+14 -14
@@ -102,31 +102,31 @@ export function MobileNavSheet(props: {
102 onPointerUp={endDrag}102 onPointerUp={endDrag}
103 onPointerCancel={endDrag}103 onPointerCancel={endDrag}
104 >104 >
105- <div class="flex justify-center pt-3">105+ <div class="flex justify-center pt-2.5">
106- <span class="h-1 w-10 rounded-full bg-border" />106+ <span class="h-1 w-9 rounded-full bg-border" />
107 </div>107 </div>
108 108
109- <div class="flex items-center justify-between px-6 pb-3 pt-3">109+ <div class="flex items-center justify-between px-4 pb-2 pt-2">
110- <h2 class="text-lg font-semibold">{t("nav.menu")}</h2>110+ <h2 class="text-base font-semibold">{t("nav.menu")}</h2>
111 <button111 <button
112 type="button"112 type="button"
113 onClick={props.onClose}113 onClick={props.onClose}
114 aria-label={t("nav.close")}114 aria-label={t("nav.close")}
115- class="topbar-control flex h-9 w-9 items-center justify-center rounded-md outline-hidden focus-visible:ring-2 focus-visible:ring-ring"115+ class="topbar-control flex h-8 w-8 items-center justify-center rounded-md outline-hidden focus-visible:ring-2 focus-visible:ring-ring"
116 >116 >
117 <IconX class="h-4 w-4" />117 <IconX class="h-4 w-4" />
118 </button>118 </button>
119 </div>119 </div>
120 </div>120 </div>
121 121
122- <div class="no-scrollbar min-h-0 flex-1 overflow-y-auto overscroll-contain px-4">122+ <div class="no-scrollbar min-h-0 flex-1 overflow-y-auto overscroll-contain px-2 pb-1">
123 <For each={groups()}>123 <For each={groups()}>
124 {(group) => (124 {(group) => (
125- <div class="mt-3 first:mt-0">125+ <div class="mt-1.5 border-t border-border/60 pt-1.5 first:mt-0 first:border-t-0 first:pt-0">
126- <p class="px-2 text-xs font-medium uppercase tracking-wide text-muted-foreground">126+ <p class="px-3 pb-0.5 pt-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground">
127 {t(group.labelKey)}127 {t(group.labelKey)}
128 </p>128 </p>
129- <div class="mt-1.5 flex flex-col">129+ <div class="flex flex-col">
130 <For each={group.items}>130 <For each={group.items}>
131 {(item) => {131 {(item) => {
132 const active = () => current()?.id === item.id;132 const active = () => current()?.id === item.id;
@@ -136,19 +136,19 @@ export function MobileNavSheet(props: {
136 onClick={props.onClose}136 onClick={props.onClose}
137 aria-current={active() ? "page" : undefined}137 aria-current={active() ? "page" : undefined}
138 class={cn(138 class={cn(
139- "flex items-center gap-3 rounded-md px-2 py-3 transition-colors active:bg-muted",139+ "flex items-center gap-2.5 rounded-md px-3 py-1.5 transition-colors active:bg-muted",
140 active() ? "text-primary" : "text-foreground",140 active() ? "text-primary" : "text-foreground",
141 )}141 )}
142 >142 >
143 <span143 <span
144 class={cn(144 class={cn(
145- "inline-flex size-9 shrink-0 items-center justify-center rounded-md",145+ "inline-flex size-7 shrink-0 items-center justify-center rounded-md",
146- active() ? "bg-primary/10 text-primary" : "bg-muted text-foreground",146+ active() ? "bg-primary/10 text-primary" : "bg-muted text-muted-foreground",
147 )}147 )}
148 >148 >
149- <item.Icon class="h-4.5 w-4.5" />149+ <item.Icon class="h-4 w-4" />
150 </span>150 </span>
151- <span class="min-w-0 flex-1 truncate text-sm font-medium">151+ <span class="min-w-0 flex-1 truncate text-[13px] font-medium">
152 {t(item.labelKey)}152 {t(item.labelKey)}
153 </span>153 </span>
154 <Show when={badgeFor(item) > 0}>154 <Show when={badgeFor(item) > 0}>
src/components/layout/mobile-tab-bar.tsxmodified+2 -2
@@ -46,14 +46,14 @@ export function MobileTabBar(props: { onMenu: () => void }) {
46 <li class="min-w-0">46 <li class="min-w-0">
47 <button47 <button
48 type="button"48 type="button"
49- aria-label={t("nav.account")}49+ aria-label={t("nav.menu")}
50 class="flex h-full w-full flex-col items-center justify-center gap-1 px-1 text-[10px] font-medium text-muted-foreground"50 class="flex h-full w-full flex-col items-center justify-center gap-1 px-1 text-[10px] font-medium text-muted-foreground"
51 onClick={() => props.onMenu()}51 onClick={() => props.onMenu()}
52 >52 >
53 <span class="flex h-8 w-10 items-center justify-center rounded-md">53 <span class="flex h-8 w-10 items-center justify-center rounded-md">
54 <IconMenu class="h-4.5 w-4.5" />54 <IconMenu class="h-4.5 w-4.5" />
55 </span>55 </span>
56- <span class="truncate">{t("nav.account")}</span>56+ <span class="truncate">{t("nav.menu")}</span>
57 </button>57 </button>
58 </li>58 </li>
59 </ul>59 </ul>
src/i18n/messages.tsmodified+9 -0
@@ -1452,6 +1452,9 @@ export type MessageKey =
1452 | "calendar.lessons"1452 | "calendar.lessons"
1453 | "calendar.studies"1453 | "calendar.studies"
1454 | "calendar.homework"1454 | "calendar.homework"
1455+ | "calendar.viewDay"
1456+ | "calendar.viewWeek"
1457+ | "calendar.viewMonth"
1455 | "nav.appointments"1458 | "nav.appointments"
1456 | "appointments.title"1459 | "appointments.title"
1457 | "appointments.subtitle"1460 | "appointments.subtitle"
@@ -2161,6 +2164,9 @@ const en: Dict = {
2161 "calendar.lessons": "Lessons",2164 "calendar.lessons": "Lessons",
2162 "calendar.studies": "Studies & clubs",2165 "calendar.studies": "Studies & clubs",
2163 "calendar.homework": "Homework due",2166 "calendar.homework": "Homework due",
2167+ "calendar.viewDay": "Day",
2168+ "calendar.viewWeek": "Week",
2169+ "calendar.viewMonth": "Month",
2164 "nav.appointments": "Appointments",2170 "nav.appointments": "Appointments",
2165 "appointments.title": "Appointments",2171 "appointments.title": "Appointments",
2166 "appointments.subtitle": "Pick one of the times a teacher opened for meetings, then follow your request here.",2172 "appointments.subtitle": "Pick one of the times a teacher opened for meetings, then follow your request here.",
@@ -3698,6 +3704,9 @@ const tr: Dict = {
3698 "calendar.lessons": "Dersler",3704 "calendar.lessons": "Dersler",
3699 "calendar.studies": "Etütler ve kulüpler",3705 "calendar.studies": "Etütler ve kulüpler",
3700 "calendar.homework": "Ödev teslimi",3706 "calendar.homework": "Ödev teslimi",
3707+ "calendar.viewDay": "Gün",
3708+ "calendar.viewWeek": "Hafta",
3709+ "calendar.viewMonth": "Ay",
3701 "nav.appointments": "Randevular",3710 "nav.appointments": "Randevular",
3702 "appointments.title": "Randevular",3711 "appointments.title": "Randevular",
3703 "appointments.subtitle": "Bir öğretmenin görüşmeye açtığı saatlerden birini seç, talebini buradan takip et.",3712 "appointments.subtitle": "Bir öğretmenin görüşmeye açtığı saatlerden birini seç, talebini buradan takip et.",
src/pages/calendar-page.tsxmodified+128 -12
@@ -114,6 +114,16 @@ const KIND_STYLES: Record<CalendarKind, KindStyle> = {
114 114
115 const KIND_ORDER = Object.keys(KIND_STYLES) as CalendarKind[];115 const KIND_ORDER = Object.keys(KIND_STYLES) as CalendarKind[];
116 116
117+/** Day / week / month, the three zoom levels a phone calendar is expected to
118+ * offer. The month grid alone is unreadable at 45px per cell. */
119+type CalendarView = "day" | "week" | "month";
120+
121+const VIEWS: { id: CalendarView; labelKey: MessageKey }[] = [
122+ { id: "day", labelKey: "calendar.viewDay" },
123+ { id: "week", labelKey: "calendar.viewWeek" },
124+ { id: "month", labelKey: "calendar.viewMonth" },
125+];
126+
117 function dateKey(d: Date) {127 function dateKey(d: Date) {
118 return `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`;128 return `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`;
119 }129 }
@@ -135,6 +145,7 @@ function CalendarContent() {
135 const [viewYear, setViewYear] = createSignal(nowDate().getFullYear());145 const [viewYear, setViewYear] = createSignal(nowDate().getFullYear());
136 const [viewMonth, setViewMonth] = createSignal(nowDate().getMonth());146 const [viewMonth, setViewMonth] = createSignal(nowDate().getMonth());
137 const [selected, setSelected] = createSignal(dateKey(nowDate()));147 const [selected, setSelected] = createSignal(dateKey(nowDate()));
148+ const [view, setView] = createSignal<CalendarView>("month");
138 149
139 const [events] = createResource(async () => (await getEvents({ limit: 100 })).items, { initialValue: [] });150 const [events] = createResource(async () => (await getEvents({ limit: 100 })).items, { initialValue: [] });
140 const [exams] = createResource(async () => (await getExams({ limit: 100 })).items, { initialValue: [] });151 const [exams] = createResource(async () => (await getExams({ limit: 100 })).items, { initialValue: [] });
@@ -255,6 +266,41 @@ function CalendarContent() {
255 ms == null ? "" : new Date(ms).toLocaleTimeString(locale() === "tr" ? "tr-TR" : "en-US", { hour: "2-digit", minute: "2-digit" });266 ms == null ? "" : new Date(ms).toLocaleTimeString(locale() === "tr" ? "tr-TR" : "en-US", { hour: "2-digit", minute: "2-digit" });
256 const timeRange = (item: CalendarItem) => (item.endsAt ? `${clock(item.at)} — ${clock(item.endsAt)}` : clock(item.at));267 const timeRange = (item: CalendarItem) => (item.endsAt ? `${clock(item.at)} — ${clock(item.endsAt)}` : clock(item.at));
257 268
269+ const intl = () => (locale() === "tr" ? "tr-TR" : "en-US");
270+
271+ /** Moves the selected day, keeping the month grid on the same page as it. */
272+ const shiftSelected = (days: number) => {
273+ const d = selectedDay();
274+ d.setDate(d.getDate() + days);
275+ setSelected(dateKey(d));
276+ setViewYear(d.getFullYear());
277+ setViewMonth(d.getMonth());
278+ };
279+
280+ // Monday-first, like the month grid.
281+ const weekDays = createMemo(() => {
282+ const start = selectedDay();
283+ start.setDate(start.getDate() - ((start.getDay() + 6) % 7));
284+ return Array.from({ length: 7 }, (_, i) => {
285+ const d = new Date(start);
286+ d.setDate(start.getDate() + i);
287+ return d;
288+ });
289+ });
290+
291+ const rangeLabel = () => {
292+ if (view() === "month") return monthLabel();
293+ if (view() === "day") {
294+ return selectedDay().toLocaleDateString(intl(), { day: "numeric", month: "long", year: "numeric" });
295+ }
296+ const days = weekDays();
297+ return `${days[0].toLocaleDateString(intl(), { day: "numeric", month: "short" })} – ${days[6].toLocaleDateString(intl(), { day: "numeric", month: "short", year: "numeric" })}`;
298+ };
299+
300+ // One pair of arrows for all three views: they step by whatever is on screen.
301+ const goPrev = () => (view() === "month" ? prevMonth() : shiftSelected(view() === "week" ? -7 : -1));
302+ const goNext = () => (view() === "month" ? nextMonth() : shiftSelected(view() === "week" ? 7 : 1));
303+
258 const goToday = () => {304 const goToday = () => {
259 const n = nowDate();305 const n = nowDate();
260 setViewYear(n.getFullYear());306 setViewYear(n.getFullYear());
@@ -277,21 +323,41 @@ function CalendarContent() {
277 <section class="data-shell flex flex-col space-y-3 border-sky-500/15 bg-sky-500/2.5 p-3 lg:h-[calc(100dvh-7.5rem)]">323 <section class="data-shell flex flex-col space-y-3 border-sky-500/15 bg-sky-500/2.5 p-3 lg:h-[calc(100dvh-7.5rem)]">
278 <div class="flex flex-wrap items-start justify-between gap-3">324 <div class="flex flex-wrap items-start justify-between gap-3">
279 <div class="min-w-0">325 <div class="min-w-0">
280- <h1 class="truncate text-xl font-semibold tracking-tight text-foreground">{t("calendar.title")}</h1>326+ <h1 class="truncate text-lg font-semibold tracking-tight text-foreground sm:text-xl">{t("calendar.title")}</h1>
281- <div class="mt-1.5 flex items-center gap-2">327+ <div class="mt-1.5 flex items-center gap-1 sm:gap-2">
282- <Button type="button" variant="ghost" size="sm" class="h-8 w-8 rounded-lg p-0" onClick={prevMonth}>328+ <Button type="button" variant="ghost" size="sm" class="h-8 w-8 rounded-lg p-0" onClick={goPrev}>
283 <IconChevronLeft class="h-4 w-4" />329 <IconChevronLeft class="h-4 w-4" />
284 </Button>330 </Button>
285- <span class="text-base font-semibold tracking-tight">{monthLabel()}</span>331+ <span class="truncate text-sm font-semibold tracking-tight sm:text-base">{rangeLabel()}</span>
286- <Button type="button" variant="ghost" size="sm" class="h-8 w-8 rounded-lg p-0" onClick={nextMonth}>332+ <Button type="button" variant="ghost" size="sm" class="h-8 w-8 rounded-lg p-0" onClick={goNext}>
287 <IconChevronRight class="h-4 w-4" />333 <IconChevronRight class="h-4 w-4" />
288 </Button>334 </Button>
289 </div>335 </div>
290 </div>336 </div>
291- <Button type="button" variant="outline" size="sm" class="h-9 rounded-lg gap-1 text-sm font-semibold" onClick={goToday}>337+ <div class="flex items-center gap-2">
292- <IconCalendarDays class="h-3.5 w-3.5" />338+ {/* Day / week / month, the way a phone calendar switches zoom. */}
293- {t("calendar.today")}339+ <div class="inline-flex shrink-0 rounded-lg border border-border bg-muted/40 p-0.5">
294- </Button>340+ <For each={VIEWS}>
341+ {(entry) => (
342+ <button
343+ type="button"
344+ aria-pressed={view() === entry.id}
345+ onClick={() => setView(entry.id)}
346+ class={cn(
347+ "rounded-md px-2.5 py-1 text-xs font-semibold transition-colors",
348+ view() === entry.id ? "bg-background text-foreground shadow-xs" : "text-muted-foreground",
349+ )}
350+ >
351+ {t(entry.labelKey)}
352+ </button>
353+ )}
354+ </For>
355+ </div>
356+ <Button type="button" variant="outline" size="sm" class="h-9 shrink-0 rounded-lg gap-1 text-sm font-semibold" onClick={goToday}>
357+ <IconCalendarDays class="h-3.5 w-3.5" />
358+ <span class="hidden sm:inline">{t("calendar.today")}</span>
359+ </Button>
360+ </div>
295 </div>361 </div>
296 362
297 {/* Legend — six categories share one grid, so the colours need naming. */}363 {/* Legend — six categories share one grid, so the colours need naming. */}
@@ -307,7 +373,49 @@ function CalendarContent() {
307 </div>373 </div>
308 374
309 <Suspense fallback={<PageSpinner />}>375 <Suspense fallback={<PageSpinner />}>
310- <div class="grid min-h-0 flex-1 gap-4 xl:grid-cols-[minmax(0,1fr)_20rem]">376+ <div class={cn("grid min-h-0 flex-1 gap-4", view() === "month" && "xl:grid-cols-[minmax(0,1fr)_20rem]")}>
377+ <Show when={view() === "week"}>
378+ {/* Week strip: seven tappable days with their category dots, the
379+ middle zoom level between a month of cells and one day's list. */}
380+ <div class="grid shrink-0 grid-cols-7 gap-1 rounded-lg border bg-card p-1 shadow-xs">
381+ <For each={weekDays()}>
382+ {(day) => {
383+ const key = dateKey(day);
384+ const dayItems = () => itemsByDay().get(key) ?? [];
385+ const today = () => dateKey(nowDate()) === key;
386+ return (
387+ <button
388+ type="button"
389+ onClick={() => setSelected(key)}
390+ class={cn(
391+ "flex min-w-0 flex-col items-center gap-1 rounded-md px-0.5 py-1.5 transition-colors",
392+ key === selected() ? "bg-sky-50 ring-1 ring-inset ring-sky-400/50 dark:bg-sky-950/40 dark:ring-sky-500/40" : "hover:bg-muted/40",
393+ )}
394+ >
395+ <span class="text-[10px] font-semibold uppercase tracking-wide text-muted-foreground">
396+ {dayNames()[(day.getDay() + 6) % 7]}
397+ </span>
398+ <span
399+ class={cn(
400+ "inline-flex h-7 w-7 items-center justify-center rounded-full text-[13px] font-semibold",
401+ today() ? "bg-sky-500 text-white" : "text-foreground",
402+ )}
403+ >
404+ {day.getDate()}
405+ </span>
406+ <span class="flex h-1.5 items-center gap-0.5">
407+ <For each={dayItems().slice(0, 3)}>
408+ {(item) => <span class={cn("h-1.5 w-1.5 rounded-full", KIND_STYLES[item.kind].dot)} />}
409+ </For>
410+ </span>
411+ </button>
412+ );
413+ }}
414+ </For>
415+ </div>
416+ </Show>
417+
418+ <Show when={view() === "month"}>
311 <div class="flex min-h-0 flex-col rounded-lg border bg-card shadow-xs">419 <div class="flex min-h-0 flex-col rounded-lg border bg-card shadow-xs">
312 <div class="grid shrink-0 grid-cols-7 border-b">420 <div class="grid shrink-0 grid-cols-7 border-b">
313 <For each={dayNames()}>421 <For each={dayNames()}>
@@ -329,7 +437,7 @@ function CalendarContent() {
329 <button437 <button
330 type="button"438 type="button"
331 class={cn(439 class={cn(
332- "relative flex min-h-17 min-w-0 flex-col overflow-hidden border-b border-r border-border/40 p-1.5 text-left transition-colors last:border-r-0 hover:bg-muted/40 lg:min-h-0",440+ "relative flex min-h-12 min-w-0 flex-col overflow-hidden border-b border-r border-border/40 p-1 text-left transition-colors last:border-r-0 hover:bg-muted/40 sm:min-h-17 sm:p-1.5 lg:min-h-0",
333 cell.other && "pointer-events-none bg-muted/20",441 cell.other && "pointer-events-none bg-muted/20",
334 cellSelected() ? "bg-sky-50/60 ring-1 ring-inset ring-sky-400/50 dark:bg-sky-950/40 dark:ring-sky-500/40" : "",442 cellSelected() ? "bg-sky-50/60 ring-1 ring-inset ring-sky-400/50 dark:bg-sky-950/40 dark:ring-sky-500/40" : "",
335 cellToday ? "font-bold text-sky-600 dark:text-sky-400" : ""443 cellToday ? "font-bold text-sky-600 dark:text-sky-400" : ""
@@ -347,7 +455,14 @@ function CalendarContent() {
347 {cell.day || ""}455 {cell.day || ""}
348 </span>456 </span>
349 <Show when={dayItems().length > 0}>457 <Show when={dayItems().length > 0}>
350- <div class="mt-1 flex min-h-0 flex-1 flex-col justify-end gap-0.5 overflow-hidden">458+ {/* A phone cell is too narrow for titles, so it marks
459+ the day with one dot per category instead. */}
460+ <div class="mt-0.5 flex flex-wrap gap-0.5 sm:hidden">
461+ <For each={dayItems().slice(0, 4)}>
462+ {(item) => <span class={cn("h-1.5 w-1.5 rounded-full", KIND_STYLES[item.kind].dot)} />}
463+ </For>
464+ </div>
465+ <div class="mt-1 hidden min-h-0 flex-1 flex-col justify-end gap-0.5 overflow-hidden sm:flex">
351 <For each={dayItems().slice(0, CHIPS_PER_CELL)}>466 <For each={dayItems().slice(0, CHIPS_PER_CELL)}>
352 {(item) => (467 {(item) => (
353 <span class={cn("inline-flex min-w-0 items-center gap-1 rounded px-1 py-0.5 text-[9px] font-medium leading-none", KIND_STYLES[item.kind].chip)}>468 <span class={cn("inline-flex min-w-0 items-center gap-1 rounded px-1 py-0.5 text-[9px] font-medium leading-none", KIND_STYLES[item.kind].chip)}>
@@ -369,6 +484,7 @@ function CalendarContent() {
369 </For>484 </For>
370 </div>485 </div>
371 </div>486 </div>
487+ </Show>
372 488
373 <div class="min-h-0 space-y-3 overflow-y-auto">489 <div class="min-h-0 space-y-3 overflow-y-auto">
374 <div class="rounded-xl border border-border/80 bg-card p-3 shadow-xs">490 <div class="rounded-xl border border-border/80 bg-card p-3 shadow-xs">