Settings page

Settings on the grey page surface: a 240 px menu of sections, and the chosen section beside it under its own title.

Screen

The live layout, built only from the library's exports on made-up records. It is a page of its own in the frame, so it lays out, scrolls and opens its panels as it would in an app.

View full screen

What to try

  • Profile has a Save: change a field and Discard and Save changes wake up. Clear Last name and save to see the error.
  • Notifications has no Save: a switch takes effect as it is flipped, and the page says so.
  • The header marks no page here, as Settings is reached from the person's menu.

Source

Each file as written. Copy the screen's own file first; the shell and the sample data are shared by every screen.

SettingsPage.tsx

import { Bell, UserRound, UsersRound } from "lucide-react";
import { useId, useState, type SubmitEvent } from "react";
import {
  Avatar,
  Badge,
  Button,
  Card,
  Field,
  Input,
  List,
  ListItem,
  ListSubheader,
  ScrollArea,
  SwitchRow,
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
  toast,
} from "@leap-crm/design-system";
import { AppShell } from "./AppShell";
import { me, people } from "./fixtures";

const sections = [
  {
    id: "profile",
    group: "Your account",
    label: "Profile",
    icon: <UserRound />,
    description: "Your name and how people reach you.",
  },
  {
    id: "notifications",
    group: "Your account",
    label: "Notifications",
    icon: <Bell />,
    description: "What you're emailed about. Changes save as you make them.",
  },
  {
    id: "team",
    group: "Workspace",
    label: "Team",
    icon: <UsersRound />,
    description: "Everyone who can see and change records.",
  },
] as const;

type SectionId = (typeof sections)[number]["id"];
const groups = ["Your account", "Workspace"] as const;

const phonePattern = /^\+?[\d ]{8,15}$/;
type ProfileValues = { firstName: string; lastName: string; phone: string };

const saved: ProfileValues = {
  firstName: "Ada",
  lastName: "Hartley",
  phone: "0412 345 678",
};

/** The profile form: a card with who it is across the top, the fields, and Save on its bottom edge. */
function Profile({
  stored,
  onSave,
}: {
  /** The profile as last saved. */
  stored: ProfileValues;
  onSave: (values: ProfileValues) => void;
}) {
  const form = useId();
  const [values, setValues] = useState(stored);
  const [submitted, setSubmitted] = useState(false);
  const set = (patch: Partial<ProfileValues>) =>
    setValues(current => ({ ...current, ...patch }));
  const dirty =
    values.firstName !== stored.firstName ||
    values.lastName !== stored.lastName ||
    values.phone !== stored.phone;
  const errors = {
    firstName:
      values.firstName.trim() === "" ? "Please enter a first name" : undefined,
    lastName:
      values.lastName.trim() === "" ? "Please enter a last name" : undefined,
    phone:
      values.phone !== "" && !phonePattern.test(values.phone)
        ? "Please enter a valid phone number"
        : undefined,
  };
  const shown: Partial<typeof errors> = submitted ? errors : {};

  const submit = (event: SubmitEvent<HTMLFormElement>) => {
    event.preventDefault();
    setSubmitted(true);
    if (Object.values(errors).some(Boolean)) return;
    onSave(values);
    setSubmitted(false);
    toast.success({ title: "Profile saved" });
  };

  return (
    <Card className="p-0">
      <div className="border-neutral-divider flex items-center gap-4 border-b px-6 py-4">
        <Avatar
          size="2xl"
          person="staff"
          name={me.name}
          initials={me.initials}
        />
        <div className="flex min-w-0 flex-col gap-0.5">
          <span className="text-lead font-book text-neutral-text">
            {`${stored.firstName} ${stored.lastName}`.trim()}
          </span>
          <span className="text-body text-neutral-text-muted">
            ada@example.com
          </span>
        </div>
      </div>
      <form
        id={form}
        noValidate
        onSubmit={submit}
        className="grid gap-x-8 gap-y-6 px-6 py-6 md:grid-cols-2"
      >
        <Field label="First name" error={shown.firstName}>
          <Input
            value={values.firstName}
            onValueChange={firstName => set({ firstName })}
            autoComplete="off"
            required
          />
        </Field>
        <Field label="Last name" error={shown.lastName}>
          <Input
            value={values.lastName}
            onValueChange={lastName => set({ lastName })}
            autoComplete="off"
            required
          />
        </Field>
        <Field label="Email" hint="Your sign-in. Ask an admin to change it.">
          <Input value="ada@example.com" readOnly />
        </Field>
        <Field label="Phone" optional error={shown.phone}>
          <Input
            type="tel"
            value={values.phone}
            onValueChange={phone => set({ phone })}
            autoComplete="off"
          />
        </Field>
      </form>
      <div className="border-neutral-divider flex justify-end gap-2 border-t px-6 py-3">
        <Button
          intent="outline"
          disabled={!dirty}
          onClick={() => {
            setValues(stored);
            setSubmitted(false);
          }}
        >
          Discard
        </Button>
        <Button type="submit" form={form} disabled={!dirty}>
          Save changes
        </Button>
      </div>
    </Card>
  );
}

const emails = [
  {
    id: "assigned",
    label: "Email me when a record is assigned to me",
    description: "You still see it in Notifications either way.",
  },
  {
    id: "due",
    label: "Email me the day before a record is due",
    description: "One email each morning, listing what is due tomorrow.",
  },
  {
    id: "digest",
    label: "Send me a weekly summary",
    description: "Every Monday: what was opened and closed last week.",
  },
] as const;

function Notifications({
  on,
  onChange,
}: {
  /** The ids of the emails that are switched on. */
  on: string[];
  onChange: (on: string[]) => void;
}) {
  return (
    <Card className="flex flex-col gap-4">
      {emails.map(email => (
        <SwitchRow
          key={email.id}
          label={email.label}
          description={email.description}
          checked={on.includes(email.id)}
          onCheckedChange={checked =>
            onChange(
              checked ? [...on, email.id] : on.filter(id => id !== email.id),
            )
          }
        />
      ))}
    </Card>
  );
}

function Team() {
  return (
    <Table>
      <TableHeader>
        <TableRow>
          <TableHead>Name</TableHead>
          <TableHead>Role</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        {people.map((person, index) => (
          <TableRow key={person.id}>
            <TableCell>
              <span className="flex items-center gap-2">
                <Avatar
                  size="xs"
                  person="staff"
                  name={person.name}
                  initials={person.initials}
                />
                {person.name}
              </span>
            </TableCell>
            <TableCell>
              <Badge size="sm" tone={index === 0 ? "info" : "default"}>
                {index === 0 ? "Admin" : "Member"}
              </Badge>
            </TableCell>
          </TableRow>
        ))}
      </TableBody>
    </Table>
  );
}

/**
 * A settings page, laid out as the CRM's is: on the grey page surface, a
 * 240 px menu of sections on the left, grouped under quiet labels, and the
 * chosen section beside it under its own title and one line about it. The
 * two sit together in the middle of a wide window, the page scrolls as one,
 * and the menu stays in view while it does. The header marks no page: Settings
 * is reached from the person's menu.
 */
function SettingsPage() {
  const [current, setCurrent] = useState<SectionId>("profile");
  // What has been saved lives here, above the sections, so it is still there
  // when someone leaves a section and comes back.
  const [profile, setProfile] = useState(saved);
  const [emailsOn, setEmailsOn] = useState(["assigned", "due"]);
  const section =
    sections.find(candidate => candidate.id === current) ?? sections[0];
  return (
    <AppShell unread={3}>
      <ScrollArea className="bg-neutral-surface-subtle min-h-0 flex-1">
        <div className="mx-auto flex w-full max-w-7xl flex-col md:flex-row md:items-start">
          <nav
            aria-label="Settings"
            className="flex shrink-0 flex-col gap-3 px-3 pt-6 md:sticky md:top-0 md:w-60 md:pb-6"
          >
            {groups.map(group => (
              <List key={group} aria-label={group}>
                <ListSubheader>{group}</ListSubheader>
                {sections
                  .filter(item => item.group === group)
                  .map(item => (
                    <ListItem
                      key={item.id}
                      leading={item.icon}
                      primary={item.label}
                      current={item.id === current}
                      onClick={() => setCurrent(item.id)}
                    />
                  ))}
              </List>
            ))}
          </nav>
          <div className="flex min-w-0 flex-1 flex-col gap-6 px-4 pt-6 pb-8 md:px-8">
            <header className="flex flex-col gap-1">
              <h1 className="text-title font-book text-neutral-text m-0">
                {section.label}
              </h1>
              <p className="text-neutral-text-secondary m-0 text-base">
                {section.description}
              </p>
            </header>
            {section.id === "profile" && (
              <Profile stored={profile} onSave={setProfile} />
            )}
            {section.id === "notifications" && (
              <Notifications on={emailsOn} onChange={setEmailsOn} />
            )}
            {section.id === "team" && <Team />}
          </div>
        </div>
      </ScrollArea>
    </AppShell>
  );
}

export { SettingsPage };

AppShell.tsx

import {
  Bell,
  ChartLine,
  LayoutDashboard,
  Plus,
  Search,
  Table2,
} from "lucide-react";
import type { ReactNode } from "react";
import {
  AppHeader,
  Avatar,
  HeaderIconButton,
  HeaderNavLink,
} from "@leap-crm/design-system";
import { me } from "./fixtures";

const pages = [
  { label: "Overview", icon: <LayoutDashboard /> },
  { label: "Records", icon: <Table2 /> },
  { label: "Reports", icon: <ChartLine /> },
] as const;

type PageName = (typeof pages)[number]["label"];

/**
 * The frame every page of the app sits in, as the CRM lays it out: the 48 px
 * navy header across the top, and one page under it that fills the rest of
 * the window and owns its own scrolling. There is no side menu and no page
 * chrome between the header and the page.
 *
 * The header holds the main pages on the left and, on the right, New, Search,
 * Notifications and the person signed in. New things are made from the header,
 * so a page's own toolbar carries no "New" button.
 *
 * In an app, pass your router's link to each HeaderNavLink's `render`.
 */
function AppShell({
  page,
  unread = 0,
  onNew,
  creating = false,
  children,
}: {
  /** The page you're on, marked in the header. Leave it out on a page the header doesn't list, like Settings. */
  page?: PageName;
  /** Unread notifications, on the bell. */
  unread?: number;
  /** Runs when New is pressed. */
  onNew?: () => void;
  /** Whether what New opens is open now. */
  creating?: boolean;
  children: ReactNode;
}) {
  return (
    <div className="bg-neutral-surface flex h-dvh flex-col overflow-hidden">
      <AppHeader
        nav={pages.map(item => (
          <HeaderNavLink
            key={item.label}
            href="#"
            icon={item.icon}
            active={item.label === page}
            onClick={event => event.preventDefault()}
          >
            {item.label}
          </HeaderNavLink>
        ))}
        actions={
          <>
            <HeaderIconButton
              icon={<Plus />}
              aria-label="New record"
              open={creating}
              onClick={onNew}
            />
            <HeaderIconButton icon={<Search />} aria-label="Search" />
            <HeaderIconButton
              icon={<Bell />}
              aria-label="Notifications"
              count={unread}
            />
            <Avatar
              size="lg"
              person="staff"
              name={me.name}
              initials={me.initials}
            />
          </>
        }
      />
      <main className="flex min-h-0 flex-1 flex-col overflow-hidden">
        {children}
      </main>
    </div>
  );
}

export { AppShell };
export type { PageName };

fixtures.ts

// Sample data for the example screens: plainly made-up records, so a screen
// reads as a layout to copy and never as one of the CRM's own pages.

type Person = { id: string; name: string; initials: string };

const people = [
  { id: "ah", name: "Ada Hartley", initials: "AH" },
  { id: "bo", name: "Ben Okafor", initials: "BO" },
  { id: "cm", name: "Chloe Moreau", initials: "CM" },
] as const satisfies Person[];

/** The person signed in: "Mine" lists their records. */
const me: Person = people[0];

const statuses = {
  active: { label: "Active", tone: "success" },
  review: { label: "In review", tone: "warning" },
  closed: { label: "Closed", tone: "default" },
} as const;

type StatusId = keyof typeof statuses;

const categories = ["Agreement", "Report", "Request", "Template"] as const;

type Category = (typeof categories)[number];

type SampleRecord = {
  id: string;
  name: string;
  category: Category;
  status: StatusId;
  owner: Person;
  /** Who to write to about it, when someone is named. */
  email: string | null;
  /** An ISO date. */
  due: string | null;
  created: string;
  updated: string;
};

const [ada, ben, chloe] = people;

const records: SampleRecord[] = [
  {
    id: "r-1042",
    name: "Supplier agreement renewal",
    category: "Agreement",
    status: "active",
    owner: ada,
    email: "accounts@northwind.example",
    due: "2026-12-11",
    created: "3 Nov 2026",
    updated: "2 hours ago",
  },
  {
    id: "r-1041",
    name: "Quarterly activity report",
    category: "Report",
    status: "review",
    owner: ben,
    email: null,
    due: "2026-12-01",
    created: "2 Nov 2026",
    updated: "Yesterday",
  },
  {
    id: "r-1040",
    name: "Access request for the shared archive and its historical exports",
    category: "Request",
    status: "active",
    owner: chloe,
    email: "it@harbourside.example",
    due: null,
    created: "30 Oct 2026",
    updated: "Yesterday",
  },
  {
    id: "r-1039",
    name: "Onboarding checklist",
    category: "Template",
    status: "closed",
    owner: ada,
    email: null,
    due: null,
    created: "28 Oct 2026",
    updated: "3 days ago",
  },
  {
    id: "r-1038",
    name: "Office lease variation",
    category: "Agreement",
    status: "review",
    owner: ben,
    email: "leasing@quayside.example",
    due: "2026-12-18",
    created: "24 Oct 2026",
    updated: "4 days ago",
  },
  {
    id: "r-1037",
    name: "Annual compliance summary",
    category: "Report",
    status: "active",
    owner: ada,
    email: null,
    due: "2027-01-15",
    created: "21 Oct 2026",
    updated: "5 days ago",
  },
  {
    id: "r-1036",
    name: "Equipment purchase request",
    category: "Request",
    status: "closed",
    owner: chloe,
    email: "orders@fieldworks.example",
    due: null,
    created: "17 Oct 2026",
    updated: "1 week ago",
  },
  {
    id: "r-1035",
    name: "Welcome letter",
    category: "Template",
    status: "active",
    owner: ben,
    email: null,
    due: null,
    created: "14 Oct 2026",
    updated: "1 week ago",
  },
  {
    id: "r-1034",
    name: "Service agreement",
    category: "Agreement",
    status: "closed",
    owner: chloe,
    email: "hello@brightline.example",
    due: null,
    created: "9 Oct 2026",
    updated: "2 weeks ago",
  },
  {
    id: "r-1033",
    name: "Monthly usage report",
    category: "Report",
    status: "active",
    owner: ada,
    email: null,
    due: "2026-12-04",
    created: "6 Oct 2026",
    updated: "2 weeks ago",
  },
];

type ActivityKind = "created" | "status" | "note" | "owner";

/** What happened to a record, newest first. */
const activity: {
  id: string;
  kind: ActivityKind;
  what: string;
  who: string;
  when: string;
}[] = [
  {
    id: "a4",
    kind: "note",
    what: "Note added",
    who: "Ada Hartley",
    when: "2 hours ago",
  },
  {
    id: "a3",
    kind: "status",
    what: "Status changed to Active",
    who: "Ben Okafor",
    when: "Yesterday",
  },
  {
    id: "a2",
    kind: "owner",
    what: "Owner changed to Ada Hartley",
    who: "Chloe Moreau",
    when: "5 Nov 2026",
  },
  {
    id: "a1",
    kind: "created",
    what: "Record created",
    who: "Chloe Moreau",
    when: "3 Nov 2026",
  },
];

/** The figures on the overview page, with twelve weeks of history each. */
const stats = [
  {
    id: "open",
    title: "Open records",
    value: "128",
    trend: [96, 101, 99, 107, 111, 108, 115, 118, 116, 122, 125, 128],
  },
  {
    id: "new",
    title: "New this month",
    value: "34",
    trend: [18, 22, 19, 25, 21, 27, 24, 30, 26, 29, 31, 34],
  },
  {
    id: "closed",
    title: "Closed this month",
    value: "21",
    trend: [12, 15, 11, 16, 18, 14, 19, 17, 20, 18, 22, 21],
  },
  {
    id: "days",
    title: "Average days to close",
    value: "9",
    trend: [14, 13, 13, 12, 12, 11, 12, 10, 11, 10, 9, 9],
  },
] as const;

const upcoming = [
  {
    id: "u1",
    title: "Quarterly activity report",
    detail: "Due for review",
    when: "Tue 1 Dec",
  },
  { id: "u2", title: "Monthly usage report", detail: "Due", when: "Fri 4 Dec" },
  {
    id: "u3",
    title: "Supplier agreement renewal",
    detail: "Due",
    when: "Fri 11 Dec",
  },
  {
    id: "u4",
    title: "Office lease variation",
    detail: "Due for review",
    when: "Fri 18 Dec",
  },
] as const;

/** Today, as the screens see it: fixed, so every capture shows the same dates. */
const today = "2026-11-24";

const dateFormat = new Intl.DateTimeFormat("en-AU", {
  day: "numeric",
  month: "short",
  year: "numeric",
});

/** An ISO date as people read it, like "11 Dec 2026". */
const formatDate = (iso: string) =>
  dateFormat.format(new Date(`${iso}T00:00:00`));

export {
  activity,
  categories,
  formatDate,
  me,
  people,
  records,
  stats,
  statuses,
  today,
  upcoming,
};
export type { ActivityKind, Category, Person, SampleRecord, StatusId };