Skip to content

Commit a1bd974

Browse files
zombieJclaude
andcommitted
refactor: reorganize Notification props and simplify CSS structure
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8941e61 commit a1bd974

File tree

3 files changed

+47
-43
lines changed

3 files changed

+47
-43
lines changed

assets/geek.less

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,17 @@
44
@notificationMotionOffset: 64px;
55

66
.@{notificationPrefixCls} {
7-
&-list {
8-
position: fixed;
9-
top: 0;
10-
right: 0;
11-
z-index: 1000;
12-
width: 360px;
13-
height: 100vh;
14-
padding: 24px;
15-
box-sizing: border-box;
16-
pointer-events: none;
17-
overflow: hidden;
18-
overscroll-behavior: contain;
19-
}
7+
position: fixed;
8+
top: 0;
9+
right: 0;
10+
z-index: 1000;
11+
width: 360px;
12+
height: 100vh;
13+
padding: 24px;
14+
box-sizing: border-box;
15+
pointer-events: none;
16+
overflow: hidden;
17+
overscroll-behavior: contain;
2018

2119
&-list-content {
2220
position: relative;

src/Notification.tsx

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,49 +21,61 @@ export interface NotificationStyles {
2121
}
2222

2323
export interface NotificationProps {
24+
// Style
2425
prefixCls?: string;
26+
className?: string;
27+
style?: React.CSSProperties;
28+
classNames?: NotificationClassNames;
29+
styles?: NotificationStyles;
30+
31+
// UI
2532
content?: React.ReactNode;
2633
actions?: React.ReactNode;
2734
close?: React.ReactNode;
2835
closable?:
2936
| boolean
3037
| ({ closeIcon?: React.ReactNode; onClose?: VoidFunction } & React.AriaAttributes);
31-
duration?: number | false | null;
32-
showProgress?: boolean;
33-
times?: number;
34-
hovering?: boolean;
3538
offset?: {
3639
x: number;
3740
y: number;
3841
};
42+
43+
// Behavior
44+
duration?: number | false | null;
45+
showProgress?: boolean;
46+
times?: number;
47+
hovering?: boolean;
3948
pauseOnHover?: boolean;
40-
className?: string;
41-
style?: React.CSSProperties;
42-
classNames?: NotificationClassNames;
43-
styles?: NotificationStyles;
44-
props?: React.HTMLAttributes<HTMLDivElement> & Record<string, any>;
49+
50+
// Function
4551
onClick?: React.MouseEventHandler<HTMLDivElement>;
4652
onClose?: () => void;
4753
onCloseInternal?: VoidFunction;
4854
}
4955

5056
const Notification = React.forwardRef<HTMLDivElement, NotificationProps>((props, ref) => {
5157
const {
58+
// Style
5259
prefixCls = 'rc-notification',
60+
className,
61+
style,
62+
classNames,
63+
styles,
64+
65+
// UI
5366
content,
5467
actions,
5568
close,
5669
closable,
70+
offset,
71+
72+
// Behavior
5773
duration = 4.5,
5874
showProgress,
5975
hovering: forcedHovering,
60-
offset,
6176
pauseOnHover = true,
62-
className,
63-
style,
64-
classNames,
65-
styles,
66-
props: divProps,
77+
78+
// Function
6779
onClick,
6880
onClose,
6981
onCloseInternal,
@@ -121,8 +133,9 @@ const Notification = React.forwardRef<HTMLDivElement, NotificationProps>((props,
121133
// ========================= Render =========================
122134
return (
123135
<div
124-
{...divProps}
136+
{...rootProps}
125137
ref={ref}
138+
// Styles
126139
className={clsx(noticePrefixCls, className, classNames?.root, {
127140
[`${noticePrefixCls}-closable`]: mergedClosable,
128141
})}
@@ -136,20 +149,21 @@ const Notification = React.forwardRef<HTMLDivElement, NotificationProps>((props,
136149
: null),
137150
...style,
138151
}}
152+
// Events
139153
onClick={onClick}
140154
onMouseEnter={(event) => {
141155
setHovering(true);
142156
if (pauseOnHover) {
143157
onPause();
144158
}
145-
divProps?.onMouseEnter?.(event);
159+
rootProps?.onMouseEnter?.(event);
146160
}}
147161
onMouseLeave={(event) => {
148162
setHovering(false);
149163
if (pauseOnHover && !forcedHovering) {
150164
onResume();
151165
}
152-
divProps?.onMouseLeave?.(event);
166+
rootProps?.onMouseLeave?.(event);
153167
}}
154168
>
155169
<div

src/NotificationList.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,10 @@ const NotificationList: React.FC<NotificationListProps> = (props) => {
119119

120120
return (
121121
<div
122-
className={clsx(
123-
prefixCls,
124-
`${prefixCls}-${placement}`,
125-
listPrefixCls,
126-
`${listPrefixCls}-${placement}`,
127-
contextClassNames?.list,
128-
className,
129-
{
130-
[`${prefixCls}-stack`]: stackEnabled,
131-
[`${prefixCls}-stack-expanded`]: expanded,
132-
},
133-
)}
122+
className={clsx(prefixCls, `${prefixCls}-${placement}`, contextClassNames?.list, className, {
123+
[`${prefixCls}-stack`]: stackEnabled,
124+
[`${prefixCls}-stack-expanded`]: expanded,
125+
})}
134126
onWheel={onWheel}
135127
onMouseEnter={() => {
136128
setListHovering(true);

0 commit comments

Comments
 (0)