fix(notification): prevent colorful background when CSS variables are disabled (#55785)

* fix(notification): prevent colorful background when CSS variables are disabled

This fix conditionally applies type-specific background colors (success, error, info, warning) only when the color values exist. This prevents the notification component from showing unexpected colorful backgrounds when CSS variables are disabled (cssVar: false).

Fixes #55765

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* refactor(notification): use reduce pattern for type-specific backgrounds

Refactor the conditional background color application to use Object.entries
and reduce pattern, making the code more maintainable and DRY. This approach
makes it easier to add new notification types in the future.

Co-authored-by: gemini-code-assist[bot] <gemini-code-assist[bot]@users.noreply.github.com>

* Refactor notification styles for background colors

Signed-off-by: lijianan <574980606@qq.com>

---------

Signed-off-by: lijianan <574980606@qq.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: gemini-code-assist[bot] <gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: lijianan <574980606@qq.com>
This commit is contained in:
Yueming Gao
2025-11-21 02:09:49 +08:00
committed by GitHub
parent b40fb8a832
commit b4168a0f29

View File

@@ -156,20 +156,11 @@ export const genNoticeStyle = (token: NotificationToken): CSSObject => {
wordWrap: 'break-word',
borderRadius: borderRadiusLG,
overflow: 'hidden',
// Type-specific background colors
'&-success': {
background: colorSuccessBg,
},
'&-error': {
background: colorErrorBg,
},
'&-info': {
background: colorInfoBg,
},
'&-warning': {
background: colorWarningBg,
},
'&-success': colorSuccessBg ? { background: colorSuccessBg } : {},
'&-error': colorErrorBg ? { background: colorErrorBg } : {},
'&-info': colorInfoBg ? { background: colorInfoBg } : {},
'&-warning': colorWarningBg ? { background: colorWarningBg } : {},
},
[`${noticeCls}-message`]: {