Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

BellNotification.tsx 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. 'use client'
  2. import { Badge, Dropdown, Space, List, Typography, Flex } from 'antd'
  3. import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
  4. import { faBell } from '@fortawesome/free-solid-svg-icons'
  5. const { Text } = Typography
  6. // Example Notification Data
  7. const notifications = [
  8. {
  9. id: '1',
  10. title: 'New Message',
  11. description: 'You have received a new message from John.',
  12. time: '2 min ago',
  13. },
  14. {
  15. id: '2',
  16. title: 'Server Update',
  17. description: 'Server will restart at 12:00 AM.',
  18. time: '10 min ago',
  19. },
  20. {
  21. id: '3',
  22. title: 'Payment Received',
  23. description: 'You have received a payment of $120.',
  24. time: '1 hour ago',
  25. },
  26. ]
  27. const NotificationList = () => (
  28. <div className="w-80 max-h-96 overflow-auto bg-white rounded p-2 border border-gray-200 absolute" style={{right:-16}}>
  29. <List
  30. itemLayout="horizontal"
  31. dataSource={notifications}
  32. renderItem={(item) => (
  33. <List.Item className="hover:bg-gray-50 px-3 py-2 cursor-pointer transition-all">
  34. <List.Item.Meta
  35. title={<Text strong>{item.title}</Text>}
  36. description={
  37. <Flex className="!justify-between !text-gray-500">
  38. <Text className='!text-xs'>{item.description}</Text>
  39. <Text className="!whitespace-nowrap !text-xs">{item.time}</Text>
  40. </Flex>
  41. }
  42. />
  43. </List.Item>
  44. )}
  45. />
  46. </div>
  47. )
  48. const BellNotification = () => {
  49. return (
  50. <Dropdown
  51. popupRender={() => <NotificationList />}
  52. placement="bottomRight"
  53. trigger={['click']}
  54. arrow
  55. >
  56. <Space className="cursor-pointer relative">
  57. <Badge count={notifications.length} size="small" offset={[-2, 2]}>
  58. <FontAwesomeIcon icon={faBell} style={{ fontSize: 20, color: 'black' }} />
  59. </Badge>
  60. </Space>
  61. </Dropdown>
  62. )
  63. }
  64. export default BellNotification