Skip to content
Source
Sign inSign up
fuko/trytanstackdb-v2

Mobile: guide-first layout with the app in a Try it sheet #2

Mergedfukomerged 5 commits intomain fromrefs/pull/2/headmerged by fuko

Showing 43 changed files with 220 additions and 0 deletions (loading 41).

x
0 of 43 viewed, 43 left
102 additions and 0 deletionssrc/components/app-sheet/app-sheet-store.tsAdded
View file
@@ -0,0 +1,102 @@
+import { useLocation, useRouter } from "@tanstack/react-router";
+import type { LinkOptions } from "@tanstack/react-router";
+import { useCallback, useSyncExternalStore } from "react";
+​
+import { closeSheetAction, isSheetOpen, openSheetState } from "@/lib/app-sheet-history";
+import { isOnScreen } from "@/lib/app-screen";
+​
+/**
+ * On small screens the app lives in a sheet over the guide. Whether the sheet
+ * is open is part of browser history (see `lib/app-sheet-history.ts`); this
+ * store only holds what's on top of that:
+ *
+ * - which view the sheet shows: the app, or the latency controls and request
+ * inspector over it,
+ * - the guide section it was last opened from (phase 4 watches for that
+ * section's action),
+ * - where the app was when the sheet last closed, so "Try it" can pick up
+ * there instead of starting over.
+ */
+export type AppSheetView = "app" | "network";
+​
+interface AppSheetState {
+ view: AppSheetView;
+ sectionId: string | null;
+}
+​
+let state: AppSheetState = { view: "app", sectionId: null };