fix(component): avoid close button of the notification being invisible in dark mode and bright bg (#6946)

This commit is contained in:
CatsJuice
2024-05-16 06:43:47 +00:00
parent 3cca879a83
commit 301586c0f4
3 changed files with 11 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ import {
getCardBorderColor,
getCardColor,
getCardForegroundColor,
getCloseIconColor,
getIconColor,
} from './utils';
@@ -48,6 +49,7 @@ export const NotificationCard = ({ notification }: NotificationCardProps) => {
[styles.cardForeground]: getCardForegroundColor(style),
[styles.actionTextColor]: getActionTextColor(style, theme),
[styles.iconColor]: getIconColor(style, theme, iconColor),
[styles.closeIconColor]: getCloseIconColor(style),
})}
data-with-icon={icon ? '' : undefined}
{...rootAttrs}

View File

@@ -6,6 +6,7 @@ export const cardForeground = createVar();
export const cardBorderColor = createVar();
export const actionTextColor = createVar();
export const iconColor = createVar();
export const closeIconColor = createVar();
export const card = style({
borderRadius: 8,
@@ -82,7 +83,7 @@ export const closeButton = style({
},
});
export const closeIcon = style({
color: `${cardForeground} !important`,
color: `${closeIconColor} !important`,
});
export const main = style({

View File

@@ -59,7 +59,7 @@ export const getIconColor = (
theme: NotificationTheme,
iconColor?: string
) => {
if (style === 'normal') {
if (style !== 'alert') {
const map: Record<NotificationTheme, string> = {
error: cssVar('errorColor'),
info: cssVar('processingColor'),
@@ -71,3 +71,9 @@ export const getIconColor = (
return iconColor || cssVar('pureWhite');
};
export const getCloseIconColor = (style: NotificationStyle) => {
return style === 'alert'
? getCardForegroundColor(style)
: cssVar('iconColor');
};