Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

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

CatsJuice301586c0f4b8
diff --git a/packages/frontend/component/src/ui/notification/notification-card.tsx b/packages/frontend/component/src/ui/notification/notification-card.tsx
index 6b1d21f6ab..816c674234 100644
--- a/packages/frontend/component/src/ui/notification/notification-card.tsx
+++ b/packages/frontend/component/src/ui/notification/notification-card.tsx
@@ -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}
diff --git a/packages/frontend/component/src/ui/notification/styles.css.ts b/packages/frontend/component/src/ui/notification/styles.css.ts
index 9c28bf2237..812ccffec2 100644
--- a/packages/frontend/component/src/ui/notification/styles.css.ts
+++ b/packages/frontend/component/src/ui/notification/styles.css.ts
@@ -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({
diff --git a/packages/frontend/component/src/ui/notification/utils.ts b/packages/frontend/component/src/ui/notification/utils.ts
index 814a14a74c..6d09597390 100644
--- a/packages/frontend/component/src/ui/notification/utils.ts
+++ b/packages/frontend/component/src/ui/notification/utils.ts
@@ -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');
+};