Frontend School

Interactive Event Calendar with Range Selection

Machine Coding
hard

Interactive Event Calendar with Range Selection

Hard
Calendar
Date Picker
UI
React
State Management
Accessibility

Overview

Apple's internal tools often require sophisticated date management. Imagine a scheduling application where users need to select a date range for a new project, but also quickly see existing commitments or resource availability within that period. This problem challenges you to build a robust and intuitive date range picker that integrates event data directly into the calendar view, enhancing user decision-making.

What you need to do / Task

  1. Implement a calendar component that displays a single month view.
  2. Allow users to select a start date and an end date, forming a range.
  3. Display a visual indication (e.g., a colored dot or border) on days that have one or more events, regardless of whether they are selected.
  4. Clearly highlight the selected date range within the calendar view.
  5. Below the calendar, display a summary of events occurring within the currently selected date range.
  6. Provide navigation controls (e.g., "Previous Month", "Next Month") to change the displayed month.

UI/UX expectations

  • Layout: A single calendar grid for the current month. Navigation buttons above. Selected range summary below.
  • Interactions:
    • Clicking a date: If no range is selected, it becomes the start date. If a start date is selected but no end date, clicking another date sets it as the end date (re-ordering if the clicked date is earlier than the start date). If a full range (start and end) is already selected, clicking a date clears the previous range and sets the clicked date as the new start date.
    • Hovering over dates: Visually indicate potential end date selection when a start date is already picked.
    • Navigation buttons: Smooth transition to adjacent months.
  • Accessibility:
    • Keyboard navigation for calendar days and month controls (e.g., Tab, Arrow keys).
    • Clear ARIA labels for interactive elements.
    • Sufficient contrast for selected states and event indicators.

Acceptance criteria

  • [ ] Calendar displays days of the month correctly, including days from previous/next months to fill the grid.
  • [ ] Navigation buttons correctly change the displayed month.
  • [ ] Days with events are visually distinct (e.g., a small dot, border, or background color).
  • [ ] Users can select a start date and an end date.
  • [ ] The selected date range is clearly highlighted in the calendar.
  • [ ] Selecting an end date before the start date correctly re-orders the range (e.g., if you click Oct 10 then Oct 5, the range should be Oct 5 - Oct 10).
  • [ ] A summary of events within the selected range is displayed below the calendar.
  • [ ] All interactive elements (days, navigation buttons) are keyboard navigable.
  • [ ] UI states (selected, hovered, event-day) have sufficient contrast.

Constraints

Constraints & assumptions

  • Date Range: The calendar should support navigating through a reasonable range of years (e.g., +/- 5 years from the current year). No need to handle dates beyond this.
  • Event Data: Assume event data is provided as a simple array of objects, each with an id, date (formatted as YYYY-MM-DD), and title. Events are pre-loaded; no API calls are required.
  • Timezone: Assume all dates are in the user's local timezone. No need for complex timezone conversions.
  • Styling: Focus on functionality and clear visual states. Basic styling is sufficient; pixel-perfect recreation of Apple UI is not expected within the time limit.
  • Environment: React functional components with Hooks.
  • Browser Support: Modern evergreen browsers only.

Out of scope

  • Recurring events.
  • Drag-and-drop selection of date ranges.
  • Integration with backend APIs for event fetching.
  • Complex date formatting beyond Month Day, Year or YYYY-MM-DD.

What interviewers evaluate

  • Architectural Design: Logical component structure, effective state management patterns.
  • Core Functionality: Correctness of date range selection logic, event display, and accurate range summary.
  • UI/UX & Accessibility: Intuitive interactions, clear visual feedback, and basic keyboard navigation support.
  • Code Quality: Readability, maintainability, and effective use of React features.

Loading editor...