Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,81 @@
|
||||
import type { ReactElement } from "react";
|
||||
import { createShellRegistries } from "@toolctrl/ui-app";
|
||||
import type { HotSwapDrillData, MockPage } from "@toolctrl/ui-mock";
|
||||
|
||||
export type HotSwapPageRendererProps = {
|
||||
readonly descriptor: MockPage<HotSwapDrillData>;
|
||||
};
|
||||
|
||||
function isHotSwapDrillData(value: unknown): value is HotSwapDrillData {
|
||||
if (!value || typeof value !== "object") return false;
|
||||
const candidate = value as Partial<HotSwapDrillData>;
|
||||
return Array.isArray(candidate.cards) && Array.isArray(candidate.activity);
|
||||
}
|
||||
|
||||
export function HotSwapPageRenderer({ descriptor }: HotSwapPageRendererProps): ReactElement {
|
||||
const registries = createShellRegistries(descriptor.registries);
|
||||
const titleKey = descriptor.titleKey ?? descriptor.title ?? descriptor.id;
|
||||
const descriptionKey = descriptor.descriptionKey ?? descriptor.description ?? `${descriptor.id}.description`;
|
||||
const data = isHotSwapDrillData(descriptor.state.data) ? descriptor.state.data : null;
|
||||
|
||||
return (
|
||||
<section
|
||||
data-ui-shell="hot-swap"
|
||||
data-ui-source="ui-app-registry"
|
||||
data-page-id={descriptor.id}
|
||||
data-page-route={descriptor.route}
|
||||
data-page-status={descriptor.state.status}
|
||||
data-sidebar-count={registries.sidebar.length}
|
||||
data-breadcrumb-count={registries.breadcrumbs.length}
|
||||
data-mobile-count={registries.mobile.length}
|
||||
data-portal-count={registries.portals.length}
|
||||
>
|
||||
<nav data-section="sidebar" aria-label={titleKey}>
|
||||
<ul>
|
||||
{registries.sidebar.map((item) => (
|
||||
<li key={item.id} data-sidebar-id={item.id}>
|
||||
<a href={item.href} data-label-key={item.labelKey}>
|
||||
{item.labelKey}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</nav>
|
||||
<ol data-section="breadcrumbs" aria-label={`${descriptor.id}.breadcrumbs`}>
|
||||
{registries.breadcrumbs.map((item) => (
|
||||
<li key={item.id} data-breadcrumb-id={item.id} data-label-key={item.labelKey}>
|
||||
{item.labelKey}
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
<header data-section="header">
|
||||
<h1 data-label-key={titleKey}>{titleKey}</h1>
|
||||
<p data-label-key={descriptionKey}>{descriptionKey}</p>
|
||||
</header>
|
||||
<section data-section="cards" aria-label={`${descriptor.id}.cards`}>
|
||||
{(data?.cards ?? []).map((card, index) => (
|
||||
<article
|
||||
key={`${card.labelKey}-${index}`}
|
||||
data-card-trend={card.trend}
|
||||
data-label-key={card.labelKey}
|
||||
>
|
||||
<p data-card-label data-label-key={card.labelKey}>
|
||||
{card.labelKey}
|
||||
</p>
|
||||
<p data-card-value>{card.value}</p>
|
||||
</article>
|
||||
))}
|
||||
</section>
|
||||
<section data-section="activity" aria-label={`${descriptor.id}.activity`}>
|
||||
<ul>
|
||||
{(data?.activity ?? []).map((entry, index) => (
|
||||
<li key={`${entry.labelKey}-${index}`} data-label-key={entry.labelKey}>
|
||||
<span data-label-key={entry.labelKey}>{entry.labelKey}</span>
|
||||
<span data-meta>{entry.meta}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user