mirror of
https://github.com/priyanshujain/margin-calendar.git
synced 2026-10-02 19:17:04 +00:00
Tauri 2, React 19 and zustand on the front, Rust behind. Rust owns auth, all HTTP to Google, the SQLite store, the sync loop, recurrence expansion and timezone maths. TypeScript owns rendering and never talks to Google, which keeps the content security policy locked to ipc:. Week, day and agenda views, and no month view: it would be a second layout engine, and the fit and fold logic that makes a day fit the window without scrolling is the whole point of the app. Runs on macOS, Linux, Android and iOS. Desktop catches Google's OAuth redirect on a loopback port. A phone cannot, and Google rejects loopback for mobile client types anyway, so it redirects to a custom URI scheme and needs its own public OAuth clients, which docs/mobile.md covers. Refresh tokens are sealed with XChaCha20-Poly1305 in the app data directory on every platform, with no OS credential store in the picture. On a phone the chrome becomes a top bar and a bottom tab bar, overlays become sheets, hover affordances become taps, and dragging out an event waits for a long press. Navigation moves one day at a time everywhere, a swipe included.
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
// The seam between "something was clicked" and "the details card is on screen".
|
|
//
|
|
// The grid and the agenda call `open` with the instance key and the on-screen rectangle of the
|
|
// thing that was clicked. The details card positions itself against that rectangle. Neither side
|
|
// imports the other, which is what lets them be built in parallel.
|
|
|
|
import { create } from "zustand";
|
|
import type { InstanceKey } from "../ipc";
|
|
|
|
/** Where the clicked block is, in viewport coordinates. A DOMRect satisfies this. */
|
|
export interface AnchorRect {
|
|
top: number;
|
|
left: number;
|
|
width: number;
|
|
height: number;
|
|
}
|
|
|
|
interface DetailsState {
|
|
key: InstanceKey | null;
|
|
anchor: AnchorRect | null;
|
|
open: (key: InstanceKey, anchor: AnchorRect) => void;
|
|
close: () => void;
|
|
}
|
|
|
|
export const useDetails = create<DetailsState>((set) => ({
|
|
key: null,
|
|
anchor: null,
|
|
open: (key, anchor) =>
|
|
set({ key, anchor: { top: anchor.top, left: anchor.left, width: anchor.width, height: anchor.height } }),
|
|
close: () => set({ key: null, anchor: null }),
|
|
}));
|
|
|
|
/** Imperative form, for a click handler that has an element to measure. */
|
|
export function openDetailsFor(key: InstanceKey, element: Element | null): void {
|
|
const rect = element?.getBoundingClientRect();
|
|
useDetails.getState().open(
|
|
key,
|
|
rect ?? { top: window.innerHeight / 2, left: window.innerWidth / 2, width: 0, height: 0 },
|
|
);
|
|
}
|