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: icon wrapper border on alert component #4383

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/many-kiwis-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@nextui-org/alert": patch
"@nextui-org/theme": patch
---

Fix #4382 `hideIconWrapper` property wasn't removing the borded on `Alert` component
2 changes: 1 addition & 1 deletion packages/components/alert/src/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const iconMap = {

export type AlertColor = keyof typeof iconMap;

export interface AlertProps extends Omit<UseAlertProps, "hasDescription"> {}
export interface AlertProps extends Omit<UseAlertProps, "hasContent"> {}

const Alert = forwardRef<"div", AlertProps>((props, ref) => {
const {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/alert/src/use-alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export function useAlert(originalProps: UseAlertProps) {
}, [setIsVisible, onClose]);

const slots = useMemo(
() => alert({hasDescription: !isEmpty(description), ...variantProps}),
() => alert({hasContent: !isEmpty(description) || !isEmpty(children), ...variantProps}),
[description, objectToDeps(variantProps)],
);

Expand Down
10 changes: 9 additions & 1 deletion packages/components/alert/stories/alert.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ const CustomStylesTemplate = (args) => {
color={color}
title="The documents you requested are ready to be viewed"
>
<div className="flex items-center gap-1 mt-3">
<div className="flex items-center gap-1">
<Button
className="bg-background text-default-700 font-medium border-1 shadow-small"
size="sm"
Expand Down Expand Up @@ -226,6 +226,14 @@ export const WithDescription = {
},
};

export const WithoutIconWrapper = {
render: Template,
args: {
...defaultProps,
hideIconWrapper: true,
},
};

export const Color = {
render: ColorTemplate,
args: {
Expand Down
8 changes: 4 additions & 4 deletions packages/core/theme/src/components/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const alert = tv({
title: "text-small w-full font-medium block text-inherit leading-5",
description: "pl-[1px] text-small font-normal text-inherit",
closeButton: "relative text-inherit translate-x-1 -translate-y-1",
iconWrapper: "flex-none relative w-9 h-9 rounded-full",
iconWrapper: "flex-none relative w-9 h-9 rounded-full grid place-items-center",
alertIcon: "fill-current w-6 absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",
},
variants: {
Expand Down Expand Up @@ -76,13 +76,13 @@ const alert = tv({
hideIconWrapper: {
true: {
base: "gap-x-0",
iconWrapper: "!bg-transparent !shadow-none",
iconWrapper: "!bg-transparent !shadow-none !border-none",
},
},
hasDescription: {
hasContent: {
false: {
base: "items-start",
mainWrapper: "justify-center",
mainWrapper: "justify-center items-center",
},
},
},
Expand Down
Loading