Skip to content

feat: add Dialog component with various demo stories#75

Merged
Aunshon merged 2 commits intomainfrom
add-dialog-component
Apr 2, 2026
Merged

feat: add Dialog component with various demo stories#75
Aunshon merged 2 commits intomainfrom
add-dialog-component

Conversation

@Aunshon
Copy link
Copy Markdown
Collaborator

@Aunshon Aunshon commented Apr 2, 2026

Summary by CodeRabbit

  • New Features

    • Added a Dialog UI with configurable close-button behavior, scrollable content, and sticky-footer layout.
    • Dialog exposes structural subcomponents (header, footer, title, description) for flexible composition.
  • Documentation

    • Added interactive Storybook examples demonstrating the dialog variants and usage.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 26b7adb0-0c7b-4662-9c8c-bf837d4aab6d

📥 Commits

Reviewing files that changed from the base of the PR and between 3c1da13 and 0a4900e.

📒 Files selected for processing (1)
  • src/index.ts

📝 Walkthrough

Walkthrough

Adds a new Dialog component set (with theming and optional close button) and accompanying Storybook stories demonstrating five dialog variants. Exports for the Dialog components are added to the UI module and root index.

Changes

Cohort / File(s) Summary
Dialog implementation & stories
src/components/ui/dialog.tsx, src/components/ui/Dialog.stories.tsx
New dialog component suite built on @base-ui/react/dialog: Dialog, DialogTrigger, DialogClose, DialogPortal, DialogOverlay, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription. DialogContent supports showCloseButton, theming via useThemeOptional(), portal CSS variable injection, overlay animations, and close button rendering. Storybook file adds five stories: Default, CustomCloseButton, NoCloseButton, ScrollableContent, StickyFooter.
UI module re-exports
src/components/ui/index.ts
Re-exports the new Dialog components and subcomponents from ./dialog.
Package root exports
src/index.ts
Re-exports Dialog components from ./components/ui at package root.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Story as Storybook (or App)
  participant Trigger as DialogTrigger
  participant Dialog
  participant Portal as DialogPortal
  participant Overlay as DialogOverlay
  participant Content as DialogContent

  User->>Story: click "Open dialog" button
  Story->>Trigger: onClick -> open
  Trigger->>Dialog: set open state
  Dialog->>Portal: render portal
  Portal->>Overlay: render backdrop
  Portal->>Content: render dialog content (uses theme CSS vars)
  User->>Content: interact (scroll, inputs, buttons)
  User->>Overlay: click backdrop (optional close)
  Content->>Dialog: DialogClose invoked -> set closed
  Dialog->>Portal: unmount portal
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • mrabbani

Poem

🐰 I hopped to open, soft and bright,
I brought a portal, overlay, and light,
Five tiny stories show each way,
Close buttons, scroll, and sticky play,
A rabbit's cheer for dialog delight! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a Dialog component along with demo stories for Storybook.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-dialog-component

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/components/ui/Dialog.stories.tsx (1)

29-49: Wrap the story form controls with Field for consistency.

These input groups are currently composed with Label + Input directly; please switch them to the Field pattern used in this repo.

As per coding guidelines, "Wrap form controls with the Field component to ensure consistent label, description, and error display".

Also applies to: 206-233

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/ui/Dialog.stories.tsx` around lines 29 - 49, Replace the
direct Label + Input groupings in the Dialog story with the repo's Field
pattern: wrap each label/input pair (e.g., the groups using Label and Input with
ids "name" and "username" and any similar groups later in the file) inside a
Field component so labels, descriptions, and errors render consistently; move
the Label into Field's label slot/prop and place the Input as Field's child,
preserving ids, defaultValue, and className, and apply the same change to the
other form groups flagged (the later blocks around the other form controls).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/ui/dialog.tsx`:
- Around line 70-74: The close Button rendered in DialogContent (the Button with
variant="ghost" className="absolute top-4 end-4" size="icon-sm") lacks an
explicit type and can act as a form submit button; update that Button to include
type="button" so it never triggers form submission when DialogContent is used
inside a form.

---

Nitpick comments:
In `@src/components/ui/Dialog.stories.tsx`:
- Around line 29-49: Replace the direct Label + Input groupings in the Dialog
story with the repo's Field pattern: wrap each label/input pair (e.g., the
groups using Label and Input with ids "name" and "username" and any similar
groups later in the file) inside a Field component so labels, descriptions, and
errors render consistently; move the Label into Field's label slot/prop and
place the Input as Field's child, preserving ids, defaultValue, and className,
and apply the same change to the other form groups flagged (the later blocks
around the other form controls).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 496a4056-29ea-4ff7-b449-286ab0a52ce0

📥 Commits

Reviewing files that changed from the base of the PR and between a6a2897 and 3c1da13.

📒 Files selected for processing (3)
  • src/components/ui/Dialog.stories.tsx
  • src/components/ui/dialog.tsx
  • src/components/ui/index.ts

Comment on lines +70 to +74
<Button
variant="ghost"
className="absolute top-4 end-4"
size="icon-sm"
/>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Set explicit type="button" on the built-in close button.

Without an explicit type, this can act as a submit button when DialogContent is used inside a form, causing unintended submits.

Suggested fix
               <Button
                 variant="ghost"
                 className="absolute top-4 end-4"
                 size="icon-sm"
+                type="button"
               />
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Button
variant="ghost"
className="absolute top-4 end-4"
size="icon-sm"
/>
<Button
variant="ghost"
className="absolute top-4 end-4"
size="icon-sm"
type="button"
/>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/ui/dialog.tsx` around lines 70 - 74, The close Button rendered
in DialogContent (the Button with variant="ghost" className="absolute top-4
end-4" size="icon-sm") lacks an explicit type and can act as a form submit
button; update that Button to include type="button" so it never triggers form
submission when DialogContent is used inside a form.

@Aunshon Aunshon merged commit ff436c0 into main Apr 2, 2026
1 check passed
@Aunshon Aunshon deleted the add-dialog-component branch April 2, 2026 11:58
@Aunshon Aunshon restored the add-dialog-component branch April 2, 2026 11:58
@coderabbitai coderabbitai bot mentioned this pull request Apr 2, 2026
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