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

feat: alert component #3680

Draft
wants to merge 45 commits into
base: canary
Choose a base branch
from

Conversation

abhinav700
Copy link

@abhinav700 abhinav700 commented Aug 23, 2024

Copy link

changeset-bot bot commented Aug 23, 2024

🦋 Changeset detected

Latest commit: 7003759

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

Copy link

vercel bot commented Aug 23, 2024

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

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Aug 23, 2024

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

@wingkwong wingkwong changed the title Beginning the work on adding alert component feat: alert component Aug 23, 2024
@wingkwong wingkwong added this to the v2.5.0 milestone Aug 23, 2024
apps/docs/tsconfig.json Outdated Show resolved Hide resolved
packages/components/alert/src/alert-icons.tsx Outdated Show resolved Hide resolved
packages/components/alert/src/alert-icons.tsx Outdated Show resolved Hide resolved
packages/components/alert/src/alert.tsx Outdated Show resolved Hide resolved
packages/components/alert/src/use-alert.ts Outdated Show resolved Hide resolved
packages/components/alert/src/use-alert.ts Outdated Show resolved Hide resolved
packages/components/alert/src/use-alert.ts Outdated Show resolved Hide resolved
packages/components/alert/src/use-alert.ts Outdated Show resolved Hide resolved
packages/components/alert/src/alert.tsx Outdated Show resolved Hide resolved
Copy link

vercel bot commented Sep 4, 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 Sep 4, 2024 11:26am
nextui-storybook-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 4, 2024 11:26am

Copy link
Member

@wingkwong wingkwong left a comment

Choose a reason for hiding this comment

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

please change all isCloseable to isClosable

Comment on lines 12 to 28
case "primary":
return <CloseIcon className={`fill-current text-primary-200`} height={20} width={20} />;

case "secondary":
return <CloseIcon className={`fill-current text-secondary-200`} height={20} width={20} />;

case "success":
return <CloseIcon className={`fill-current text-success-200`} height={20} width={20} />;

case "warning":
return <CloseIcon className={`fill-current text-warning-200`} height={20} width={20} />;

case "danger":
return <CloseIcon className={`fill-current text-danger-200`} height={20} width={20} />;

default:
return <CloseIcon className={`fill-current text-default-400`} height={20} width={20} />;
Copy link
Member

Choose a reason for hiding this comment

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

there is no variable used in className. You can simply use string. e.g.

className="fill-current text-primary-200"

Copy link
Author

Choose a reason for hiding this comment

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

Must have forgot to change that from my previous code. will make changes.

Comment on lines 34 to 45
case "primary":
return <SuccessIcon className={`fill-current text-primary`} />;
case "secondary":
return <SuccessIcon className={`fill-current text-secondary`} />;
case "success":
return <SuccessIcon className={`fill-current text-success`} />;
case "warning":
return <WarningIcon className={`fill-current text-warning`} />;
case "danger":
return <DangerIcon className={`fill-current text-danger`} />;
default:
return <InfoCircleIcon className={`fill-current text-default-foreground`} />;
Copy link
Member

Choose a reason for hiding this comment

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

same as above

Comment on lines 16 to 24
/**
* title of the alert message
*/
title: string;

/**
* Main body of the alert message
*/
description: ReactNode;
Copy link
Member

Choose a reason for hiding this comment

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

i think title should be optional while description is mandatory.

Copy link
Author

Choose a reason for hiding this comment

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

ok. will make the changes.

* @example
* ```ts
* <Alert classNames={{
* base:"base-classes", // image classes
Copy link
Member

Choose a reason for hiding this comment

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

// image classes is wrong

Comment on lines 63 to 71
/**
* isCloseable is true by default if not provided in props
*/
isCloseable: true,

/**
* By default, onClose simply closes the alert
*/
onClose: handleClose,
Copy link
Member

Choose a reason for hiding this comment

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

what's the reason defining there here while they are already in props? or you just wanna define the default value? if so, you can simply do in this way

  const {title, description, onClose = handleClose, isCloseable = true, ref, classNames} = props;

Copy link
Author

Choose a reason for hiding this comment

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

yeah, I was trying to set defautl values. Will use the syntax you suggested.

Comment on lines 72 to 81
base: "rounded-[12px]",
},
md: {
base: "rounded-[16px]",
},
lg: {
base: "rounded-[22px]",
},
full: {
base: "rounded-[9999px]",
Copy link
Member

Choose a reason for hiding this comment

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

use TW class. e.g. small, medium, large, full.


const alert = tv({
slots: {
base: ["group flex flex-row w-[342px] h-[68px] p-[12px]"],
Copy link
Member

Choose a reason for hiding this comment

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

  1. group -> group/alert so that it won't conflict with other components.
  2. may double check if you really need group here or not

Copy link
Author

Choose a reason for hiding this comment

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

Yeah we might not need it here. Will check it.

Comment on lines 28 to 32
base: ["group flex flex-row w-[342px] h-[68px] p-[12px]"],
title: ["text-medium font-normal block h-[24px]"],
description: ["text-small font-normal h-[20px]"],
mainWrapper: ["w-[268px] h-[44px] ml-[20px] flex flex-col box-border items-start"],
closeButton: ["w-[24px h-[24px] cursor-pointer relative"],
Copy link
Member

Choose a reason for hiding this comment

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

don't use fixed values here.

Copy link
Author

Choose a reason for hiding this comment

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

can you explain in more detail

Copy link
Member

Choose a reason for hiding this comment

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

We don't use the arbitrary values but TW classes. e.g. p-[12px] -> p-3, h-[20px] -> h-5.

Copy link
Author

Choose a reason for hiding this comment

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

ok

import React from "react";

import {IconSvgProps} from "./types";
export const InfoCircleIcon = (
Copy link
Member

Choose a reason for hiding this comment

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

add a new line before export (apply to other files)

@@ -0,0 +1,21 @@
import React from "react";
Copy link
Member

Choose a reason for hiding this comment

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

declare but never read. (please check other files as well)

@wingkwong wingkwong reopened this Sep 8, 2024
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.

[Feature Request] We really need a Alert component.
2 participants