nextui icon indicating copy to clipboard operation
nextui copied to clipboard

feat: alert component

Open abhinav700 opened this issue 1 year ago • 16 comments

📝 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.

abhinav700 avatar Aug 23 '24 10:08 abhinav700

🦋 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

changeset-bot[bot] avatar Aug 23 '24 10:08 changeset-bot[bot]

@abhinav700 is attempting to deploy a commit to the NextUI Inc Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Aug 23 '24 10:08 vercel[bot]

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?

❤️ 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 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.

coderabbitai[bot] avatar Aug 23 '24 10:08 coderabbitai[bot]

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

vercel[bot] avatar Sep 04 '24 11:09 vercel[bot]

^ please also handle RTL

@wingkwong can you explain what you mean by this? isn't it correctly displayed ?

abhinav700 avatar Sep 28 '24 16:09 abhinav700

You can see the space between the icon and title is not consistent.

image

image

wingkwong avatar Sep 28 '24 16:09 wingkwong

Okay I will fix that.

abhinav700 avatar Sep 28 '24 17:09 abhinav700

is it okay? image

abhinav700 avatar Sep 29 '24 06:09 abhinav700

Yes as long as the space is consistent.

wingkwong avatar Sep 29 '24 08:09 wingkwong

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:

  1. isClosable is false by default (setting it true seemed weird given the prescence of onClose)
  2. fixed the close button
  3. changed the docs for close button
  4. added a test case for close button

abhinav700 avatar Sep 29 '24 10:09 abhinav700

  1. please handle responsive case.

By adding different variants for sm , md and lg right?

abhinav700 avatar Oct 14 '24 03:10 abhinav700

@abhinav700 you may try by resizing the browser to see and compare with input component.

wingkwong avatar Oct 14 '24 04:10 wingkwong

@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 avatar Oct 16 '24 05:10 abhinav700

@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.

wingkwong avatar Oct 16 '24 05:10 wingkwong

@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

abhinav700 avatar Oct 16 '24 14:10 abhinav700

Let's discuss in discord.

wingkwong avatar Oct 16 '24 15:10 wingkwong

Okay, will look into that

abhinav700 avatar Oct 20 '24 15:10 abhinav700

please click re-request review once it's ready

wingkwong avatar Oct 29 '24 04:10 wingkwong

Hey @abhinav700 thanks for contributing and creating this component, please check my changes https://github.com/nextui-org/nextui/pull/3982

jrgarciadev avatar Nov 04 '24 13:11 jrgarciadev