@papernote/ui 1.9.1 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/NotificationBell.d.ts.map +1 -1
- package/dist/index.esm.js +52 -40
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +52 -40
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/NotificationBell.stories.tsx +42 -0
- package/src/components/NotificationBell.tsx +8 -4
package/package.json
CHANGED
|
@@ -227,6 +227,48 @@ export const Default: Story = {
|
|
|
227
227
|
},
|
|
228
228
|
};
|
|
229
229
|
|
|
230
|
+
export const Playground: Story = {
|
|
231
|
+
args: {
|
|
232
|
+
notifications: sampleNotifications,
|
|
233
|
+
variant: 'compact',
|
|
234
|
+
bellStyle: 'ghost',
|
|
235
|
+
dropdownPosition: 'bottom-right',
|
|
236
|
+
size: 'md',
|
|
237
|
+
showUnreadInHeader: false,
|
|
238
|
+
loading: false,
|
|
239
|
+
disabled: false,
|
|
240
|
+
maxHeight: '400px',
|
|
241
|
+
emptyMessage: 'No notifications',
|
|
242
|
+
viewAllText: 'View all notifications',
|
|
243
|
+
},
|
|
244
|
+
render: (args) => {
|
|
245
|
+
const [notifications, setNotifications] = useState(args.notifications);
|
|
246
|
+
|
|
247
|
+
const handleMarkAsRead = (id: string) => {
|
|
248
|
+
setNotifications((prev) =>
|
|
249
|
+
prev.map((n) => (n.id === id ? { ...n, isRead: true } : n))
|
|
250
|
+
);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
const handleMarkAllRead = () => {
|
|
254
|
+
setNotifications((prev) => prev.map((n) => ({ ...n, isRead: true })));
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
return (
|
|
258
|
+
<div style={{ padding: '250px', display: 'flex', justifyContent: 'center', minHeight: '600px' }}>
|
|
259
|
+
<NotificationBell
|
|
260
|
+
{...args}
|
|
261
|
+
notifications={notifications}
|
|
262
|
+
onMarkAsRead={handleMarkAsRead}
|
|
263
|
+
onMarkAllRead={handleMarkAllRead}
|
|
264
|
+
onNotificationClick={(n) => alert(`Navigate to: ${n.actionUrl}`)}
|
|
265
|
+
onViewAll={() => alert('View all notifications')}
|
|
266
|
+
/>
|
|
267
|
+
</div>
|
|
268
|
+
);
|
|
269
|
+
},
|
|
270
|
+
};
|
|
271
|
+
|
|
230
272
|
export const DetailedVariant: Story = {
|
|
231
273
|
render: () => {
|
|
232
274
|
const [notifications, setNotifications] = useState(bankingNotifications);
|
|
@@ -138,19 +138,23 @@ const defaultTypeLabels: Record<NotificationItem['type'], string> = {
|
|
|
138
138
|
|
|
139
139
|
/**
|
|
140
140
|
* Map dropdown position to Popover placement
|
|
141
|
+
* - bottom-right: Below bell, dropdown's right edge aligns with bell
|
|
142
|
+
* - bottom-left: Below bell, dropdown's left edge aligns with bell
|
|
143
|
+
* - top-right: Above bell, dropdown's right edge aligns with bell
|
|
144
|
+
* - top-left: Above bell, dropdown's left edge aligns with bell
|
|
141
145
|
*/
|
|
142
146
|
function getPopoverPlacement(position: NotificationBellPosition): 'bottom-start' | 'bottom-end' | 'top-start' | 'top-end' {
|
|
143
147
|
switch (position) {
|
|
144
148
|
case 'bottom-right':
|
|
145
149
|
case 'right':
|
|
146
|
-
return 'bottom-start';
|
|
150
|
+
return 'bottom-start'; // Below, extends to the right
|
|
147
151
|
case 'bottom-left':
|
|
148
152
|
case 'left':
|
|
149
|
-
return 'bottom-end';
|
|
153
|
+
return 'bottom-end'; // Below, extends to the left
|
|
150
154
|
case 'top-right':
|
|
151
|
-
return 'top-start';
|
|
155
|
+
return 'top-start'; // Above, extends to the right
|
|
152
156
|
case 'top-left':
|
|
153
|
-
return 'top-end';
|
|
157
|
+
return 'top-end'; // Above, extends to the left
|
|
154
158
|
default:
|
|
155
159
|
return 'bottom-start';
|
|
156
160
|
}
|