a band lists its blocks, and selection is the URL
A fourth level under the open band only — a page of six bands with four blocks each is thirty rows, and the nav stops being somewhere you can find anything. Blocks are named by the same list the picker offers, so a thing is called the same word wherever it appears. Clicking a block in the PAGE now writes that address too, rather than calling the handler directly. Both ways of picking a block are the same act, so neither can disagree with the other about what is selected — and closing it is the band row. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+21
-6
@@ -32,16 +32,24 @@ export const MOUNT = '/fofos-admin';
|
||||
* redirects, so the address bar ends up saying where you are. `section` is still defaulted, so
|
||||
* everything that only wants to draw a highlight has one answer rather than a branch.
|
||||
*/
|
||||
export const useNav = (): { section: SectionKey; item: string | null; part: string | null; atIndex: boolean } => {
|
||||
export const useNav = (): {
|
||||
section: SectionKey;
|
||||
item: string | null;
|
||||
part: string | null;
|
||||
piece: string | null;
|
||||
atIndex: boolean;
|
||||
} => {
|
||||
const { pathname } = useLocation();
|
||||
const rest = pathname.startsWith(MOUNT) ? pathname.slice(MOUNT.length) : '';
|
||||
const [first = '', second = '', third = ''] = rest.replace(/^\//, '').split('/');
|
||||
const [first = '', second = '', third = '', fourth = ''] = rest.replace(/^\//, '').split('/');
|
||||
return {
|
||||
// An unknown segment falls back rather than 404s: the URL is a thing people type and edit.
|
||||
section: isSectionKey(first) ? first : DEFAULT_SECTION,
|
||||
item: second ? decodeURIComponent(second) : null,
|
||||
/** Something inside the item — a band of the open page. Nothing else uses a third segment yet. */
|
||||
/** Something inside the item — a band of the open page. */
|
||||
part: third ? decodeURIComponent(third) : null,
|
||||
/** Something inside THAT — a block in the band. This is what selection writes. */
|
||||
piece: fourth ? decodeURIComponent(fourth) : null,
|
||||
atIndex: first === '',
|
||||
};
|
||||
};
|
||||
@@ -53,8 +61,15 @@ export const useNav = (): { section: SectionKey; item: string | null; part: stri
|
||||
* you are looking at the Layout preview; carrying it into Galleries would be state from one screen
|
||||
* deciding something on another. A panel that wants a parameter to survive says so at its own link.
|
||||
*/
|
||||
export const href = (section: SectionKey, item?: string | null, part?: string | null): string => {
|
||||
export const href = (
|
||||
section: SectionKey,
|
||||
item?: string | null,
|
||||
part?: string | null,
|
||||
piece?: string | null,
|
||||
): string => {
|
||||
if (!item) return `${MOUNT}/${section}`;
|
||||
const base = `${MOUNT}/${section}/${encodeURIComponent(item)}`;
|
||||
return part ? `${base}/${encodeURIComponent(part)}` : base;
|
||||
let path = `${MOUNT}/${section}/${encodeURIComponent(item)}`;
|
||||
if (!part) return path;
|
||||
path += `/${encodeURIComponent(part)}`;
|
||||
return piece ? `${path}/${encodeURIComponent(piece)}` : path;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user