Frontend School

Build a Simple Event Timeline Component

Machine Coding
easy

Build a Simple Event Timeline Component

Easy
React
UI
Component
Timeline
CSS

Overview

In many business applications, visualizing a sequence of events chronologically is crucial for understanding progress, history, or status changes. This problem focuses on building a simple, yet effective, timeline component to display key activities or milestones in a clear, sequential manner, enhancing user comprehension and interaction with historical data.

What you need to do / Task

Your primary task is to develop a React component that renders a vertical timeline of events.

  1. Create a Timeline component: This component should accept an events array (of type TimelineEvent[]) as a prop.
  2. Create a TimelineItem component: This sub-component should be responsible for rendering an individual event's details.
  3. Display Event Details: Each TimelineItem must clearly show:
    • The title of the event.
    • A brief description of the event.
    • The timestamp of the event, formatted for readability.
  4. Chronological Order: Ensure events are displayed in chronological order, from oldest to newest. The mockEvents array provided in App.tsx is already sorted; your component should rely on this order.

UI/UX expectations

  • Vertical Layout: The timeline should be presented as a vertical list of events.
  • Timeline Path: A clear vertical line should run down the center or side, connecting all event points.
  • Event Markers: Each event on the timeline should have a distinct visual marker (e.g., a circle, dot, or icon) positioned on the timeline path.
  • Content Alignment: Event details (title, description, timestamp) should be clearly associated with their respective markers and easily readable.
  • Timestamp Formatting: Use the provided formatTimestamp helper function in App.tsx to display dates in a user-friendly format (e.g., "Jan 1, 2023, 10:00 AM").

Acceptance criteria

  • All events from the mockEvents array are rendered.
  • Events appear in ascending chronological order.
  • Each event displays its title, description, and formatted timestamp.
  • A vertical line visually represents the timeline path.
  • Each event has a distinct visual marker on the timeline path.
  • The component is responsive and readable on common screen sizes (basic responsiveness is sufficient).

Constraints

Constraints & assumptions

  • You must use React (functional components and hooks).
  • Styling should be done using plain CSS (either inline or in styles.css). CSS-in-JS or preprocessors are not required.
  • The event data structure (TimelineEvent interface) is provided and will not change.
  • All necessary data is provided upfront; no API calls or external data fetching is needed.
  • Focus on the visual rendering and component structure.

Out of scope

  • Implementing advanced features like infinite scrolling, event filtering, or dynamic data loading.
  • Complex animations or transitions.
  • Accessibility beyond basic semantic HTML elements.

What interviewers evaluate

  • Component Structure: How well the problem is broken down into reusable and manageable React components.
  • Styling Implementation: Proficiency in using CSS to achieve the specified UI/UX requirements, including layout and visual hierarchy.
  • Data Handling: Correctly mapping and displaying data from props, including date formatting.
  • Code Quality: Readability, maintainability, and adherence to standard React practices.

Loading editor...