Skip to content

Feat/trail 38 form card#19

Open
Hannahbird wants to merge 7 commits intomainfrom
feat/TRAIL-38__form_card
Open

Feat/trail 38 form card#19
Hannahbird wants to merge 7 commits intomainfrom
feat/TRAIL-38__form_card

Conversation

@Hannahbird
Copy link
Collaborator

@Hannahbird Hannahbird commented Mar 12, 2026

Summary

Fixes: #

Related Tickets: TRAIL-38 https://jira.atlassian.krum.io/browse/TRAIL-38?atlOrigin=eyJpIjoiNzljMjgwM2FlOTg3NDM2Yjg4NzE4N2Q1NDgwMjg5Y2MiLCJwIjoiaiJ9

Adds two new Lit web components: trailhand-form-card and trailhand-form-row, that serve as the layout layer for forms housed inside modals (or standalone with optional shadow). The form card provides a flex-column content area with optional action buttons; the form row provides a per-section grid with an optional section title. Together they compose the multi-section, multi-column form patterns shown in the TRAIL-38 mockups.


Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📚 Documentation update
  • 🎨 Style/UI change
  • ♻️ Refactor (no functional changes)
  • ⚡ Performance improvement
  • 🧪 Test update
  • 🔧 Build/CI configuration
  • 🧹 Chore (dependency updates, cleanup, etc.)

Changes Made

Primary Changes

  • Added trailhand-form-card component: a borderless layout card with configurable column grid, optional box shadow, loading state, and independent cancel/primary action buttons
  • Added trailhand-form-row companion component: a section row with an optional title and per-row CSS grid for form fields; auto-registered by importing the form card so consumers only need one import
  • Exported both components from the package root (src/index.ts)

Secondary/Collateral Changes

  • Added CSS custom properties for both components to src/styles/colors.css with light and dark theme values following the existing --th-[component]-[property] naming convention
  • Updated dev/main.ts with three representative form card modal examples matching the TRAIL-38 mockups (configuration form, instances catalog form, config data with upload/remove links)
  • Converted Storybook stories from imperative document.createElement JS to html tagged template TypeScript to enable "Show code" snippets in autodocs

Technical Notes

Files Modified

New Components:

  • src/components/th-form-card/th-form-card.ts: Main form card component
  • src/components/th-form-card/th-form-row.ts: Section row component
  • src/components/th-form-card/index.ts: Barrel exports for both components

Stories:

  • src/components/th-form-card/th-form-card.stories.ts: Storybook stories (TS, html templates)
  • src/components/th-form-card/th-form-row.stories.ts: Storybook stories (TS, html templates)

Tests:

  • src/components/th-form-card/th-form-card.test.ts: Unit tests for form card
  • src/components/th-form-card/th-form-row.test.ts: Unit tests for form row

Global:

  • src/styles/colors.css: Added --th-form-card-* and --th-form-row-* CSS variables (:root + [data-theme='dark'])
  • src/index.ts: Added export * from './components/th-form-card'
  • dev/main.ts: Added three form card modal demos

Implementation Details

  • Form card is a pure layout container title, subtitle, and dismiss are intentionally omitted since those concerns belong to the wrapping trailhand-modal
  • Flex column by default, grid when columns > 1 the card stacks trailhand-form-row children vertically in the common case; a flat grid is available for simpler forms that slot fields directly without rows
  • Each button renders independently buttonLabel and cancelLabel both default to ''; a button only renders when its label is explicitly set, so either, both, or neither can be shown without separate boolean props
  • th-form-row is auto-registered th-form-card.ts imports ./th-form-row, so consumers only need to import the card
  • CSS variables use --th- prefix avoids collision with epinio's existing variable namespace; --th-form-card-shadow-bg is a separate variable from --th-form-card-bg so the shadow variant can use a solid background in both themes without overriding the default transparent background

Testing

How to Test

Test Coverage

  • Unit tests added/updated
  • Integration tests added/updated
  • E2E tests added/updated
  • Manual testing completed

Browsers Tested

  • Chrome
  • Firefox
  • Safari
  • Edge

Potential Regressions


Screenshots / Videos

Before After

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code in hard-to-understand areas
  • I have updated documentation as needed
  • My changes generate no new warnings or errors
  • I have tested my changes locally
  • Any dependent changes have been merged and published

Additional Context

  • Form validation is intentionally not handled at this layer, individual trailhand-text-input components own their own validation state via the required, error, and error-message props

th-form-card.ts — main component
index.ts — barrel export
th-form-card.stories.js — Storybook stories
…n order to allow users more flexibility in the case of complex forms. created tests, and updated stories. implemented forms into modals on main.ts
@Hannahbird Hannahbird requested a review from johnlcos March 12, 2026 15:04

export const Loading: Story = {
args: { loading: true },
};
Copy link
Member

Choose a reason for hiding this comment

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

I think a interaction story would be helpful here, just displaying how the form would actually be used and submissions handled.

}

return html`
<div class="form-card" part="card">
Copy link
Member

Choose a reason for hiding this comment

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

I thought the form card would use the native html form element.

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.

2 participants