mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 11:06:06 +00:00
fd35f79c36
TestFlight feedback: on an iPhone Duo the status capsule in the top right
corner covered the trip's controls, its day chips, the map's category bar and
the first cards of every trip tab, upright and on its side. The app has
measured the capsule since 0f42b8b8a, but only the shell's own bars and page
used it, and the trip, its map and the sheets place their own controls.
- Upright, a control row in the capsule's height stands beside it and the
content starts below it: the trip's top row and day chips, the map's
category bar, the road trip's stage bar, every trip tab's first row, the
places browser, the plan timeline, docked and card sheets, the assistant,
the account menu, the image viewer's close button, the atlas search,
vacay's header and a journey's content and map controls.
- On a wide window the page gives up the capsule's side over the whole
height instead, as an iPhone on its side does for its camera: lifting each
page below the capsule cost a quarter of the height of an unfolded Duo.
The list tabs, the assistant panel and the form sheets end before it too.
- Screens whose first row is part of the page (settings, administration,
collections) are lifted until that row is below the capsule; screens that
keep clear of it by themselves (atlas, vacay, a journey) are not lifted.
- Right to left the rail stands on the capsule's side and takes it.
All of it reads the corner variables the app publishes, which are 0 on every
other device and before iOS 26, so nothing else moves. The rules for the
screens that place their own controls live in mobile/corner.css.
144 lines
5.0 KiB
TypeScript
144 lines
5.0 KiB
TypeScript
import type { LucideIcon } from 'lucide-react';
|
|
import { ChevronLeft } from 'lucide-react';
|
|
import type { ReactNode } from 'react';
|
|
|
|
export interface MSection {
|
|
id: string;
|
|
label: string;
|
|
icon: LucideIcon;
|
|
/**
|
|
* The heading the section stands under. Consecutive sections with the same
|
|
* group share one heading; a screen whose sections name none shows none.
|
|
*/
|
|
group?: string;
|
|
}
|
|
|
|
interface MSectionRowProps {
|
|
section: MSection;
|
|
active: boolean;
|
|
/** Marks the row as the page on show, for the list that stands beside the page. */
|
|
current?: boolean;
|
|
onPick: () => void;
|
|
}
|
|
|
|
/** One section of a settings-like screen, in its dropdown or in the list beside the page. */
|
|
function MSectionRow({ section, active, current = false, onPick }: MSectionRowProps) {
|
|
return (
|
|
<button
|
|
type="button"
|
|
onClick={onPick}
|
|
aria-current={current ? 'page' : undefined}
|
|
className={`flex w-full items-center gap-[10px] rounded-[11px] p-[10px] text-start text-[length:calc(13px*var(--fs-scale-body,1))] font-semibold text-m-ink outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--m-act)] ${
|
|
active ? 'bg-[color:var(--m-ic)]' : 'hover:bg-[color:var(--m-ic)]'
|
|
}`}
|
|
>
|
|
<section.icon size={15} strokeWidth={2} className="flex-none" />
|
|
<span className="min-w-0 flex-1 truncate">{section.label}</span>
|
|
</button>
|
|
);
|
|
}
|
|
|
|
/**
|
|
* The sections in order, each run of one group under its heading: the same list
|
|
* in the dropdown of a phone and in the list beside the page.
|
|
*/
|
|
export function MSectionList({
|
|
sections,
|
|
activeId,
|
|
markCurrent = false,
|
|
onPick,
|
|
}: {
|
|
sections: MSection[];
|
|
activeId: string;
|
|
/** Marks the active row as the page on show (the list beside the page). */
|
|
markCurrent?: boolean;
|
|
onPick: (id: string) => void;
|
|
}) {
|
|
return (
|
|
<>
|
|
{sections.map((section, i) => {
|
|
const heading = section.group && section.group !== sections[i - 1]?.group ? section.group : null;
|
|
return (
|
|
<div key={section.id} role="presentation">
|
|
{heading && (
|
|
<div
|
|
className={`px-[10px] pb-1 font-geist text-caption font-bold uppercase tracking-[.09em] text-m-faint ${
|
|
i === 0 ? 'pt-1' : 'pt-3'
|
|
}`}
|
|
>
|
|
{heading}
|
|
</div>
|
|
)}
|
|
<MSectionRow
|
|
section={section}
|
|
active={section.id === activeId}
|
|
current={markCurrent && section.id === activeId}
|
|
onPick={() => onPick(section.id)}
|
|
/>
|
|
</div>
|
|
);
|
|
})}
|
|
</>
|
|
);
|
|
}
|
|
|
|
/**
|
|
* The frame of a settings-like screen (settings, administration), one rule for
|
|
* both: the page column on a phone, a centred column on a wide window, and from
|
|
* the split size class the list of sections beside a page that runs to the same
|
|
* width on both screens.
|
|
*/
|
|
export const SECTION_SCREEN =
|
|
'm-corner-flow px-4 pb-[calc(var(--bottom-nav-h,84px)+16px)] pt-[var(--m-safe-top,12px)] wide:mx-auto wide:max-w-[1040px] wide:px-6 split:grid split:max-w-[1240px] split:grid-cols-[260px_minmax(0,1fr)] split:items-start split:gap-8';
|
|
|
|
interface MSectionNavProps {
|
|
title: string;
|
|
backLabel: string;
|
|
onBack: () => void;
|
|
sections: MSection[];
|
|
activeId: string;
|
|
onPick: (id: string) => void;
|
|
/**
|
|
* An action of the screen (admin: a new user), on a line of its own under the
|
|
* title, so a long title in a long language keeps the whole width.
|
|
*/
|
|
action?: ReactNode;
|
|
}
|
|
|
|
/**
|
|
* The sections of a settings-like screen (settings, administration) as a list
|
|
* of their own beside the page, the way Settings on an iPad shows them, once
|
|
* the window has room for two panes. It stays in view while the page scrolls.
|
|
* Narrower windows keep the dropdown in the screen's header.
|
|
*/
|
|
export default function MSectionNav({
|
|
title,
|
|
backLabel,
|
|
onBack,
|
|
sections,
|
|
activeId,
|
|
onPick,
|
|
action,
|
|
}: MSectionNavProps) {
|
|
return (
|
|
<nav
|
|
aria-label={title}
|
|
className="sticky top-[var(--m-safe-top,12px)] flex max-h-[calc(100dvh-var(--m-safe-top,12px)-16px)] flex-col gap-1 overflow-y-auto rounded-2xl border border-[color:var(--m-rowbr)] bg-[color:var(--m-sheet)] p-[6px] shadow-[0_16px_40px_-24px_rgba(0,0,0,.3)] [scrollbar-width:none]"
|
|
>
|
|
<div className="mb-1 flex items-center gap-2 p-[4px]">
|
|
<button
|
|
type="button"
|
|
aria-label={backLabel}
|
|
onClick={onBack}
|
|
className="flex h-[34px] w-[34px] flex-none items-center justify-center rounded-full text-m-ink outline-none hover:bg-[color:var(--m-ic)] focus-visible:ring-2 focus-visible:ring-[color:var(--m-act)]"
|
|
>
|
|
<ChevronLeft size={18} strokeWidth={2.2} className="rtl:-scale-x-100" />
|
|
</button>
|
|
<span className="min-w-0 flex-1 truncate text-subtitle font-bold text-m-ink">{title}</span>
|
|
</div>
|
|
{action && <div className="mb-1 px-[4px]">{action}</div>}
|
|
<MSectionList sections={sections} activeId={activeId} markCurrent onPick={onPick} />
|
|
</nav>
|
|
);
|
|
}
|