Skip to content

Add an optional polymorphic as prop to Card for semantic section/article usage #163

Description

@Jagadeeshftw

📌 Description

Card (src/components/Card.tsx) always renders a div, and it's reused as the root wrapper for dashboard sections (QuoteForm, MetricsBar's loading/error states, PoolsPanel) that are conceptually distinct page regions. Rendering these as generic divs misses an easy opportunity to expose semantic landmarks (section, article) to assistive tech and to tools like a browser's accessibility tree/outline.

🧩 Requirements and context

  • Add an optional as prop to Card (defaulting to "div", preserving current behavior) allowing callers to render section, article, or another sanctioned tag.
  • No visual/styling change for existing call sites that don't pass as.
  • Update at least one real call site (e.g. QuoteForm's wrapping Card) to use as="section" with an appropriate aria-label/aria-labelledby, as a proof of the new capability.

🛠️ Suggested execution

  • Update src/components/Card.tsx to accept an as prop and render the corresponding element while keeping className/children behavior identical.
  • Update src/components/QuoteForm.tsx's Card usage to pass as="section" with a label tied to its existing heading.
  • Extend src/components/Card.test.tsx and src/components/QuoteForm.test.tsx to cover the new prop.

✅ Acceptance criteria

  • Card accepts an optional as prop, defaulting to the current div behavior.
  • At least one real call site demonstrates the new semantic element usage.
  • Test coverage for the polymorphic rendering.

🔒 Security notes

No new attack surface; a semantic/accessibility refactor.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26accessibilityAccessibility (WCAG)refactorCode refactor / cleanup

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions