Compare commits

..
4 Commits
9 changed files with 621 additions and 307 deletions
+8
View File
@@ -1,5 +1,13 @@
# Changelog # Changelog
## [0.5.0](https://github.com/ginnoir/famapp/compare/v0.4.10...v0.5.0) (2026-06-03)
### Features
- **mobile:** full mobile experience overhaul — bottom nav, touch targets, calendar mobile layout with day/week/agenda views and calendars bottom sheet, bidirectional swipe gestures on list items (right to complete, left to delete), iOS safe-area and keyboard support, input zoom prevention
- **mobile:** settings navigation replaced with 2-column icon grid (no horizontal scroll)
- **mobile:** remove floating action button in favour of persistent topbar quick-add button
## [0.4.10](https://github.com/ginnoir/famapp/compare/v0.4.9...v0.4.10) (2026-06-03) ## [0.4.10](https://github.com/ginnoir/famapp/compare/v0.4.9...v0.4.10) (2026-06-03)
## [0.4.8](https://github.com/ginnoir/famapp/compare/v0.4.6...v0.4.8) (2026-06-03) ## [0.4.8](https://github.com/ginnoir/famapp/compare/v0.4.6...v0.4.8) (2026-06-03)
+3 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "famapp", "name": "famapp",
"version": "0.4.10", "version": "0.5.0",
"private": true, "private": true,
"type": "module", "type": "module",
"packageManager": "pnpm@10.33.3", "packageManager": "pnpm@10.33.3",
@@ -22,7 +22,7 @@
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"db:generate": "drizzle-kit generate", "db:generate": "drizzle-kit generate",
"db:migrate": "drizzle-kit migrate", "db:migrate": "drizzle-kit migrate",
"db:seed": "tsx --env-file=.env scripts/seed.ts", "db:seed": "node --env-file=.env scripts/seed.mjs",
"db:studio": "drizzle-kit studio", "db:studio": "drizzle-kit studio",
"gen:icons": "node scripts/generate-icons.mjs", "gen:icons": "node scripts/generate-icons.mjs",
"vapid:generate": "node scripts/vapid-generate.mjs", "vapid:generate": "node scripts/vapid-generate.mjs",
@@ -78,6 +78,7 @@
"@fullcalendar/core": "^6.1.20", "@fullcalendar/core": "^6.1.20",
"@fullcalendar/daygrid": "^6.1.20", "@fullcalendar/daygrid": "^6.1.20",
"@fullcalendar/interaction": "^6.1.20", "@fullcalendar/interaction": "^6.1.20",
"@fullcalendar/list": "^6.1.20",
"@fullcalendar/react": "^6.1.20", "@fullcalendar/react": "^6.1.20",
"@fullcalendar/timegrid": "^6.1.20", "@fullcalendar/timegrid": "^6.1.20",
"canvas-confetti": "^1.9.4", "canvas-confetti": "^1.9.4",
+12
View File
@@ -23,6 +23,9 @@ importers:
'@fullcalendar/interaction': '@fullcalendar/interaction':
specifier: ^6.1.20 specifier: ^6.1.20
version: 6.1.20(@fullcalendar/core@6.1.20) version: 6.1.20(@fullcalendar/core@6.1.20)
'@fullcalendar/list':
specifier: ^6.1.20
version: 6.1.20(@fullcalendar/core@6.1.20)
'@fullcalendar/react': '@fullcalendar/react':
specifier: ^6.1.20 specifier: ^6.1.20
version: 6.1.20(@fullcalendar/core@6.1.20)(react-dom@19.2.5(react@19.2.5))(react@19.2.5) version: 6.1.20(@fullcalendar/core@6.1.20)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)
@@ -976,6 +979,11 @@ packages:
peerDependencies: peerDependencies:
'@fullcalendar/core': ~6.1.20 '@fullcalendar/core': ~6.1.20
'@fullcalendar/list@6.1.20':
resolution: {integrity: sha512-7Hzkbb7uuSqrXwTyD0Ld/7SwWNxPD6SlU548vtkIpH55rZ4qquwtwYdMPgorHos5OynHA4OUrZNcH51CjrCf2g==}
peerDependencies:
'@fullcalendar/core': ~6.1.20
'@fullcalendar/react@6.1.20': '@fullcalendar/react@6.1.20':
resolution: {integrity: sha512-1w0pZtceaUdfAnxMSCGHCQalhi+mR1jOe76sXzyAXpcPz/Lf0zHSdcGK/U2XpZlnQgQtBZW+d+QBnnzVQKCxAA==} resolution: {integrity: sha512-1w0pZtceaUdfAnxMSCGHCQalhi+mR1jOe76sXzyAXpcPz/Lf0zHSdcGK/U2XpZlnQgQtBZW+d+QBnnzVQKCxAA==}
peerDependencies: peerDependencies:
@@ -5810,6 +5818,10 @@ snapshots:
dependencies: dependencies:
'@fullcalendar/core': 6.1.20 '@fullcalendar/core': 6.1.20
'@fullcalendar/list@6.1.20(@fullcalendar/core@6.1.20)':
dependencies:
'@fullcalendar/core': 6.1.20
'@fullcalendar/react@6.1.20(@fullcalendar/core@6.1.20)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)': '@fullcalendar/react@6.1.20(@fullcalendar/core@6.1.20)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)':
dependencies: dependencies:
'@fullcalendar/core': 6.1.20 '@fullcalendar/core': 6.1.20
+85 -1
View File
@@ -725,7 +725,7 @@
} }
:where(html[data-nav="bottom"]) .scroll-area, :where(html[data-nav="bottom"]) .scroll-area,
:where(html[data-nav="fab"]) .scroll-area { :where(html[data-nav="fab"]) .scroll-area {
padding: 12px 14px 88px; padding: 12px 14px 74px;
} }
.scroll-area::-webkit-scrollbar { .scroll-area::-webkit-scrollbar {
@@ -1424,3 +1424,87 @@ select {
.animate-emoji-float { .animate-emoji-float {
animation: emojiFloat 1.8s ease-out both; animation: emojiFloat 1.8s ease-out both;
} }
/* ── Calendar min-height CSS variable ───────────────────────────── */
/* Used by calendar-shell so the grid fills the viewport correctly */
/* on both desktop (topbar only) and mobile (topbar + bottom nav). */
:root {
--cal-topbar-h: 57px;
--cal-nav-h: 0px;
}
:where(html[data-nav="bottom"]),
:where(html[data-nav="fab"]) {
--cal-nav-h: 62px;
}
/* ── Mobile overrides (≤ 759 px) ────────────────────────────────── */
@media (max-width: 759px) {
/* Prevent iOS Safari from zooming into inputs (requires ≥ 16 px) */
.input,
input,
select,
textarea {
font-size: 16px;
}
/* Topbar: tighten padding; avatar is redundant (Settings in bottom nav) */
.topbar {
padding: 10px 14px;
gap: 8px;
}
.topbar-actions > .avatar {
display: none;
}
/* Keyboard shortcut hints are meaningless on touch */
.kbd {
display: none;
}
/* Eliminate 300 ms tap delay on interactive controls */
.btn,
.checkbox,
.nav-item,
.list-row,
.fab,
.bottom-nav button,
.bottom-nav a {
touch-action: manipulation;
}
/* Momentum scrolling + prevent page bounce fighting in-app scroll */
.scroll-area {
-webkit-overflow-scrolling: touch;
overscroll-behavior-y: contain;
}
/* Checkbox: keep the 18 px visual but expand the tap area to 44 px */
.checkbox {
position: relative;
flex-shrink: 0;
}
.checkbox::after {
content: "";
position: absolute;
inset: -13px; /* 18 + 2×13 = 44 px tap target */
}
/* Delete button on list rows: always visible on touch (no hover state) */
.list-row-delete {
opacity: 1 !important;
}
}
/* Landscape phone: compress bottom nav to icon-only to reclaim vertical space */
@media (max-width: 759px) and (orientation: landscape) and (max-height: 500px) {
.bottom-nav {
height: 44px;
padding: 2px 8px env(safe-area-inset-bottom, 2px);
}
.bottom-nav .nav-label {
display: none;
}
:where(html[data-nav="bottom"]) .scroll-area {
padding-bottom: 52px;
}
}
+1
View File
@@ -42,6 +42,7 @@ const jetbrains = JetBrains_Mono({
export const viewport: Viewport = { export const viewport: Viewport = {
themeColor: "#1F1B16", themeColor: "#1F1B16",
viewportFit: "cover",
}; };
export const metadata: Metadata = { export const metadata: Metadata = {
-2
View File
@@ -4,7 +4,6 @@ import type { DashboardMeta } from "@/app/d/actions";
import { Sidebar } from "@/components/sidebar"; import { Sidebar } from "@/components/sidebar";
import { Topbar } from "@/components/topbar"; import { Topbar } from "@/components/topbar";
import { BottomNav } from "@/components/bottom-nav"; import { BottomNav } from "@/components/bottom-nav";
import { Fab } from "@/components/fab";
import { NavModeProvider } from "@/components/nav-mode-provider"; import { NavModeProvider } from "@/components/nav-mode-provider";
const BARE_PREFIXES = ["/s/", "/login"]; const BARE_PREFIXES = ["/s/", "/login"];
@@ -38,7 +37,6 @@ export async function AppShell({ signedIn, navStyle, children }: Props) {
<div className="scroll-area">{children}</div> <div className="scroll-area">{children}</div>
</main> </main>
<BottomNav /> <BottomNav />
<Fab />
<NavModeProvider navStyle={navStyle} /> <NavModeProvider navStyle={navStyle} />
</div> </div>
); );
+10 -4
View File
@@ -81,20 +81,26 @@ function SectionHashSync({ pathname }: { pathname: string | null }) {
export function SettingsTabsMobile({ active }: { active: SectionId }) { export function SettingsTabsMobile({ active }: { active: SectionId }) {
const router = useRouter(); const router = useRouter();
return ( return (
<div className="seg w-full overflow-x-auto" style={{ display: "flex" }}> <div className="grid grid-cols-2 gap-1.5 mb-1">
{SECTIONS.map((s) => ( {SECTIONS.map((s) => (
<button <button
key={s.id} key={s.id}
type="button" type="button"
role="tab" aria-current={active === s.id ? "page" : undefined}
aria-selected={active === s.id} className={cn(
"flex items-center gap-2.5 px-3 py-2.5 rounded-[var(--r-md)] border-[0.5px] text-left text-[13px] font-medium transition-colors",
active === s.id
? "bg-[var(--card)] border-[var(--hair-2)] text-[var(--ink)] shadow-[var(--shadow-1)]"
: "border-transparent text-[var(--ink-soft)] hover:bg-[var(--shade)]",
)}
onClick={() => { onClick={() => {
const url = new URL(window.location.href); const url = new URL(window.location.href);
url.searchParams.set("s", s.id); url.searchParams.set("s", s.id);
router.replace(url.pathname + "?" + url.searchParams.toString(), { scroll: false }); router.replace(url.pathname + "?" + url.searchParams.toString(), { scroll: false });
}} }}
> >
{s.label.split(" ")[0]} <NavIcon name={s.icon} className="size-4 shrink-0" />
<span>{s.label.split(" ")[0]}</span>
</button> </button>
))} ))}
</div> </div>
+371 -252
View File
@@ -4,10 +4,11 @@ import FullCalendar from "@fullcalendar/react";
import dayGridPlugin from "@fullcalendar/daygrid"; import dayGridPlugin from "@fullcalendar/daygrid";
import interactionPlugin from "@fullcalendar/interaction"; import interactionPlugin from "@fullcalendar/interaction";
import timeGridPlugin from "@fullcalendar/timegrid"; import timeGridPlugin from "@fullcalendar/timegrid";
import listPlugin from "@fullcalendar/list";
import type { DateSelectArg, EventClickArg, EventDropArg } from "@fullcalendar/core"; import type { DateSelectArg, EventClickArg, EventDropArg } from "@fullcalendar/core";
import type { EventResizeDoneArg } from "@fullcalendar/interaction"; import type { EventResizeDoneArg } from "@fullcalendar/interaction";
import { CalendarPlus, Check, Eye, EyeOff, Plus, Trash2 } from "lucide-react"; import { CalendarPlus, Check, Eye, EyeOff, Plus, Trash2, X } from "lucide-react";
import { useMemo, useState, useTransition } from "react"; import { useMemo, useState, useEffect, useTransition } from "react";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label"; import { Label } from "@/components/ui/label";
@@ -44,6 +45,8 @@ type EventDraft = {
remindMinutesBefore: number | null; remindMinutesBefore: number | null;
}; };
type MobileView = "day" | "week" | "agenda";
const DEFAULT_COLOR = "#B85C3C"; const DEFAULT_COLOR = "#B85C3C";
const VIEW_MAP: Record<CalView, string> = { const VIEW_MAP: Record<CalView, string> = {
@@ -52,8 +55,13 @@ const VIEW_MAP: Record<CalView, string> = {
day: "timeGridDay", day: "timeGridDay",
}; };
const MOBILE_VIEW_MAP: Record<MobileView, string> = {
day: "timeGridDay",
week: "timeGridWeek",
agenda: "listWeek",
};
function withAlpha(hex: string, alpha: number): string { function withAlpha(hex: string, alpha: number): string {
// Accept #RGB / #RRGGBB / non-hex (return as-is for non-hex e.g. var(--))
if (!hex.startsWith("#")) return hex; if (!hex.startsWith("#")) return hex;
let h = hex.slice(1); let h = hex.slice(1);
if (h.length === 3) if (h.length === 3)
@@ -88,6 +96,17 @@ export function CalendarShell({
); );
const [lastCalendarId, setLastCalendarId] = useState(calendars[0]?.id ?? ""); const [lastCalendarId, setLastCalendarId] = useState(calendars[0]?.id ?? "");
const [isPending, startTransition] = useTransition(); const [isPending, startTransition] = useTransition();
const [isMobile, setIsMobile] = useState(false);
const [showCalendarsPanel, setShowCalendarsPanel] = useState(false);
const [mobileView, setMobileView] = useState<MobileView>("day");
useEffect(() => {
const mq = window.matchMedia("(max-width: 759px)");
const apply = () => setIsMobile(mq.matches);
apply();
mq.addEventListener("change", apply);
return () => mq.removeEventListener("change", apply);
}, []);
const defaultCalendarId = calendarRows.some((calendar) => calendar.id === lastCalendarId) const defaultCalendarId = calendarRows.some((calendar) => calendar.id === lastCalendarId)
? lastCalendarId ? lastCalendarId
@@ -289,106 +308,49 @@ export function CalendarShell({
}); });
} }
return ( // Shared calendar list + new-calendar form rendered in both the desktop aside
<div className="grid min-h-[calc(100vh-57px)] grid-cols-1 lg:grid-cols-[280px_1fr]"> // and the mobile bottom-sheet panel.
<aside className="border-b bg-sidebar p-4 lg:border-r lg:border-b-0"> const calendarsPanelContent = (
<div className="mb-4 flex items-center justify-between"> <>
<h1 className="text-xl font-semibold">Calendar</h1> <div className="space-y-2">
<Button size="icon-sm" variant="outline" onClick={() => openNewEvent()}> {calendarRows.map((calendar) => (
<Plus /> <div key={calendar.id} className="rounded-lg border bg-background p-2">
<span className="sr-only">New event</span> <div className="flex items-center gap-2">
</Button> <button
</div> type="button"
className="grid size-7 place-items-center rounded-md border"
<div className="space-y-2"> onClick={() => toggleCalendar(calendar.id)}
{calendarRows.map((calendar) => ( aria-label={`${visibleIds.has(calendar.id) ? "Hide" : "Show"} ${calendar.name}`}
<div key={calendar.id} className="rounded-lg border bg-background p-2"> >
<div className="flex items-center gap-2"> {visibleIds.has(calendar.id) ? <Eye /> : <EyeOff />}
<button </button>
type="button" <span
className="grid size-7 place-items-center rounded-md border" className="size-3 rounded-full"
onClick={() => toggleCalendar(calendar.id)} style={{ backgroundColor: calendar.color ?? DEFAULT_COLOR }}
aria-label={`${visibleIds.has(calendar.id) ? "Hide" : "Show"} ${calendar.name}`} />
>
{visibleIds.has(calendar.id) ? <Eye /> : <EyeOff />}
</button>
<span
className="size-3 rounded-full"
style={{ backgroundColor: calendar.color ?? DEFAULT_COLOR }}
/>
<Input
aria-label={`${calendar.name} name`}
value={calendar.name}
onChange={(event) => updateCalendarName(calendar, event.target.value)}
onBlur={() => commitCalendarName(calendar)}
/>
</div>
<div className="mt-2 grid grid-cols-[1fr_1fr_auto] gap-2">
<Input
aria-label={`${calendar.name} color`}
type="color"
value={calendar.color ?? DEFAULT_COLOR}
onChange={(event) => updateCalendar(calendar, { color: event.target.value })}
/>
<Select
value={calendar.visibility}
onValueChange={(value) =>
updateCalendar(calendar, {
visibility: value as "private" | "household",
})
}
>
<SelectTrigger aria-label={`${calendar.name} visibility`}>
<SelectValue>
{calendar.visibility === "household" ? "Household" : "Private"}
</SelectValue>
</SelectTrigger>
<SelectContent>
<SelectItem value="household">Household</SelectItem>
<SelectItem value="private">Private</SelectItem>
</SelectContent>
</Select>
<Button
size="icon"
variant="ghost"
onClick={() => removeCalendar(calendar.id)}
aria-label={`Delete ${calendar.name}`}
>
<Trash2 />
</Button>
</div>
</div>
))}
</div>
<div className="mt-4 rounded-lg border bg-background p-3">
<div className="mb-3 flex items-center gap-2 text-sm font-medium">
<CalendarPlus className="size-4" />
New calendar
</div>
<div className="space-y-2">
<Label htmlFor="calendar-name">Name</Label>
<Input
id="calendar-name"
value={calendarName}
onChange={(event) => setCalendarName(event.target.value)}
/>
<div className="grid grid-cols-[1fr_1fr] gap-2">
<Input <Input
aria-label="Calendar color" aria-label={`${calendar.name} name`}
value={calendar.name}
onChange={(event) => updateCalendarName(calendar, event.target.value)}
onBlur={() => commitCalendarName(calendar)}
/>
</div>
<div className="mt-2 grid grid-cols-[1fr_1fr_auto] gap-2">
<Input
aria-label={`${calendar.name} color`}
type="color" type="color"
value={calendarColor} value={calendar.color ?? DEFAULT_COLOR}
onChange={(event) => setCalendarColorValue(event.target.value)} onChange={(event) => updateCalendar(calendar, { color: event.target.value })}
/> />
<Select <Select
value={calendarVisibility} value={calendar.visibility}
onValueChange={(value) => onValueChange={(value) =>
setCalendarVisibilityValue(value as "private" | "household") updateCalendar(calendar, { visibility: value as "private" | "household" })
} }
> >
<SelectTrigger aria-label="Calendar visibility"> <SelectTrigger aria-label={`${calendar.name} visibility`}>
<SelectValue> <SelectValue>
{calendarVisibility === "household" ? "Household" : "Private"} {calendar.visibility === "household" ? "Household" : "Private"}
</SelectValue> </SelectValue>
</SelectTrigger> </SelectTrigger>
<SelectContent> <SelectContent>
@@ -396,179 +358,336 @@ export function CalendarShell({
<SelectItem value="private">Private</SelectItem> <SelectItem value="private">Private</SelectItem>
</SelectContent> </SelectContent>
</Select> </Select>
<Button
size="icon"
variant="ghost"
onClick={() => removeCalendar(calendar.id)}
aria-label={`Delete ${calendar.name}`}
>
<Trash2 />
</Button>
</div> </div>
<Button className="w-full" onClick={addCalendar} disabled={!calendarName}>
<Check />
Create calendar
</Button>
</div> </div>
))}
</div>
<div className="mt-4 rounded-lg border bg-background p-3">
<div className="mb-3 flex items-center gap-2 text-sm font-medium">
<CalendarPlus className="size-4" />
New calendar
</div> </div>
<div className="space-y-2">
<Label htmlFor="calendar-name">Name</Label>
<Input
id="calendar-name"
value={calendarName}
onChange={(event) => setCalendarName(event.target.value)}
/>
<div className="grid grid-cols-[1fr_1fr] gap-2">
<Input
aria-label="Calendar color"
type="color"
value={calendarColor}
onChange={(event) => setCalendarColorValue(event.target.value)}
/>
<Select
value={calendarVisibility}
onValueChange={(value) =>
setCalendarVisibilityValue(value as "private" | "household")
}
>
<SelectTrigger aria-label="Calendar visibility">
<SelectValue>
{calendarVisibility === "household" ? "Household" : "Private"}
</SelectValue>
</SelectTrigger>
<SelectContent>
<SelectItem value="household">Household</SelectItem>
<SelectItem value="private">Private</SelectItem>
</SelectContent>
</Select>
</div>
<Button className="w-full" onClick={addCalendar} disabled={!calendarName}>
<Check />
Create calendar
</Button>
</div>
</div>
</>
);
const fcEvents = visibleEvents.map((event) => {
const color =
calendarRows.find((calendar) => calendar.id === event.calendarId)?.color ?? DEFAULT_COLOR;
return {
id: event.id,
title: event.title,
start: event.startAt,
end: event.endAt,
allDay: event.allDay,
backgroundColor: withAlpha(color, 0.14),
borderColor: color,
textColor: "var(--ink-2)",
extendedProps: { calendarId: event.calendarId, color },
};
});
// Shared event form content — rendered inside both the desktop centered modal
// and the mobile bottom-sheet.
const eventFormContent = selectedEvent && (
<div className="grid gap-3">
<Label htmlFor="event-title">Title</Label>
<Input
id="event-title"
value={selectedEvent.title}
onChange={(event) => setSelectedEvent({ ...selectedEvent, title: event.target.value })}
/>
<Label htmlFor="event-calendar">Calendar</Label>
<Select
value={selectedEvent.calendarId}
onValueChange={(value) => setSelectedEvent({ ...selectedEvent, calendarId: value ?? "" })}
>
<SelectTrigger id="event-calendar">
<SelectValue>
{calendarRows.find((c) => c.id === selectedEvent.calendarId)?.name ??
"Select a calendar"}
</SelectValue>
</SelectTrigger>
<SelectContent>
{calendarRows.map((calendar) => (
<SelectItem key={calendar.id} value={calendar.id}>
{calendar.name}
</SelectItem>
))}
</SelectContent>
</Select>
<div className="grid gap-3 sm:grid-cols-2">
<div className="space-y-1.5">
<Label htmlFor="event-start">Start</Label>
<Input
id="event-start"
type="datetime-local"
value={selectedEvent.startAt}
onChange={(event) =>
setSelectedEvent({ ...selectedEvent, startAt: event.target.value })
}
/>
</div>
<div className="space-y-1.5">
<Label htmlFor="event-end">End</Label>
<Input
id="event-end"
type="datetime-local"
value={selectedEvent.endAt}
onChange={(event) => setSelectedEvent({ ...selectedEvent, endAt: event.target.value })}
/>
</div>
</div>
<Label htmlFor="event-location">Location</Label>
<Input
id="event-location"
value={selectedEvent.location}
onChange={(event) => setSelectedEvent({ ...selectedEvent, location: event.target.value })}
/>
<Label htmlFor="event-notes">Notes</Label>
<textarea
id="event-notes"
className="min-h-20 rounded-lg border border-input bg-transparent px-2.5 py-2 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50"
value={selectedEvent.notes}
onChange={(event) => setSelectedEvent({ ...selectedEvent, notes: event.target.value })}
/>
{!selectedEvent.id && (
<label className="flex items-center gap-2 text-sm">
<input
type="checkbox"
className="size-4 cursor-pointer"
checked={selectedEvent.remindMinutesBefore !== null}
onChange={(e) =>
setSelectedEvent({
...selectedEvent,
remindMinutesBefore: e.target.checked ? 30 : null,
})
}
/>
Remind me 30 min before
</label>
)}
<div className="flex items-center justify-between gap-2 pt-2">
<div className="flex gap-2">
{selectedEvent.id && (
<Button variant="destructive" onClick={removeSelectedEvent}>
Delete event
</Button>
)}
</div>
<div className="flex gap-2">
{selectedEvent.id && (
<ShareButton entityType="calendar.event" entityId={selectedEvent.id} />
)}
<Button onClick={saveSelectedEvent} disabled={!selectedEvent.title || isPending}>
Save event
</Button>
</div>
</div>
</div>
);
return (
<div
className="grid grid-cols-1 lg:grid-cols-[280px_1fr]"
style={{ minHeight: "calc(100dvh - var(--cal-topbar-h) - var(--cal-nav-h))" }}
>
{/* Desktop aside — hidden on mobile */}
<aside
className={`${isMobile ? "hidden" : ""} border-b bg-sidebar p-4 lg:border-r lg:border-b-0`}
>
<div className="mb-4 flex items-center justify-between">
<h1 className="text-xl font-semibold">Calendar</h1>
<Button size="icon-sm" variant="outline" onClick={() => openNewEvent()}>
<Plus />
<span className="sr-only">New event</span>
</Button>
</div>
{calendarsPanelContent}
</aside> </aside>
<section className="fc-skin min-w-0 p-4"> {/* Calendar section */}
<FullCalendar <section className="fc-skin flex min-w-0 flex-col">
plugins={[dayGridPlugin, timeGridPlugin, interactionPlugin]} {/* Mobile toolbar: view switcher + calendars button + new event */}
initialView={VIEW_MAP[defaultView]} {isMobile && (
headerToolbar={{ <div
left: "prev,next today", className="flex items-center gap-2 border-b px-3 py-2"
center: "title", style={{ borderColor: "var(--hair)" }}
right: "dayGridMonth,timeGridWeek,timeGridDay", >
}} <div className="seg flex-1">
buttonText={{ {(["day", "week", "agenda"] as MobileView[]).map((v) => (
today: "Today", <button
month: "Month", key={v}
week: "Week", type="button"
day: "Day", aria-selected={mobileView === v}
}} onClick={() => setMobileView(v)}
dayHeaderFormat={{ weekday: "short" }} >
selectable {v.charAt(0).toUpperCase() + v.slice(1)}
editable </button>
eventResizableFromStart ))}
select={handleDateSelect} </div>
eventClick={openExistingEvent} <button
eventDrop={moveEvent} type="button"
eventResize={moveEvent} className="btn btn-ghost btn-sm"
events={visibleEvents.map((event) => { onClick={() => setShowCalendarsPanel(true)}
const color = >
calendarRows.find((calendar) => calendar.id === event.calendarId)?.color ?? <Eye size={14} />
DEFAULT_COLOR; Cals
return { </button>
id: event.id, <button type="button" className="btn btn-primary btn-sm" onClick={() => openNewEvent()}>
title: event.title, <Plus size={14} />
start: event.startAt, New
end: event.endAt, </button>
allDay: event.allDay, </div>
backgroundColor: withAlpha(color, 0.14), )}
borderColor: color,
textColor: "var(--ink-2)", <div className="flex-1 p-4">
extendedProps: { calendarId: event.calendarId, color }, <FullCalendar
}; key={isMobile ? `mobile-${mobileView}` : `desktop-${defaultView}`}
})} plugins={[dayGridPlugin, timeGridPlugin, interactionPlugin, listPlugin]}
eventClassNames={(arg) => { initialView={isMobile ? MOBILE_VIEW_MAP[mobileView] : VIEW_MAP[defaultView]}
const id = String(arg.event.extendedProps["calendarId"] ?? ""); headerToolbar={
return id ? [`fc-cal-${id.slice(0, 8)}`] : []; isMobile
}} ? { left: "prev,next", center: "title", right: "today" }
height="auto" : {
/> left: "prev,next today",
center: "title",
right: "dayGridMonth,timeGridWeek,timeGridDay",
}
}
buttonText={{ today: "Today", month: "Month", week: "Week", day: "Day", list: "List" }}
dayHeaderFormat={{ weekday: "short" }}
selectable={!isMobile}
editable={!isMobile}
eventResizableFromStart={!isMobile}
select={handleDateSelect}
eventClick={openExistingEvent}
eventDrop={moveEvent}
eventResize={moveEvent}
events={fcEvents}
eventClassNames={(arg) => {
const id = String(arg.event.extendedProps["calendarId"] ?? "");
return id ? [`fc-cal-${id.slice(0, 8)}`] : [];
}}
height="auto"
/>
</div>
</section> </section>
{/* Mobile: calendars bottom sheet */}
{isMobile && showCalendarsPanel && (
<div
className="fixed inset-0 z-[45] bg-black/40"
onClick={() => setShowCalendarsPanel(false)}
>
<div
className="absolute inset-x-0 overflow-auto rounded-t-[var(--r-xl)]"
style={{
bottom: "var(--cal-nav-h)",
maxHeight: "72dvh",
background: "var(--card)",
paddingBottom: "env(safe-area-inset-bottom)",
}}
onClick={(e) => e.stopPropagation()}
>
<div
className="flex items-center justify-between border-b p-4"
style={{ borderColor: "var(--hair)" }}
>
<h3 className="serif text-[16px] font-medium">Calendars</h3>
<button
type="button"
className="btn btn-ghost btn-icon"
aria-label="Close calendars panel"
onClick={() => setShowCalendarsPanel(false)}
>
<X size={16} />
</button>
</div>
<div className="p-4">{calendarsPanelContent}</div>
</div>
</div>
)}
{/* Event form — centered modal on desktop, bottom sheet on mobile */}
{selectedEvent && ( {selectedEvent && (
<div className="fixed inset-0 z-50 grid place-items-center bg-black/20 p-4"> <div
<div className="w-full max-w-lg rounded-lg bg-popover p-4 text-popover-foreground shadow-lg"> className="fixed inset-0 z-50 flex bg-black/20"
style={
isMobile
? { alignItems: "flex-end" }
: { alignItems: "center", justifyContent: "center" }
}
onClick={(e) => {
if (e.target === e.currentTarget) setSelectedEvent(null);
}}
>
<div
className="overflow-auto bg-popover text-popover-foreground shadow-lg"
style={{
borderRadius: isMobile ? "var(--r-xl) var(--r-xl) 0 0" : "var(--r-lg)",
width: isMobile ? "100%" : undefined,
maxWidth: isMobile ? undefined : "512px",
maxHeight: "90dvh",
padding: "1rem",
paddingBottom: isMobile ? "calc(1rem + env(safe-area-inset-bottom))" : "1rem",
}}
>
<div className="mb-4 flex items-center justify-between"> <div className="mb-4 flex items-center justify-between">
<h2 className="text-lg font-semibold"> <h2 className="text-lg font-semibold">
{selectedEvent.id ? "Edit event" : "New event"} {selectedEvent.id ? "Edit event" : "New event"}
</h2> </h2>
<Button size="icon-sm" variant="ghost" onClick={() => setSelectedEvent(null)}> <Button size="icon-sm" variant="ghost" onClick={() => setSelectedEvent(null)}>
<span aria-hidden>×</span> <X size={16} />
<span className="sr-only">Close</span> <span className="sr-only">Close</span>
</Button> </Button>
</div> </div>
<div className="grid gap-3"> {eventFormContent}
<Label htmlFor="event-title">Title</Label>
<Input
id="event-title"
value={selectedEvent.title}
onChange={(event) =>
setSelectedEvent({ ...selectedEvent, title: event.target.value })
}
/>
<Label htmlFor="event-calendar">Calendar</Label>
<Select
value={selectedEvent.calendarId}
onValueChange={(value) =>
setSelectedEvent({ ...selectedEvent, calendarId: value ?? "" })
}
>
<SelectTrigger id="event-calendar">
<SelectValue>
{calendarRows.find((c) => c.id === selectedEvent.calendarId)?.name ??
"Select a calendar"}
</SelectValue>
</SelectTrigger>
<SelectContent>
{calendarRows.map((calendar) => (
<SelectItem key={calendar.id} value={calendar.id}>
{calendar.name}
</SelectItem>
))}
</SelectContent>
</Select>
<div className="grid gap-3 sm:grid-cols-2">
<div className="space-y-1.5">
<Label htmlFor="event-start">Start</Label>
<Input
id="event-start"
type="datetime-local"
value={selectedEvent.startAt}
onChange={(event) =>
setSelectedEvent({ ...selectedEvent, startAt: event.target.value })
}
/>
</div>
<div className="space-y-1.5">
<Label htmlFor="event-end">End</Label>
<Input
id="event-end"
type="datetime-local"
value={selectedEvent.endAt}
onChange={(event) =>
setSelectedEvent({ ...selectedEvent, endAt: event.target.value })
}
/>
</div>
</div>
<Label htmlFor="event-location">Location</Label>
<Input
id="event-location"
value={selectedEvent.location}
onChange={(event) =>
setSelectedEvent({ ...selectedEvent, location: event.target.value })
}
/>
<Label htmlFor="event-notes">Notes</Label>
<textarea
id="event-notes"
className="min-h-20 rounded-lg border border-input bg-transparent px-2.5 py-2 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50"
value={selectedEvent.notes}
onChange={(event) =>
setSelectedEvent({ ...selectedEvent, notes: event.target.value })
}
/>
{!selectedEvent.id && (
<label className="flex items-center gap-2 text-sm">
<input
type="checkbox"
className="size-4 cursor-pointer"
checked={selectedEvent.remindMinutesBefore !== null}
onChange={(e) =>
setSelectedEvent({
...selectedEvent,
remindMinutesBefore: e.target.checked ? 30 : null,
})
}
/>
Remind me 30 min before
</label>
)}
<div className="flex items-center justify-between gap-2 pt-2">
<div className="flex gap-2">
{selectedEvent.id && (
<Button variant="destructive" onClick={removeSelectedEvent}>
Delete event
</Button>
)}
</div>
<div className="flex gap-2">
{selectedEvent.id && (
<ShareButton entityType="calendar.event" entityId={selectedEvent.id} />
)}
<Button onClick={saveSelectedEvent} disabled={!selectedEvent.title || isPending}>
Save event
</Button>
</div>
</div>
</div>
</div> </div>
</div> </div>
)} )}
+131 -46
View File
@@ -194,57 +194,142 @@ function ListItemRow({
onCommit: () => void; onCommit: () => void;
onRemove: () => void; onRemove: () => void;
}) { }) {
const swipeStart = useRef<number | null>(null); const swipeOrigin = useRef<{ x: number; y: number } | null>(null);
const isScrolling = useRef(false);
const [swipeX, setSwipeX] = useState(0);
const THRESHOLD = 80; // px to commit the swipe action
const MAX_SWIPE = 100; // px maximum visual displacement
function handlePointerDown(e: React.PointerEvent<HTMLDivElement>) {
e.currentTarget.setPointerCapture(e.pointerId);
swipeOrigin.current = { x: e.clientX, y: e.clientY };
isScrolling.current = false;
setSwipeX(0);
}
function handlePointerMove(e: React.PointerEvent<HTMLDivElement>) {
if (!swipeOrigin.current) return;
const dx = e.clientX - swipeOrigin.current.x;
const dy = Math.abs(e.clientY - swipeOrigin.current.y);
// If the gesture is primarily vertical, treat as scroll and abort swipe.
if (!isScrolling.current && dy > Math.abs(dx) && dy > 8) {
isScrolling.current = true;
setSwipeX(0);
return;
}
if (isScrolling.current) return;
setSwipeX(Math.max(-MAX_SWIPE, Math.min(MAX_SWIPE, dx)));
}
function handlePointerUp(e: React.PointerEvent<HTMLDivElement>) {
if (swipeOrigin.current && !isScrolling.current) {
const dx = e.clientX - swipeOrigin.current.x;
if (dx > THRESHOLD) onToggle(!item.done); // right → complete / uncomplete
if (dx < -THRESHOLD) onRemove(); // left → delete
}
swipeOrigin.current = null;
setSwipeX(0);
}
function handlePointerCancel() {
swipeOrigin.current = null;
setSwipeX(0);
}
// Background tint that deepens as the swipe approaches the threshold.
const swipeProgress = Math.abs(swipeX) / MAX_SWIPE;
const swipeBg =
swipeX > 16
? `color-mix(in oklab, var(--ok) ${swipeProgress * 55}%, var(--card))`
: swipeX < -16
? `color-mix(in oklab, var(--bad) ${swipeProgress * 55}%, var(--card))`
: undefined;
return ( return (
<div <div
className={`list-row ${item.done ? "checked" : ""} group/row`} className="relative overflow-hidden border-b-[0.5px] last:border-b-0 group/row"
onPointerDown={(event) => { style={{ borderColor: "var(--hair)", background: swipeBg, touchAction: "pan-y" }}
swipeStart.current = event.clientX; onPointerDown={handlePointerDown}
}} onPointerMove={handlePointerMove}
onPointerUp={(event) => { onPointerUp={handlePointerUp}
const start = swipeStart.current; onPointerCancel={handlePointerCancel}
if (start !== null && event.clientX - start < -60) onRemove();
swipeStart.current = null;
}}
> >
<button {/* Swipe affordance icons revealed behind the sliding content */}
type="button" <div
aria-label={`Complete ${item.text}`} className="absolute inset-y-0 left-3 flex items-center"
aria-pressed={item.done} aria-hidden
className={`checkbox ${item.done ? "on" : ""}`} style={{ opacity: Math.max(0, swipeX - 16) / (MAX_SWIPE - 16), color: "var(--ok)" }}
onClick={() => onToggle(!item.done)}
> >
{item.done && ( <svg
<svg width="18"
width="12" height="18"
height="12" viewBox="0 0 24 24"
viewBox="0 0 24 24" fill="none"
fill="none" stroke="currentColor"
stroke="white" strokeWidth="2.4"
strokeWidth="2.4" strokeLinecap="round"
strokeLinecap="round" strokeLinejoin="round"
strokeLinejoin="round" >
> <path d="M5 12l5 5L20 7" />
<path d="M5 12l5 5L20 7" /> </svg>
</svg> </div>
)} <div
</button> className="absolute inset-y-0 right-3 flex items-center"
<Input aria-hidden
aria-label={`${item.text} text`} style={{ opacity: Math.max(0, -swipeX - 16) / (MAX_SWIPE - 16), color: "var(--bad)" }}
className="!border-0 !bg-transparent !shadow-none focus-visible:!ring-0 row-text flex-1 px-0 h-7 text-[13.5px]"
value={item.text}
onChange={(event) => onEdit(event.target.value)}
onBlur={onCommit}
/>
<Button
size="icon-sm"
variant="ghost"
aria-label={`Delete ${item.text}`}
onClick={onRemove}
className="opacity-0 group-hover/row:opacity-100 transition-opacity"
> >
<Trash2 className="size-3.5" /> <Trash2 size={16} />
</Button> </div>
{/* Sliding content row */}
<div
className={`flex items-center gap-3 px-[14px] py-[10px] hover:bg-[var(--shade)] ${item.done ? "checked" : ""}`}
style={{
transform: `translateX(${swipeX}px)`,
transition: swipeX === 0 ? "transform 0.22s ease-out" : "none",
}}
>
<button
type="button"
aria-label={`Complete ${item.text}`}
aria-pressed={item.done}
className={`checkbox ${item.done ? "on" : ""}`}
onClick={() => onToggle(!item.done)}
>
{item.done && (
<svg
width="12"
height="12"
viewBox="0 0 24 24"
fill="none"
stroke="white"
strokeWidth="2.4"
strokeLinecap="round"
strokeLinejoin="round"
>
<path d="M5 12l5 5L20 7" />
</svg>
)}
</button>
<Input
aria-label={`${item.text} text`}
className={`!border-0 !bg-transparent !shadow-none focus-visible:!ring-0 row-text flex-1 px-0 h-7 text-[13.5px] ${item.done ? "line-through text-[var(--ink-faint)]" : ""}`}
value={item.text}
onChange={(event) => onEdit(event.target.value)}
onBlur={onCommit}
/>
{/* Always visible on touch (list-row-delete makes opacity-0 override to 1 on mobile) */}
<Button
size="icon-sm"
variant="ghost"
aria-label={`Delete ${item.text}`}
onClick={onRemove}
className="list-row-delete opacity-0 group-hover/row:opacity-100 transition-opacity"
>
<Trash2 className="size-3.5" />
</Button>
</div>
</div> </div>
); );
} }