Skip to content

Facet updates on data-tile to make sure all the facets are listed - #438

Draft
miss-o-soup wants to merge 2 commits into
datacommonsorg:mainfrom
miss-o-soup:facets-updates-on-tables
Draft

Facet updates on data-tile to make sure all the facets are listed#438
miss-o-soup wants to merge 2 commits into
datacommonsorg:mainfrom
miss-o-soup:facets-updates-on-tables

Conversation

@miss-o-soup

@miss-o-soup miss-o-soup commented Aug 5, 2026

Copy link
Copy Markdown

Facet updates on data-tile to make sure all the facets are listed
Frontend & UI Style Updates related

Complete Facet Listing in Tile Tables (render_result_html.ts):
Replaced single-facet rendering (facets[0]) with a full loop over all available dataset facets per statistical variable (facets.map(formatFacetBlock)).

Formatted each facet line-by-line (source, dateRange, measurementMethod, unit) separated by clean paragraph breaks inside the table cell.

NOTE: It might be that these updates requires merging first the updates to use our new MCP tools like get metadata, this is in a separate-upcoming PR

Before
image

After
image

Reorganized Card Hierarchy & Titles (sync_store.ts & render_result_html.ts):

  • Card Titles: Removed • Notes suffix from card headers and updated title derivation to Relevant insights on ${topicTitle}.

  • Insights Positioned First: Moved insight paragraphs to the very top of both single-place notes cards and cross-place comparison cards.

  • Header & Bullet Removal: Removed sub-headers ("### Relevant insights" / "### Comparative insights") and bullet point markers (- / Title: ).
    "About this data" Positioned Below: Placed ### About this data (coverage & caveats) below the insights section.

Typography & Spacing Refinements (text.module.scss):

  • Insight Typography: Styled insight paragraphs preceding with @include type-title(500); (14px mobile / 16px tablet, medium non-bold weight 500), matching the exact font size of "About this data".
  • Table Top Spacing: Increased table top margin from 12px to 20px (table:not(:first-child)) for a comfortable visual gap below the lead-in text.

Improved footer with follow up questions header:

  • Card Footer Component (footer.tsx & footer.module.scss): Added support for a title prop on CardFooter that renders a header (styled with @include type-title; to match "About this data").
  • Card Integrations (text.tsx & chart.tsx): Updated both text/notes cards and chart cards to pass title="Suggested follow-up questions" to <Card.Footer>.

Changed header from “About this data” to simply “Notes”
Changed '### About this data\n\n' to '### Notes\n\n' for both single-place notes cards and cross-place comparison cards.

Before
image

After
image

Note the insights at the top should be improved and be presented more as a paragraph, will do so in a future PR. This one is just for the layout of the card content itself.

Frontend & UI Style Updates
Complete Facet Listing in Tile Tables (render_result_html.ts):
Replaced single-facet rendering (facets[0]) with a full loop over all available dataset facets per statistical variable (facets.map(formatFacetBlock)).
Formatted each facet line-by-line (source, dateRange, measurementMethod, unit) separated by clean <br><br> paragraph breaks inside the table cell.

@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 updates the HTML rendering logic to support displaying multiple facets per variable and restructures the layout of insights and notes, placing insights at the top of the card without headers or bullet points. The review feedback highlights two key improvements: handling cases where the earliest and latest dates are identical to avoid redundant date ranges (e.g., '2020 – 2020'), and escaping pipe characters in facet details to prevent them from breaking the markdown table structure.

Comment on lines +34 to +37
const dateRange =
facet.earliestDate && facet.latestDate
? `${facet.earliestDate} – ${facet.latestDate}`
: facet.earliestDate || facet.latestDate || '';

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.

medium

If earliestDate and latestDate are identical (e.g., both are '2020'), the date range will render redundantly as '2020 – 2020'. We should check if they are equal and only display a single date in that case.

  const dateRange =
    facet.earliestDate && facet.latestDate
      ? facet.earliestDate === facet.latestDate
        ? facet.earliestDate
        : facet.earliestDate + ' – ' + facet.latestDate
      : facet.earliestDate || facet.latestDate || '';

Comment on lines +66 to +69
const facetCell =
facets.length > 0
? facets.map(formatFacetBlock).join('<br><br>')
: 'No data';

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.

medium

Since the table is built using Markdown syntax, any pipe (|) characters present in the facet details (such as in the source name or unit) will break the markdown table structure. We should escape pipe characters to | to ensure the table renders correctly.

Suggested change
const facetCell =
facets.length > 0
? facets.map(formatFacetBlock).join('<br><br>')
: 'No data';
const facetCell =
facets.length > 0
? facets.map(formatFacetBlock).join('<br><br>').replace(/\|/g, '\\|')
: 'No data';

Missing UI updates for the insights card
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