Skip to content

feat(ui): enhance Alert, Button, Checkbox components#162

Merged
kylengn merged 6 commits intomainfrom
chores/alert-button-checkbox
Nov 24, 2025
Merged

feat(ui): enhance Alert, Button, Checkbox components#162
kylengn merged 6 commits intomainfrom
chores/alert-button-checkbox

Conversation

@kylengn
Copy link
Contributor

@kylengn kylengn commented Nov 21, 2025

Note

Introduces a controllable, animated Alert with auto-close and context-driven close; improves button accessibility and link behavior; adds a form validation story.

  • UI Components
    • Alert (components/alert/alert.tsx):
      • Adds controlled/uncontrolled open, defaultOpen, onOpenChange, autoClose, animated, and customizable transition (via framer-motion).
      • Introduces internal context for variant and onClose; AlertClose now closes via context and no longer requires explicit variant.
      • Exports alertDefaultTransition and AlertProps.
    • Buttons:
      • button.tsx, icon-button.tsx: add cursor-pointer and propagate aria-disabled when asChild is used; maintain loading ARIA states.
      • button-link.tsx: adds cursor-pointer and size/underline variants usage consistency.
    • Checkbox Links (checkbox-links.tsx):
      • External links open in new tab with rel="noopener noreferrer"; button-style links use buttonLinkVariants.
  • Stories
    • alert.stories.tsx: adds form validation example using zod/react-hook-form and error Alert with autoClose; removes passing variant to AlertClose.
    • checkbox.stories.tsx: updates legal links to real URLs and new window behavior.
  • Release
    • Changeset: minor bump for @shipfox/react-ui.

Written by Cursor Bugbot for commit 1316756. This will update automatically on new commits. Configure here.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added animated alert transitions with auto-close support
    • Added form validation example demonstrating error handling
  • Improvements

    • Enhanced accessibility with aria-disabled attributes and improved cursor feedback across interactive components
    • Updated legal policy links to correct destinations

✏️ Tip: You can customize this high-level summary in your review settings.

@kylengn kylengn self-assigned this Nov 21, 2025
Copilot AI review requested due to automatic review settings November 21, 2025 06:31
@vercel
Copy link

vercel bot commented Nov 21, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
react-ui Ready Ready Preview Comment Nov 21, 2025 6:55am

@coderabbitai
Copy link

coderabbitai bot commented Nov 21, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

This PR enhances Alert with controlled/uncontrolled state management, animations, autoClose functionality, and context-based variant sharing. Alert stories simplify AlertClose usage and add a form validation example. Button variants gain cursor-pointer and aria-disabled attributes for better UX and accessibility. Checkbox-links is refactored to use ButtonLink, and policy links are updated with real destinations.

Changes

Cohort / File(s) Summary
Alert Component & Stories
libs/react/ui/src/components/alert/alert.tsx, libs/react/ui/src/components/alert/alert.stories.tsx
Enhanced Alert with controlled/uncontrolled open state, motion animations via AnimatePresence, AlertContext for variant/close sharing, autoClose timer support, and animated container rendering. Stories remove variant-driven AlertClose and introduce new WithFormValidation story demonstrating form validation with zod/react-hook-form. Exports new alertDefaultTransition constant and AlertProps type.
Button Variants with Accessibility
libs/react/ui/src/components/button/button.tsx, libs/react/ui/src/components/button/button-link.tsx, libs/react/ui/src/components/button/icon-button.tsx
Added cursor-pointer class to base styling across all three button variants for explicit click affordance. Added aria-disabled attribute to button and icon-button to reflect disabled/loading states to assistive technology.
Checkbox Links & Stories
libs/react/ui/src/components/checkbox/checkbox-links.tsx, libs/react/ui/src/components/checkbox/checkbox.stories.tsx
Replaced inline button with ButtonLink (interactive variant, sm size) for non-href items. Enhanced anchor links with target="_blank", rel="noopener noreferrer", and transition-colors. Updated CheckboxLinksStory to link Terms of Service and Privacy Policy to real policy URLs on shipfox.io.

Sequence Diagram

sequenceDiagram
    actor User
    participant Alert as Alert Component
    participant Context as AlertContext
    participant Motion as AnimatePresence
    participant Timer as AutoClose Timer
    
    User->>Alert: Mount with animated=true, autoClose=5000
    Alert->>Context: Provide isOpen, onClose, variant
    
    alt autoClose enabled
        Alert->>Timer: Start countdown
        Timer-->>Timer: 5000ms elapsed
        Timer->>Alert: Trigger onClose
    end
    
    User->>Alert: Interact (click close button)
    Alert->>Alert: invoke onClose
    Alert->>Motion: Trigger exit animation
    Motion-->>User: Fade out with transition
    Alert->>Alert: Remove from DOM
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Alert component (alert.tsx): Highest complexity due to new state management patterns, context provider, animation integration, and autoClose timer logic. Verify proper cleanup of timer refs and context propagation.
  • AlertClose behavior changes: Ensure variant derivation from context and onClose invocation order don't break existing consumers.
  • Button accessibility additions: Simple aria-disabled additions should be verified for proper state binding with disabled/loading props across all three variants.

Possibly related PRs

Suggested reviewers

  • EnzalRad
  • dvxam
  • noe-charmet

Poem

🐰 Hop, hop! The Alert now dances smooth,
With timers ticking, context sooth,
Buttons point with cursor's grace,
Forms validate in their place,
Checkboxes linked to policy true—
All UI components refreshed anew!

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately captures the main changes across multiple components (Alert, Button, Checkbox) with feature enhancements.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chores/alert-button-checkbox

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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the Alert, Button, and Checkbox components with improved interactivity, accessibility, and user experience features. The Alert component gains animation support, controlled/uncontrolled state management, and auto-close functionality. Button components receive explicit cursor styling and aria attributes. Checkbox links are updated to use real URLs and the ButtonLink component for consistent styling.

Key Changes:

  • Alert component refactored with animation support (framer-motion), context-based state management, and auto-close timer functionality
  • Button components enhanced with explicit cursor-pointer class and aria-disabled attribute
  • Checkbox links updated to use real Shipfox legal URLs and replace raw button elements with ButtonLink component

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
libs/react/ui/src/components/alert/alert.tsx Added animation, controlled/uncontrolled state, context API, and auto-close feature to Alert component
libs/react/ui/src/components/alert/alert.stories.tsx Added form validation story demonstrating new Alert features with auto-close and controlled state
libs/react/ui/src/components/button/button.tsx Added cursor-pointer class and aria-disabled attribute to button variants
libs/react/ui/src/components/button/icon-button.tsx Added cursor-pointer class and aria-disabled attribute to icon button variants
libs/react/ui/src/components/button/button-link.tsx Added cursor-pointer class to button link variants
libs/react/ui/src/components/checkbox/checkbox-links.tsx Replaced placeholder URLs with real Shipfox legal links, added security attributes, replaced button with ButtonLink, added transition animation
libs/react/ui/src/components/checkbox/checkbox.stories.tsx Updated stories with real URLs and window.open handlers with proper security parameters

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@argos-ci
Copy link

argos-ci bot commented Nov 21, 2025

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) 👍 Changes approved 4 changed, 1 added Nov 21, 2025, 6:57 AM

Copy link

@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: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a0ec450 and 3368699.

📒 Files selected for processing (7)
  • libs/react/ui/src/components/alert/alert.stories.tsx (3 hunks)
  • libs/react/ui/src/components/alert/alert.tsx (4 hunks)
  • libs/react/ui/src/components/button/button-link.tsx (1 hunks)
  • libs/react/ui/src/components/button/button.tsx (2 hunks)
  • libs/react/ui/src/components/button/icon-button.tsx (2 hunks)
  • libs/react/ui/src/components/checkbox/checkbox-links.tsx (2 hunks)
  • libs/react/ui/src/components/checkbox/checkbox.stories.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*

⚙️ CodeRabbit configuration file

We handle errors at the edge of our applications in most cases. Do not recommend to add error handling around every single function. We prefer them to bubble up and be handled at upper layers.

Files:

  • libs/react/ui/src/components/button/button-link.tsx
  • libs/react/ui/src/components/checkbox/checkbox-links.tsx
  • libs/react/ui/src/components/button/button.tsx
  • libs/react/ui/src/components/alert/alert.stories.tsx
  • libs/react/ui/src/components/button/icon-button.tsx
  • libs/react/ui/src/components/alert/alert.tsx
  • libs/react/ui/src/components/checkbox/checkbox.stories.tsx
🧬 Code graph analysis (4)
libs/react/ui/src/components/checkbox/checkbox-links.tsx (1)
libs/react/ui/src/components/button/button-link.tsx (1)
  • ButtonLink (46-76)
libs/react/ui/src/components/alert/alert.stories.tsx (2)
libs/react/ui/src/components/input/input.tsx (1)
  • Input (24-43)
libs/react/ui/src/components/button/button.tsx (1)
  • Button (50-91)
libs/react/ui/src/components/alert/alert.tsx (1)
libs/react/ui/src/components/icon/icon.tsx (1)
  • Icon (73-76)
libs/react/ui/src/components/checkbox/checkbox.stories.tsx (1)
libs/react/ui/src/components/checkbox/checkbox-links.tsx (1)
  • CheckboxLinks (23-90)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Agent
  • GitHub Check: Cursor Bugbot
🔇 Additional comments (8)
libs/react/ui/src/components/button/button.tsx (1)

8-8: Cursor + ARIA disabled alignment looks good

Adding cursor-pointer to the base variant and aria-disabled={disabled || isLoading} keeps visual/keyboard behavior consistent with other button-like components and exposes the disabled/loading state to assistive tech, especially when rendered via Slot.

Also applies to: 76-80

libs/react/ui/src/components/button/icon-button.tsx (1)

8-8: IconButton cursor and ARIA updates are consistent with Button

The added cursor-pointer and aria-disabled={disabled || isLoading} mirror the main Button behavior and improve consistency and accessibility for icon-only buttons.

Also applies to: 80-84

libs/react/ui/src/components/button/button-link.tsx (1)

8-8: ButtonLink cursor update aligns with other button components

Adding cursor-pointer to the base buttonLinkVariants matches the rest of the button family and clearly indicates interactivity without changing behavior.

libs/react/ui/src/components/checkbox/checkbox.stories.tsx (1)

359-368: CheckboxLinksStory URL updates are reasonable and consistent

Pointing Terms of use and Privacy Policy at the real /legal URLs, and using window.open with 'noopener,noreferrer' for the onClick variant, aligns the stories with the new CheckboxLinks behavior while keeping external navigation safe.

Also applies to: 375-384

libs/react/ui/src/components/alert/alert.stories.tsx (2)

59-151: Form validation + error toaster story looks solid

The ErrorValidationToasterExample and WithFormValidation story wire up validation, aggregated error messaging, showError state, and Alert’s autoClose behavior coherently. The Dismiss action correctly clears field errors and hides the toaster, and the conditional errorCount > 0 guard keeps the alert mounted only when there are validation errors. No changes needed here.


53-53: Context-based AlertClose usage is correct

Switching AlertClose to be used without a variant prop in both Default and DesignMock aligns with the new context-driven API; the surrounding Alert provides the variant, so these stories will stay visually consistent across variants.

Also applies to: 171-171

libs/react/ui/src/components/alert/alert.tsx (2)

63-163: Alert controlled/uncontrolled state, context, and auto‑close are implemented correctly

The introduction of AlertContext, AlertProps (open, defaultOpen, onOpenChange, animated, transition, autoClose), and the split between animated/non‑animated render paths is coherent and idiomatic:

  • isOpen correctly derives from open when controlled and falls back to internal state otherwise.
  • handleClose respects controlled vs uncontrolled usage while still invoking onOpenChange(false) for consumers.
  • The autoClose effect uses a ref to the latest close handler, avoiding stale closures while ensuring timers are cleaned up when isOpen or autoClose change.
  • Context provisioning covers both animated and non‑animated branches so AlertClose and other subcomponents have consistent access.

Behaviorally this matches expectations for a dismissible, optionally animated alert with auto‑dismiss.


279-290: Exports of new API surface look consistent

Exporting alertDefaultTransition alongside Alert, subcomponents, and the AlertProps type provides a clear public surface for consumers to configure transitions and type their props. The ordering and naming are intuitive; no further changes needed.

@kylengn kylengn merged commit 00b8126 into main Nov 24, 2025
6 checks passed
@kylengn kylengn deleted the chores/alert-button-checkbox branch November 24, 2025 03:26
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