Skip to content

Commit 8941e61

Browse files
zombieJclaude
andcommitted
refactor: move useStack hook from legacy to hooks directory
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f29b125 commit 8941e61

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

assets/geek.less

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@
8484
}
8585
}
8686
}
87+
88+
&-stack {
89+
&:not(.@{notificationPrefixCls}-stack-expanded) {
90+
.@{notificationPrefixCls}-list-item:nth-last-child(n + 4) {
91+
opacity: 0;
92+
pointer-events: none;
93+
}
94+
}
95+
}
8796
}
8897

8998
.notification-fade {

src/NotificationList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { clsx } from 'clsx';
44
import * as React from 'react';
55
import type { StackConfig } from './interface';
66
import { NotificationContext } from './legacy/NotificationProvider';
7-
import useStack from './legacy/hooks/useStack';
87
import Notification, {
98
type NotificationClassNames,
109
type NotificationProps,
1110
type NotificationStyles,
1211
} from './Notification';
1312
import useListPosition from './hooks/useListPosition';
1413
import useListScroll from './hooks/useListScroll';
14+
import useStack from './hooks/useStack';
1515

1616
export type Placement = 'top' | 'topLeft' | 'topRight' | 'bottom' | 'bottomLeft' | 'bottomRight';
1717
export type { StackConfig } from './interface';

src/hooks/useStack.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type { StackConfig } from '../interface';
2+
3+
const DEFAULT_OFFSET = 8;
4+
const DEFAULT_THRESHOLD = 3;
5+
6+
type StackParams = Required<StackConfig>;
7+
8+
type UseStack = (config?: boolean | StackConfig) => [boolean, StackParams];
9+
10+
const useStack: UseStack = (config) => {
11+
const result: StackParams = {
12+
offset: DEFAULT_OFFSET,
13+
threshold: DEFAULT_THRESHOLD,
14+
};
15+
16+
if (config && typeof config === 'object') {
17+
result.offset = config.offset ?? DEFAULT_OFFSET;
18+
result.threshold = config.threshold ?? DEFAULT_THRESHOLD;
19+
}
20+
21+
return [!!config, result];
22+
};
23+
24+
export default useStack;

0 commit comments

Comments
 (0)