Skip to content

feat: Catalog Reference route (native @a2ui/angular) - #129

Open
jerelvelarde wants to merge 13 commits into
a2ui-project:mainfrom
jerelvelarde:jerel/pr-catalog-reference
Open

feat: Catalog Reference route (native @a2ui/angular)#129
jerelvelarde wants to merge 13 commits into
a2ui-project:mainfrom
jerelvelarde:jerel/pr-catalog-reference

Conversation

@jerelvelarde

@jerelvelarde jerelvelarde commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

A per-component reference for the custom A2UI catalog: live native preview, A2UI usage snippet, and props for every component — plus Definitions and Renderers views that show the catalog's own source.

Depends on #121 (Custom Catalog). This branch is stacked on #121, so the foundation commits (the @a2ui/angular build + the 11-component catalog) appear in this diff until #121 merges. The Catalog-Reference-specific changes are the last 4 commits: custom-catalog/reference/**, the /catalog-reference route + nav entry, and a codegen script that bundles the catalog source.

What

  • /catalog-reference route with a component index grouped by category (Layout / Content / Data Display / Interactive).
  • Per component: a live native preview, copyable A2UI usage (v0.9 createSurface / updateComponents), and a props table.
  • Definitions and Renderers views render the catalog's own source, bundled at build time via shell/scripts/generate-catalog-source.mjs.

Why

Gives contributors a browsable, always-in-sync reference for what the native catalog offers and exactly how to author each component in A2UI.

Testing

ng build (lint + AOT) green on a clean build; catalog-reference + composer-shell unit tests pass (24 specs).


Contributed by CopilotKit.

Screenshots

/catalog-reference — live native preview + A2UI usage + props (PieChart shown):

Light Dark

@google-cla

google-cla Bot commented Jul 24, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a custom 11-component dashboard catalog, a code-generation script to bundle source files, and integrates 'Custom Catalog' and 'Catalog Reference' views into the shell routes and sidebar navigation, complete with unit tests. Feedback focuses on improving robustness: clamping negative values to zero in BarChart and PieChart to prevent invalid SVG rendering, and adding a safety guard in DataTable to prevent runtime errors if a row is null or undefined.

Comment thread shell/src/app/custom-catalog/catalog/components/bar-chart/bar-chart.ts Outdated
Comment thread shell/src/app/custom-catalog/catalog/components/pie-chart/pie-chart.ts Outdated
Comment thread shell/src/app/custom-catalog/catalog/components/data-table/data-table.ts Outdated
@jerelvelarde
jerelvelarde force-pushed the jerel/pr-catalog-reference branch 3 times, most recently from bb86b15 to 6d4e210 Compare July 29, 2026 17:12
@jerelvelarde

Copy link
Copy Markdown
Contributor Author

Addressed the Gemini review:

  • Charts clamp negative values (Math.max(0, Number(d?.value) || 0)) so a negative datum can't corrupt bar heights or pie-slice angles.
  • Guarded non-object rows/columns and null cells in the data table (cell() null-guard + column/row filtering).

Rebased onto latest main.

@jerelvelarde

Copy link
Copy Markdown
Contributor Author

Went back through the Gemini review comments on this PR and resolved them — all three were already addressed in the current code:

  • bar-chart.ts — negative values producing negative <rect> heights. Both the max reduction and the per-bar value now clamp: Math.max(0, Number(d?.value) || 0).
  • pie-chart.ts — negative values corrupting total/cursor. Same clamp applied to the total reduction and each slice value.
  • data-table.tsrow[key] throwing on a null/undefined row. Now guarded: row ? String(row[key] ?? "") : "".

Holding off on rebasing this one until the refactor stack lands, per our chat.

jerelvelarde and others added 13 commits August 28, 2026 05:15
Enables in-app (no-iframe) rendering of custom catalogs. Pin shell zod to
3.25.76 so app-authored catalog schemas share the exact zod instance the
@a2ui/web_core binder introspects (Angular's own zod 4 stays nested/isolated).
Validated end-to-end: a shell-authored custom Title resolves a {path} binding
via <a2ui-v09-surface>.
Port of the react-flight-catalog dashboard catalog to native @a2ui/angular
renderers (Row/Column/Title/Badge/Metric/DashboardCard/FlightCard/DataTable/
Button + hand-rolled SVG PieChart/BarChart), themed via --cpk-* tokens.
buildDashboardCatalog() registers all 11 into an AngularCatalog. Surface-render
tests green (children, chart shapes, path bindings, action dispatch).
Native /custom-catalog page: renders the Flight Card + Sales Dashboard trees
via <a2ui-v09-surface> (no iframe) from the 11-component dashboard catalog,
with an editable Monaco data-model panel. Example toggle + data-state tabs
(Morning/Afternoon, Q1-Q4); editing the JSON live-updates the surface via
updateDataModel. Surfaces are built once per example (createSurface+
updateComponents), so data changes push updateDataModel only. Nav item added
to Google's list; shell spec nav counts updated for the new route.
Generated data module (committed) + Node codegen that reads apis.ts,
dashboard-catalog.ts, and the 11 renderer files. Wired via
yarn generate:catalog-source; generated file + scripts/ excluded from
lint and prettier.
…s + source)

Per-component reference for the 11-component dashboard catalog: native
@a2ui/angular previews, A2UI usage snippets, props tables, plus raw
Definitions/Renderers source viewers. Includes a docs-vs-catalog sync test.
…p signal-writing effect in Catalog Reference
The composer-shell spec asserts a hardcoded number of aria-hidden
MatIcon elements. This branch adds two nav items and raised the count
from 5 to 7; main independently raised it from 5 to 6. The rebase kept
one increment, so bump it to 8 to match what renders.

Also runs prettier over sources that had never been formatted.
These pages are authored against the shell's --cpk-* design tokens, which
are introduced by a separate PR. On their own none of the tokens resolve,
so every padding, radius, font and colour collapsed and the page rendered
unstyled.

Add a small styles/_cpk-fallbacks.scss partial supplying light and dark
defaults under --cpk-fb-* names, and reference each token as
var(--cpk-x, var(--cpk-fb-x)). The real token always wins where it exists,
so nothing here shadows or overrides the theme; the fallbacks apply only
in its absence. Dark values are keyed off the existing .dark-theme class
via :host-context, so the standalone page themes correctly too.

Separately, fix the Catalog Reference preview pane. .ref-detail is a flex
column, so its cards were flex items that shrank to fit instead of letting
the pane scroll; with overflow: hidden this clipped the live preview to a
few pixels. Pin the cards to their content height.
Pinning the cards to their content height stopped the preview being
clipped, but exposed the opposite problem: components authored to fill
their container -- BarChart and DataTable -- then rendered at full page
width, several hundred pixels tall. PieChart was unaffected because its
svg is a fixed 160px box.

Give the preview a sane box (640x560 max) and let anything larger scroll
inside the card. This is a page-layout concern, so the components keep
their fill-the-container behaviour for real dashboards.
@jerelvelarde
jerelvelarde force-pushed the jerel/pr-catalog-reference branch from 6d4e210 to 4d7d4dd Compare August 28, 2026 17:38
@jerelvelarde

Copy link
Copy Markdown
Contributor Author

Rebased onto current main and pushed. Verified locally: tsc, prettier, lint clean, 1077/1077 tests, clean build.

Four things changed beyond the rebase:

  1. Decorative-icon count. composer-shell.spec.ts asserts a hardcoded number of aria-hidden mat-icon elements. main raised it 5→6 for its new nav item and this branch had raised it 5→7 for its two, so the rebase collapsed the two edits into one and the spec asserted one fewer icon than renders. Bumped to 8. Worth deriving that count from the template at some point — it will catch anyone who adds a nav item on a branch.

  2. Formatting. Seven files here had never been through prettier. yarn prettier over them, no logic touched.

  3. Standalone theming. This page is authored against the shell's --cpk-* design tokens, which the theme PR introduces. On its own none of them resolved, so every padding, radius and colour collapsed and the page rendered unstyled — which is what the old screenshots showed. Added styles/_cpk-fallbacks.scss with light and dark defaults under --cpk-fb-*, and each usage is now var(--cpk-x, var(--cpk-fb-x)). The real token always wins where it exists, so nothing shadows or overrides the theme.

  4. The preview pane. .ref-detail is a flex column, so its cards were flex items that shrank rather than letting the pane scroll; with overflow: hidden that clipped the live preview to a few pixels. Pinned the cards to their content height. That then exposed the opposite problem — BarChart and DataTable are authored to fill their container, so an unbounded preview rendered them at full page width — so the preview now has a 640×560 box and scrolls beyond it.

Screenshots in the description have been retaken against this branch.

Note on ordering: this still looks best merged after the theme layer. The fallbacks are there so it reviews correctly on its own, not to replace the theme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant