Skip to content

Commit 15a0a2f

Browse files
zombieJclaude
andcommitted
refactor: clean up unused code and update stack demo
- Remove unused assignRef helper function - Remove unused itemPrefixCls and noticeWrapperCls variables - Make placement prop required in NotificationListProps - Update stack demo to use geek.less and inline motion config Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5a937ee commit 15a0a2f

File tree

2 files changed

+35
-31
lines changed

2 files changed

+35
-31
lines changed

docs/examples/stack.tsx

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,54 @@
11
/* eslint-disable no-console */
22
import React from 'react';
3-
import '../../assets/index.less';
3+
import type { CSSMotionProps } from '@rc-component/motion';
4+
import '../../assets/geek.less';
45
import { useNotification } from '../../src';
5-
import motion from './motion';
66

77
const Context = React.createContext({ name: 'light' });
88

9+
const motion: CSSMotionProps = {
10+
motionName: 'notification-fade',
11+
motionAppear: true,
12+
motionEnter: true,
13+
motionLeave: true,
14+
};
15+
916
const getConfig = () => ({
1017
description: `${Array(Math.round(Math.random() * 5) + 1)
1118
.fill(1)
1219
.map(() => new Date().toISOString())
1320
.join('\n')}`,
14-
duration: null,
21+
duration: false as const,
1522
});
1623

1724
const Demo = () => {
18-
const [{ open }, holder] = useNotification({ motion, stack: true, closable: true });
25+
const [{ open }, holder] = useNotification({
26+
motion,
27+
stack: { threshold: 3, offset: 20 },
28+
closable: true,
29+
prefixCls: 'notification',
30+
});
1931

2032
return (
2133
<Context.Provider value={{ name: 'bamboo' }}>
22-
<button
23-
type="button"
24-
onClick={() => {
25-
open(getConfig());
26-
}}
27-
>
28-
Top Right
29-
</button>
30-
<button
31-
type="button"
32-
onClick={() => {
33-
open({ ...getConfig(), placement: 'bottomRight' });
34-
}}
35-
>
36-
Bottom Right
37-
</button>
34+
<div style={{ marginBottom: 16, display: 'flex', flexWrap: 'wrap', gap: 8 }}>
35+
<button
36+
type="button"
37+
onClick={() => {
38+
open(getConfig());
39+
}}
40+
>
41+
Top Right
42+
</button>
43+
<button
44+
type="button"
45+
onClick={() => {
46+
open({ ...getConfig(), placement: 'bottomRight' });
47+
}}
48+
>
49+
Bottom Right
50+
</button>
51+
</div>
3852
{holder}
3953
</Context.Provider>
4054
);

src/NotificationList.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export interface NotificationListConfig extends Omit<NotificationProps, 'prefixC
2727
export interface NotificationListProps {
2828
configList?: NotificationListConfig[];
2929
prefixCls?: string;
30-
placement?: Placement;
30+
placement: Placement;
3131
pauseOnHover?: boolean;
3232
classNames?: NotificationClassNames;
3333
styles?: NotificationStyles;
@@ -40,14 +40,6 @@ export interface NotificationListProps {
4040
onAllRemoved?: (placement: Placement) => void;
4141
}
4242

43-
function assignRef<T>(ref: React.Ref<T>, value: T | null) {
44-
if (typeof ref === 'function') {
45-
ref(value);
46-
} else if (ref) {
47-
(ref as React.MutableRefObject<T | null>).current = value;
48-
}
49-
}
50-
5143
const NotificationList: React.FC<NotificationListProps> = (props) => {
5244
const {
5345
configList = [],
@@ -118,8 +110,6 @@ const NotificationList: React.FC<NotificationListProps> = (props) => {
118110

119111
// ========================= Render =========================
120112
const listPrefixCls = `${prefixCls}-list`;
121-
const itemPrefixCls = `${listPrefixCls}-item`;
122-
const noticeWrapperCls = `${prefixCls}-notice-wrapper`;
123113

124114
return (
125115
<div

0 commit comments

Comments
 (0)