Lower semantic rosters in browser clients
This commit is contained in:
parent
91277a6845
commit
698f3672e0
5 changed files with 139 additions and 3 deletions
|
|
@ -48,6 +48,13 @@ export interface EveCommandIntent {
|
|||
clientId: string;
|
||||
}
|
||||
|
||||
export interface EveSemanticListItem {
|
||||
label: string;
|
||||
status: string;
|
||||
detail: string;
|
||||
badges: string[];
|
||||
}
|
||||
|
||||
export interface EveSurfaceWorldInteraction {
|
||||
commandBoundary?: string;
|
||||
receiptSchema?: string;
|
||||
|
|
@ -450,15 +457,35 @@ export function renderEveComponent(
|
|||
return pane;
|
||||
}
|
||||
|
||||
if (kind === "list") {
|
||||
if (kind === "list" || kind.endsWith(".roster")) {
|
||||
const list = el("section", "cultui-list");
|
||||
assignId(list, node);
|
||||
list.dataset.componentKind = kind;
|
||||
const title = stringProp(props.title, "");
|
||||
if (title) list.append(el("h3", "cultui-list-title", title));
|
||||
for (const child of children) list.append(renderEveComponent(child, options));
|
||||
return list;
|
||||
}
|
||||
|
||||
if (kind === "list.item" || kind.endsWith(".item")) {
|
||||
const semantic = projectSemanticListItem(node);
|
||||
const item = el("article", "cultui-list-item");
|
||||
assignId(item, node);
|
||||
item.dataset.componentKind = kind;
|
||||
const heading = el("div", "cultui-list-item-heading");
|
||||
heading.append(el("strong", "cultui-list-item-label", semantic.label));
|
||||
if (semantic.status) heading.append(el("span", "cultui-list-item-status", semantic.status));
|
||||
item.append(heading);
|
||||
if (semantic.detail) item.append(el("div", "cultui-list-item-detail", semantic.detail));
|
||||
if (semantic.badges.length) {
|
||||
const badgeRow = el("div", "cultui-list-item-badges");
|
||||
for (const badge of semantic.badges) badgeRow.append(el("span", "cultui-list-item-badge", badge));
|
||||
item.append(badgeRow);
|
||||
}
|
||||
for (const child of children) item.append(renderEveComponent(child, options));
|
||||
return item;
|
||||
}
|
||||
|
||||
if (kind === "bar") {
|
||||
const bar = el("div", "cultui-meter");
|
||||
assignId(bar, node);
|
||||
|
|
@ -679,6 +706,16 @@ export function renderEveComponent(
|
|||
return fallback;
|
||||
}
|
||||
|
||||
export function projectSemanticListItem(node: EveSurfaceComponent): EveSemanticListItem {
|
||||
const props = objectProps(node.props);
|
||||
return {
|
||||
label: firstString(props.label, props.title, node.text, node.kind, "item"),
|
||||
status: firstString(props.status, ""),
|
||||
detail: firstString(props.detail, props.phase, ""),
|
||||
badges: firstString(props.badges, "").split(",").map(value => value.trim()).filter(Boolean),
|
||||
};
|
||||
}
|
||||
|
||||
function applyGeneratedLayout(
|
||||
element: HTMLElement,
|
||||
layout: Record<string, unknown>,
|
||||
|
|
|
|||
Loading…
Reference in a new issue