Skip to content

Align alert-dialog to architecture goals#202

Open
lifeiscontent wants to merge 2 commits into
mainfrom
align/alert-dialog
Open

Align alert-dialog to architecture goals#202
lifeiscontent wants to merge 2 commits into
mainfrom
align/alert-dialog

Conversation

@lifeiscontent

Copy link
Copy Markdown
Collaborator

Closes #117

What the spec says

From the designer's comment on #117:

Always the same (baked into the design system):

  • Centered overlay positioning + backdrop, focus trap, close on Escape
  • Action button placement: right-aligned in footer
  • Icon placement: left of title
  • Spacing between title, description, and action buttons
  • Z-index stacking, border-radius, shadow/elevation
  • Destructive action always visually distinct
  • Max-width constraint

Depends / adjustable (consumer-supplied):

  • Title text, description/body text, action button labels
  • Variant: destructive vs informational
  • Icon type (warning, error, info)

What changed

Previously, the "always the same" structural layout (title+description group, right-aligned actions row, popup max-width) lived as ad-hoc className-bearing divs inside the stories. The popup also had no width baked in — a w-80 sat on an inner wrapper inside the story, not on the popup itself. The stories even noted "these are the future anatomy surfaces" but hadn't committed them.

This commit hardens those surfaces:

  • AlertDialogIntro — new ui part (div) that groups the title and description with the always-the-same flex flex-col gap-2 spacing. Styled via alertDialogIntroVariants in variants.ts.
  • AlertDialogActions — new ui part (div) that right-aligns action buttons with the always-the-same flex justify-end gap-2 layout. Styled via alertDialogActionsVariants in variants.ts.
  • AlertDialogPopup gets w-80 flex flex-col gap-4 baked into its cva — the max-width constraint and top-level popup layout are always the same per spec, so they belong on the popup, not a wrapper div in the story.
  • Both stories (UI tier and components tier) now use the anatomy parts instead of layout divs, dropping all inline className from JSX.
  • Both index.tsx exports and subcomponents meta are updated to include the new parts.

Architecture checklist

  • No cx or className in component .tsx files — all className lives in variants.ts via cva
  • Every ui part renders exactly one element
  • No defaultVariants — both new parts have no variant axes (the layout is invariant per spec)
  • No className or style props exposed on any part
  • vp check --no-fmt passes clean across all 17 files

Notes

Needs design approval from @bhaveshraja before merge.

The "variant: destructive vs informational" and "icon type" axes from the spec are intentionally not yet wired — no Icon part exists yet and the visual treatment for informational vs destructive at the popup level hasn't been signed off. Those are tracked in #117.

@github-actions

Copy link
Copy Markdown

📚 Storybook preview: https://pr-202-propel-storybook.vamsi-906.workers.dev

Per issue #117, the designer marked spacing, right-aligned action placement,
and max-width constraint as "always the same". These were previously left to
the consumer via ad-hoc layout divs inside the stories. This commit bakes
them in via two new anatomy parts and updates the popup's baked styles.
The popup now exposes the leading-icon region the design spec calls out
("icon placement, left of title"; "icon type warning/error/info"). Two new
ui parts:

- AlertDialogIcon: a decorative single-element node slot for the leading
  glyph, with a required `tone` (danger/warning/info/success) — the
  destructive-vs-informational axis the spec marks adjustable, no default.
- AlertDialogHeader: the row that places the icon at the inline-start of
  the intro so the icon sits left of the title.

Styling stays in ui/.../variants.ts (cva); the components tier only
composes parts. Stories compose the new parts and register them in
subcomponents.
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.

Alert dialog: what should always look the same, and what should be adjustable?

1 participant