Overview
Many project management and scheduling applications require a robust and intuitive date picker. This problem focuses on building a core component for such a system: a date picker that allows users to select a single date, navigate months, and importantly, visualize and respect "unavailable" dates while also displaying associated events for the selected day. This ensures users can efficiently schedule tasks and view commitments.
What you need to do / Task
Your goal is to implement a DatePicker React component with the following features:
- Calendar Grid: Display a standard calendar grid for the current month, showing all days of the month.
- Month Navigation: Provide "Previous" and "Next" buttons to navigate between months. The displayed month and year should update accordingly.
- Date Selection: Allow users to click on an available date to select it. The selected date should be visually highlighted.
- Unavailable Dates: Visually distinguish "unavailable" dates (provided via mock data). These dates should not be selectable.
- Event Display: Below the calendar, display a simple list of events associated with the currently selected date. If no date is selected or no events exist for the selected date, display a "No events" message.
UI/UX expectations
- Layout: The component should display the current month and year at the top, flanked by "Previous" and "Next" buttons. Below this, render a 7-column grid for the days of the week (e.g., Sun, Mon, Tue...) followed by the calendar days. The event list should appear below the calendar grid.
- Interactions:
- Clicking "Previous" or "Next" should smoothly transition the calendar to the adjacent month.
- Clicking an available date should update the selection and the event list.
- Clicking an unavailable date should have no effect.
- Visuals:
- The selected date should have a distinct background or border.
- Unavailable dates should be visually muted or styled differently (e.g., greyed out, strikethrough).
- Days from the previous/next month displayed in the grid should also be visually distinct (e.g., lighter text color).
Acceptance criteria
- The calendar initially renders correctly for the current month and year.
- "Previous" and "Next" buttons successfully navigate to adjacent months/years.
- Clicking an available date correctly highlights it as selected.
- Clicking an unavailable date does not change the selection.
- Unavailable dates are clearly distinguishable visually.
- The list of events below the calendar updates to show events for the currently selected date.
- If no date is selected or no events exist for the selected date, an appropriate message is displayed.
- Days from adjacent months visible in the current month's grid are styled differently and are not selectable.