Skip to content
Myr

context.ts

This file

Path

apps/web/src/features/shared/shell/context.ts

49 lines · 1.5 KiB · TypeScript

Last changed by

Merge redesign into mainoscabrielbefore adoptioncaedd21

History of this file

Take it

Put every page in the Control room shell: rail, bars, workspace, router links, keys, head, error and pending statesoscabrielbefore adoptionddbd51e

lines 1–5why, one step back
1import type { ProjectListing } from "@repo/protocol/domain/front-page";
2import { ProjectName } from "@repo/protocol/ids";3import { useMatch } from "@tanstack/react-router";4import { Schema } from "effect";5import { createContext, useContext } from "react";

Merge redesign into mainoscabrielbefore adoptioncaedd21

line 6why, one step back
6import type { ComponentType, ReactNode } from "react";

Put every page in the Control room shell: rail, bars, workspace, router links, keys, head, error and pending statesoscabrielbefore adoptionddbd51e

line 7why, one step back
7

Merge redesign into mainoscabrielbefore adoptioncaedd21

line 8why, one step back
8export type Overlay = "keys" | "menu" | "projects";

Put every page in the Control room shell: rail, bars, workspace, router links, keys, head, error and pending statesoscabrielbefore adoptionddbd51e

lines 9–25why, one step back
9
10export interface Shell {11 readonly open: (overlay: Overlay) => void;12}1314export const ShellContext = createContext<Shell>({15 open: () => {16 // Outside the shell (a view's own test) there is nothing to open.17 },18});1920export const useShell = (): Shell => useContext(ShellContext);2122const isProjectName = Schema.is(ProjectName);2324export const useCurrentProject = (): ProjectName | undefined =>25 useMatch({

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

line 26why, one step back
26 from: "/$owner/$project",

Put every page in the Control room shell: rail, bars, workspace, router links, keys, head, error and pending statesoscabrielbefore adoptionddbd51e

lines 27–31why, one step back
27 select: ({ params }) =>
28 isProjectName(params.project) ? params.project : undefined,29 shouldThrow: false,30 });31

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 32–37why, one step back
32/**
33 * What the shell shows but never reads itself, so its pieces stay views: the34 * root hands it the inbox's count (read lazily, once a signed-in reader's35 * page is up) and a reader of the project list (mounted only while the36 * search is open).37 */

Put every page in the Control room shell: rail, bars, workspace, router links, keys, head, error and pending statesoscabrielbefore adoptionddbd51e

line 38why, one step back
38export interface ShellReads {

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 39–44why, one step back
39 readonly inboxCount?: ReactNode;
40 readonly ReadProjects?: ComponentType<{41 readonly children: (42 listed: readonly ProjectListing[] | undefined43 ) => ReactNode;44 }>;

Put every page in the Control room shell: rail, bars, workspace, router links, keys, head, error and pending statesoscabrielbefore adoptionddbd51e

lines 45–48why, one step back
45}
4647export const ShellReadsContext = createContext<ShellReads>({});48

Merge redesign into mainoscabrielbefore adoptioncaedd21

line 49why, one step back
49export const useShellReads = (): ShellReads => useContext(ShellReadsContext);