Frontend School

Flight Status Indicator with Tooltip and Popover

Machine Coding
easy

Flight Status Indicator with Tooltip and Popover

Easy
React
UI
Component
Tooltip
Popover
Event Handling

Overview

In travel applications like Ixigo, displaying concise yet informative data is crucial. Flight status indicators in search results or booking details are a perfect example. While a simple label like "Delayed" is useful, users often need more details without navigating away. This problem challenges you to build an interactive flight status indicator that reveals additional information through a tooltip on hover and a more detailed popover on click.

What you need to do / Task

Your primary task is to enhance the provided FlightStatusIndicator component to display dynamic information using both a tooltip and a popover.

  1. Implement a Tooltip: When a user hovers their mouse over the FlightStatusIndicator component, a small tooltip should appear. This tooltip should display the statusMessage from the flight details.
  2. Implement a Popover: When a user clicks on the FlightStatusIndicator component, a larger popover should appear. This popover should display more detailed information from the flight details, such as estimatedDelay, reason, and newGate (if available).
  3. Popover Dismissal: The popover should close when the user clicks anywhere outside of the popover or presses the Escape key.

UI/UX expectations

  • Flight Status Indicator: A visible element (e.g., a colored badge or text) indicating the flight's primary status (On Time, Delayed, Cancelled).
  • Tooltip: A small, unobtrusive box that appears briefly when the user hovers over the indicator. It should be positioned close to the indicator (e.g., above or below).
  • Popover: A larger, more prominent box that appears on click. It should also be positioned close to the indicator and contain multiple lines of text for detailed information.
  • Interactions: The tooltip should appear on mouseenter and disappear on mouseleave. The popover should appear on click and disappear on click-outside or Escape key press.

Acceptance criteria

  • Hovering over the FlightStatusIndicator displays a tooltip.
  • The tooltip correctly displays the statusMessage provided in the details prop.
  • Moving the mouse away from the indicator dismisses the tooltip.
  • Clicking the FlightStatusIndicator displays a popover.
  • The popover correctly displays estimatedDelay, reason, and newGate from the details prop, if they exist.
  • Clicking outside the popover dismisses it.
  • Pressing the Escape key dismisses the popover.
  • Both the tooltip and popover are reasonably positioned relative to the FlightStatusIndicator (e.g., directly above, below, or to the side).

Constraints

Constraints & assumptions

  • You should use React functional components and hooks.
  • Do not use any external UI component libraries for Tooltip or Popover (e.g., Material UI, Ant Design). Implement them from scratch using basic HTML and CSS.
  • Focus on basic positioning for the tooltip/popover (e.g., position: absolute;). Advanced positioning logic (like auto-flipping if near screen edge) is not required.
  • The provided mockFlightData will be the source of truth for flight details.

Out of scope

  • Complex animations for tooltip/popover appearance/disappearance.
  • Full accessibility for screen readers beyond basic keyboard dismissal.
  • Persisting state across page reloads or routing.

What interviewers evaluate

  • Component Design: Clarity and separation of concerns in component structure.
  • State Management: Effective use of React state for managing tooltip and popover visibility.
  • Event Handling: Correct implementation of DOM event listeners (hover, click, keyboard) and managing event propagation.
  • Basic Styling & Positioning: Ability to apply fundamental CSS for layout and visual presentation.
  • Code Quality: Readability, maintainability, and adherence to React best practices.

Loading editor...