Frontend School

Build a Flight Search Result Skeleton Loader

Machine Coding
easy

Build a Flight Search Result Skeleton Loader

Easy
React
CSS
UI
Skeleton Loader

Overview

At MakeMyTrip, providing a seamless user experience is paramount. When users search for flights, it can take a few moments for the actual flight data to load. Instead of showing a blank screen, displaying a visual placeholder, known as a skeleton loader, significantly improves perceived performance and keeps users engaged. This problem challenges you to implement such a skeleton loader for a simplified flight search result card.

What you need to do / Task

Your primary task is to create a FlightCardSkeleton component that mimics the structure of a typical flight search result card. This skeleton should be displayed when data is loading and then replaced by the actual FlightCard once the data is available.

  1. Implement FlightCardSkeleton component: Create a React component that visually represents the layout of a flight search result card using placeholder elements (e.g., rectangles, circles).
  2. Apply a loading animation: Integrate a shimmering or pulsing animation effect to the skeleton elements to indicate active loading.
  3. Conditional Rendering: Implement logic to toggle between displaying the FlightCardSkeleton and a mock FlightCard based on an isLoading prop or state.

UI/UX expectations

  • Structure: The skeleton should visually resemble a flight card, including placeholders for common elements like:
    • An airline logo (e.g., a small circle or square).
    • Flight times (e.g., two short lines of text).
    • Duration (e.g., a medium line of text).
    • Price (e.g., a prominent, wider line of text).
    • A "Book Now" button (e.g., a rectangle).
  • Animation: A smooth, non-distracting animation (e.g., a subtle shimmer effect moving across the elements or a gentle pulse) should be applied to the placeholder elements.
  • Clarity: It should be immediately clear to the user that content is loading.

Acceptance criteria

  • A FlightCardSkeleton component is implemented and used.
  • The skeleton loader displays placeholder shapes (e.g., rectangles, circles) that resemble the actual content structure.
  • A CSS-driven animation (e.g., shimmer, pulse) is visible on the skeleton elements.
  • The application correctly renders the FlightCardSkeleton when isLoading is true, and a mock FlightCard when isLoading is false.
  • The solution is implemented using React functional components and CSS.

Constraints

Constraints & assumptions

  • You should use React (functional components) and plain CSS for styling.
  • No external animation libraries (e.g., React Spring, Framer Motion) or dedicated skeleton loader libraries (e.g., react-loading-skeleton) are allowed. Implement the animation purely with CSS.
  • Assume a simplified data structure for the FlightCard when it's not loading.
  • Focus on the visual implementation of the skeleton and the toggle logic, not on actual data fetching or complex state management.
  • The solution should be reasonably performant and not cause significant jank.

Out of scope

  • Implementing actual API calls or data fetching logic.
  • Full responsiveness across all possible screen sizes (focus on a typical desktop view).
  • Advanced accessibility features beyond basic semantic HTML (unless explicitly part of the skeleton itself).
  • Complex error handling or empty states beyond the loading state.

What interviewers evaluate

  • Component Design: How well the FlightCardSkeleton component is structured, its reusability, and separation of concerns.
  • CSS Proficiency: The effective use of CSS for layout, styling, and implementing the animation effect.
  • React Fundamentals: Correct usage of React concepts like props, conditional rendering, and functional components.
  • Code Quality: Readability, maintainability, and adherence to best practices for UI development.

Loading editor...