feat: alert component
📝 Description
- closes: #2250
- closes: https://github.com/nextui-org/nextui/discussions/313
Summary by CodeRabbit
-
New Features
- Introduced a new Alert component for user notifications and alerts.
- Added support for customizable alert configurations including colors, radius, and closability.
- New icons for different alert types (Success, Danger, Info, Warning) implemented.
-
Documentation
- New README and comprehensive documentation for the Alert component added.
- Expanded documentation structure to include the Alert component.
-
Tests
- Implemented a test suite to ensure the functionality of the Alert component.
- Added Storybook stories to showcase various alert configurations.
🦋 Changeset detected
Latest commit: eebab5d520ca832f577eea849eb16d4f64cb00f2
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 3 packages
| Name | Type |
|---|---|
| @nextui-org/alert | Minor |
| @nextui-org/theme | Minor |
| @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
@abhinav700 is attempting to deploy a commit to the NextUI Inc Team on Vercel.
A member of the Team first needs to authorize it.
Walkthrough
The changes introduce a new Alert component to the project, incorporating dependencies from the @nextui-org library. This component allows for user notifications and alerts, enhancing the application's feedback mechanism. The update includes new files for various alert configurations, documentation, and a test suite. Additionally, the routes.json file has been modified to include the Alert component, and several new React components and utilities have been added to support the Alert's functionality.
Changes
| Files/Paths | Change Summary |
|---|---|
.changeset/poor-sheep-repair.md |
Summary of changes and new Alert component details. |
apps/docs/config/routes.json |
New entry for Alert component added. |
apps/docs/content/components/alert/*.ts |
Multiple new components (colors.ts, isClosable.ts, radius.ts, index.ts, alert.tsx, use-alert.ts) added. |
packages/components/alert/* |
New Alert component, test suite, README, and various icons added. |
packages/core/react/package.json |
Dependency for @nextui-org/alert added. |
packages/core/theme/src/components/alert.ts |
New alert-related types and exports added. |
packages/utilities/shared-icons/src/*.tsx |
New icon components (DangerIcon, InfoCircleIcon, SuccessIcon, WarningIcon) added. |
packages/components/alert/package.json |
New package declaration for @nextui-org/alert with version 2.0.0. |
packages/components/alert/__tests__/alert.test.tsx |
New test suite for the Alert component created. |
packages/components/alert/stories/alert.stories.tsx |
New Storybook stories for the Alert component added. |
packages/components/alert/tsconfig.json |
New TypeScript configuration file added. |
packages/components/alert/tsup.config.ts |
New configuration file for building the Alert component. |
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
| Introduce an Alert component for user notifications (#2250) | ✅ | |
| Provide configurations for different alert types (#2250) | ✅ | |
| Ensure the component is well-documented (#2250) | ✅ | |
| Include a test suite for the new component (#2250) | ✅ |
Suggested labels
👀 Status: In Review, 📋 Scope : Docs
Suggested reviewers
- wingkwong
- ryo-manba
- jrgarciadev
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?
🪧 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
@coderabbitaiin 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
@coderabbitaiin 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 pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full reviewto do a full review from scratch and review all the files again. -
@coderabbitai summaryto regenerate the summary of the PR. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai configurationto show the current CodeRabbit configuration for the repository. -
@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere 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.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| nextui-docs-v2 | ❌ Failed (Inspect) | Nov 4, 2024 11:52am | ||
| nextui-storybook-v2 | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Nov 4, 2024 11:52am |
^ please also handle RTL
@wingkwong can you explain what you mean by this? isn't it correctly displayed ?
You can see the space between the icon and title is not consistent.
Okay I will fix that.
is it okay?
Yes as long as the space is consistent.
I have made the changes. I have ignored some of the changes recommended by coderabbit because they were not consistent with codebase of other components.
Changes made:
-
isClosableis false by default (setting it true seemed weird given the prescence ofonClose) - fixed the close button
- changed the docs for close button
- added a test case for close button
- please handle responsive case.
By adding different variants for sm , md and lg right?
@abhinav700 you may try by resizing the browser to see and compare with input component.
@abhinav700 you may try by resizing the browser to see and compare with input component.
@wingkwong I have added breakpoints to change the width and make it more responsive. can you check it?
@abhinav700 i think the reason is you have the fixed width so it won't shrink when the window is resizing. You may try if you put two alert on the same row and resize the container. Adding breakpoint doesn't solve the full problem since it may not reach the breakpoint.
@abhinav700 i think the reason is you have the fixed width so it won't shrink when the window is resizing. You may try if you put two alert on the same row and resize the container. Adding breakpoint doesn't solve the full problem since it may not reach the breakpoint.
I think my original code would work if I replace w- with max-w-
is this output acceptable?
https://github.com/user-attachments/assets/ba01d876-d782-4dd4-8158-f4cd4e0b3386
Let's discuss in discord.
Okay, will look into that
please click re-request review once it's ready
Hey @abhinav700 thanks for contributing and creating this component, please check my changes https://github.com/nextui-org/nextui/pull/3982