Overview
Many modern applications rely on a centralized notification system to keep users informed about important updates, activities, and system alerts. This problem challenges you to build a functional Notification Center component, demonstrating your ability to manage complex UI state, handle user interactions, and render dynamic data efficiently. You will implement features crucial for a seamless user experience, such as filtering, read/unread status management, and dynamic loading of notifications.
What you need to do / Task
Your goal is to implement a NotificationCenter React component that displays a list of notifications and provides interaction capabilities.
- Display Notifications: Render a list of notifications. Each notification item should display its type (e.g., info, warning), a descriptive message, a relative timestamp (e.g., "5 minutes ago"), and its current read/unread status.
- Toggle Read Status:
- Allow users to individually mark a notification as read or unread.
- Implement a "Mark all as read" button that changes the status of all currently displayed unread notifications to read.
- Dismiss Notifications:
- Allow users to dismiss (remove) individual notifications from the list.
- Implement a "Clear all read" button that removes all notifications currently marked as read from the list.
- Filter Notifications: Provide controls to filter the displayed notifications:
- "All": Shows all notifications.
- "Unread": Shows only unread notifications.
- Load More Notifications: Implement a "Load More" button at the bottom of the notification list. Clicking this button should append additional mock notifications to the existing list.
- Notification Counts: Display the total number of notifications and the count of unread notifications prominently within the header of the notification center.
UI/UX expectations
- Toggle: The notification center should be toggled open/closed by clicking a "Bell" icon (or similar) button. When closed, only the bell icon and potentially an unread count badge should be visible.
- Layout: When open, the notification center should appear as a distinct panel. It should have a header displaying counts and actions (e.g., "Mark all as read", filter controls), followed by the scrollable list of notifications, and finally the "Load More" button.
- Notification Item: Each notification should be visually distinct based on its type (e.g., different background color or icon for warning vs. info). Read notifications should be visually distinguishable from unread ones (e.g., subtle background change, lighter text).
- Interactions: All buttons and interactive elements should be clearly clickable. Dismissal should be smooth.
Acceptance criteria
- Clicking the bell icon toggles the visibility of the notification center.
- The notification center header displays accurate total and unread notification counts.
- Each notification displays its message, type, relative time, and read status.
- Clicking a notification item (or a dedicated button on it) toggles its read/unread status.
- Clicking "Mark all as read" updates all unread notifications to read.
- Clicking the dismiss button on an individual notification removes it from the list.
- Clicking "Clear all read" removes all read notifications from the list.
- Selecting "Unread" filter correctly displays only unread notifications.
- Selecting "All" filter correctly displays all notifications.
- Clicking "Load More" appends new notifications to the list.
- The UI remains responsive and functional during all interactions.