Frontend School

Event Scheduler Date Picker

Machine Coding
medium

Event Scheduler Date Picker

Medium
Calendar
Date Picker
UI
React
Frontend

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:

  1. Calendar Grid: Display a standard calendar grid for the current month, showing all days of the month.
  2. Month Navigation: Provide "Previous" and "Next" buttons to navigate between months. The displayed month and year should update accordingly.
  3. Date Selection: Allow users to click on an available date to select it. The selected date should be visually highlighted.
  4. Unavailable Dates: Visually distinguish "unavailable" dates (provided via mock data). These dates should not be selectable.
  5. 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.

Constraints

Constraints & assumptions

  • You should implement this using React.
  • Focus on core functionality. Full internationalization, advanced accessibility (beyond basic keyboard navigation), or complex styling frameworks are not required.
  • You may use native JavaScript Date objects for all date calculations. Avoid external date libraries (e.g., date-fns, Moment.js).
  • Assume a standard week starts on Sunday.
  • Mock data for unavailable dates and events will be provided in App.tsx.
  • The DatePicker should handle displaying a single month at a time.

Out of scope

  • Multi-date selection or date range selection.
  • Time selection.
  • Adding, editing, or deleting events. The event data is static.
  • Year view or decade view navigation.
  • Complex animations or transitions for month changes.

What interviewers evaluate

  • Correctness and Robustness: Accuracy of date calculations, month navigation, and selection logic.
  • Component Design: Clean separation of concerns, effective state management, and clear component structure.
  • UI/UX Adherence: How well the visual and interactive specifications are met, including distinct styling for different date states.
  • React Proficiency: Appropriate use of React hooks, props, and rendering patterns.

Loading editor...