Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(alert): slots & variantProps import #4365

Merged
merged 1 commit into from
Dec 17, 2024
Merged

fix(alert): slots & variantProps import #4365

merged 1 commit into from
Dec 17, 2024

Conversation

wingkwong
Copy link
Member

@wingkwong wingkwong commented Dec 15, 2024

Closes #4336

📝 Description

⛳️ Current behavior (updates)

image

🚀 New behavior

image

💣 Is this a breaking change (Yes/No):

📝 Additional Information

@wingkwong wingkwong added this to the v2.6.9 milestone Dec 15, 2024
Copy link

linear bot commented Dec 15, 2024

Copy link

changeset-bot bot commented Dec 15, 2024

🦋 Changeset detected

Latest commit: 0d429c4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@nextui-org/alert Patch
@nextui-org/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Dec 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextui-docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 15, 2024 7:04am
nextui-storybook-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 15, 2024 7:04am

Copy link
Contributor

coderabbitai bot commented Dec 15, 2024

Walkthrough

The pull request addresses an issue with the Alert component in the NextUI library by updating the use-alert.ts file. The changes focus on improving the component's type definitions and import statements, specifically adding a classNames property to the Props interface. This modification allows for more flexible styling options and enhances the component's type completeness, addressing the reported issue with prop auto-completion.

Changes

File Change Summary
packages/components/alert/src/use-alert.ts - Updated import statements from @nextui-org/theme
- Added classNames property to Props interface
- Updated UseAlertProps type definition
.changeset/polite-dingos-call.md Changeset file for tracking the patch release

Assessment against linked issues

Objective Addressed Explanation
Include all available props for Alert component
Improve auto-completion for Alert component props

Possibly related PRs

Suggested labels

📋 Scope : Docs

Suggested reviewers

  • jrgarciadev

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. This feature will be included in our Pro Plan when released.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

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

🧹 Nitpick comments (1)
packages/components/alert/src/use-alert.ts (1)

Line range hint 73-73: Add JSDoc documentation for the classNames property

While the example in the code comment is helpful, consider adding a brief description of the property's purpose in JSDoc format, consistent with other properties in the interface.

   * }} />
   * ```
   */
+  /**
+   * Classnames for each slot of the Alert component.
+   * Use this prop to apply custom styles to specific parts of the component.
+   */
  classNames?: SlotsToClasses<AlertSlots>;
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8d53e8b and 0d429c4.

📒 Files selected for processing (2)
  • .changeset/polite-dingos-call.md (1 hunks)
  • packages/components/alert/src/use-alert.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/polite-dingos-call.md
🔇 Additional comments (3)
packages/components/alert/src/use-alert.ts (3)

2-2: LGTM: Import consolidation improves code organization

The consolidation of type imports from @nextui-org/theme package improves code organization and maintainability.


Line range hint 77-77: LGTM: Type definition properly combines Props and AlertVariantProps

The type composition ensures proper typing for both component props and variant props.


Line range hint 142-147: LGTM: Consistent and type-safe implementation of classNames

The implementation correctly handles the optional classNames prop and consistently applies it across all slots.

Let's verify that all slots are properly typed and no slots are missing:

Also applies to: 151-156, 160-165, 169-174, 176-181, 183-188

✅ Verification successful

Let me search for the AlertSlots type definition to ensure we have all the information needed.


Let me check the alert theme function to see all the slots it defines.


Let me fix the regex syntax:


All Alert slots are properly implemented and type-safe

The implementation correctly handles all seven slots defined in the theme package:

  • base
  • mainWrapper
  • description
  • title
  • closeButton
  • alertIcon
  • iconWrapper

Each slot is consistently implemented with proper optional chaining for classNames, and the usage matches exactly with the slots defined in the theme package.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all Alert slots defined in the theme package are handled in the hook

# Search for Alert slots definition in the theme package
ast-grep --pattern 'export type AlertSlots = {
  $$$
}'

# Search for all slot usage in the current file
rg 'slots\.[a-zA-Z]+\(' packages/components/alert/src/use-alert.ts

Length of output: 586


Script:

#!/bin/bash
# Search for AlertSlots type definition in a more flexible way
rg -A 10 "AlertSlots" 

Length of output: 2021


Script:

#!/bin/bash
# Search for the alert theme function definition
rg -A 20 "const alert = tv\({" packages/core/theme/src/components/alert.ts

Length of output: 178


Script:

#!/bin/bash
# Search for the alert theme function definition
rg -A 20 "const alert = tv" packages/core/theme/src/components/alert.ts

Length of output: 828

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.

[BUG] - Alert component don't show available props
2 participants