Skip to content

[FEATURE] UI Customization. Add Card Component - #387

Open
zhuje wants to merge 3 commits into
ui-customizationfrom
zhuje/ou1607-ui-customization-card-component
Open

zhuje wants to merge 3 commits into
ui-customizationfrom
zhuje/ou1607-ui-customization-card-component

Conversation

@zhuje

@zhuje zhuje commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

Description

Adds the Card primitive (Card, CardHeader, CardContent) to the next design system in @perses-dev/components

API

  • Card — variant="elevated" | "outlined" (default elevated), rendered as data-variant; as="div" | "section" | "article" (default div).
  • CardHeader — endElement slot for actions (boolean/null values render no trailing slot); as="div" | "header".
  • CardContent — as="div" | "figure"; supports p="0" for edge-to-edge content, which the Card clips to its radius (overflow: hidden).
  • All three accept the shared spacing/sizing style props via applyStyleProps, forward ref (HTMLElement), and are registered as customization slots in PersesComponents / defaultComponents so hosts can swap them through ComponentsProvider.

Design notes

  • The as prop is a closed union, not an open ElementType. This is a deliberate exception to the implementation plan's "no polymorphic props" rule: the existing MUI Panel renders Card component="section" / CardHeader component="header" / CardContent component="figure", and the only alternative (role="region"/role="figure" on divs) is a semantic regression that trips jsx-a11y/prefer-tag-over-role in every consumer. The closed list keeps types simple (refs are always HTMLElement) and prevents misuse (as="button"). Rendering uses createElement because a union JSX tag fails type-checking on the div ref type.
  • Scope follows the call-site audit of Perses (Panel, PanelHeader, ExploreManager, AnnotationPreview, VariablePreview): CardActions, startElement, subheader, and CardMedia had zero usages and are intentionally omitted.

Screenshots

Screenshot 2026-10-21 at 3 00 23 PM Screenshot 2026-10-21 at 3 00 13 PM Screenshot 2026-10-21 at 3 00 14 PM

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.
  • E2E tests are stable and unlikely to be flaky.
    See e2e docs for more details. Common issues include:
    • Is the data inconsistent? You need to mock API requests.
    • Does the time change? You need to use consistent time values or mock time utilities.
    • Does it have loading states? You need to wait for loading to complete.

@zhuje
zhuje requested a review from a team as a code owner October 21, 2026 19:03
@zhuje zhuje changed the title Zhuje/ou1607 UI customization card component [FEATURE] UI Customization. Add Card Component Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit 5ee7d19.

zhuje added 3 commits October 21, 2026 15:12
Adds Card, CardHeader and CardContent to the next primitives. Card takes
variant ('elevated' | 'outlined' -> data-variant) plus spacing and sizing
style props; CardHeader exposes children as the title slot and a single
endElement slot; CardContent is a padded container. All defaults are
wrapped in :where() so style props win. Each part accepts a closed-union
'as' prop (div|section|article, div|header, div|figure) so the dashboard
Panel keeps its native section/header/figure semantics.

Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
  - Card now clips edge-to-edge content to rounded boundaries.
  - Removed all new Card Oxlint warnings.
  - Updated tests and story example.

Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
- Add closed-union  prop to Card/CardHeader/CardContent
  (div|section|article, div|header, div|figure) so the Panel
  migration keeps native semantics without role= suppressions
- Use --perses-border-width-sm token; drop reset-owned box-sizing
- Import the style engine via the system barrel
- Remove file-wide jsx-a11y suppressions from tests and stories
- Move story presentation styles into .ladle/stories.css
- Complete the ComponentsContext provider example

Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
@zhuje
zhuje force-pushed the zhuje/ou1607-ui-customization-card-component branch from d1ad2cc to 5ee7d19 Compare October 21, 2026 19:13
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