Frontend School

LinkedIn Learning Course Navigator

Machine Coding
medium

LinkedIn Learning Course Navigator

Medium
Tree View
React
Frontend
UI
State Management
Recursion

Overview

Imagine you're building a core UI component for LinkedIn Learning, enabling users to efficiently navigate course content. This component needs to display the hierarchical structure of a course, including modules, lessons, and quizzes, with the ability to expand and collapse sections. This feature significantly enhances content discoverability and user experience by providing a clear overview and control over content visibility.

What you need to do / Task

  1. Render Hierarchical Data: Display the provided COURSE_DATA as a tree-like structure.
  2. Item Representation: Each course item should display its name and a visual icon indicating its type (e.g., a folder for 'module', a file for 'lesson' or 'quiz').
  3. Expand/Collapse Functionality: Implement click handlers to toggle the visibility of child items for 'module' type items. Clicking on a module's name or its toggle icon should expand or collapse its children.
  4. State Management: Maintain the expanded/collapsed state for each module. The component should re-render correctly when the state changes.
  5. Visual Hierarchy: Apply visual indentation to child items to clearly reflect their depth within the course structure.

UI/UX expectations

  • Visual Distinction: Clearly differentiate between parent ('module') and child items ('lesson', 'quiz').
  • Toggle Indicator: Display an arrow or chevron icon next to expandable 'module' items. This icon should visually indicate the current state (e.g., right-facing when collapsed, down-facing when expanded).
  • Interaction Area: The entire visible area of a module item (including its name and icons) should be clickable to toggle its expansion state.
  • Indentation: Each level of nesting should have a noticeable, consistent indentation (e.g., 20px per level).
  • Initial State: All 'module' items should be initially collapsed.

Acceptance criteria

  • The component successfully renders all items from the COURSE_DATA array.
  • All 'module' items are initially rendered in a collapsed state, with their children hidden.
  • Clicking on a 'module' item's interactive area toggles its expanded/collapsed state.
  • When a 'module' is expanded, its direct children are visible and appropriately indented.
  • When a 'module' is collapsed, its direct children and all nested descendants are hidden.
  • The toggle icon next to a 'module' visually updates to reflect its current expanded/collapsed state.
  • 'Lesson' and 'quiz' items, which do not have children, should not have a toggle icon and should not be expandable.

Constraints

Constraints & assumptions

  • The provided COURSE_DATA structure is immutable and represents the complete hierarchy for this exercise.
  • Focus on functional correctness and clean, maintainable React component structure.
  • You may use standard React hooks (useState, useEffect, etc.). No external UI component libraries (e.g., Material UI, Ant Design) are allowed.
  • Assume a modern browser environment for rendering.
  • The component should handle reasonably sized trees; extreme performance optimization for very deep or wide trees is out of scope.

Out of scope

  • Keyboard navigation beyond basic mouse clicks.
  • Drag-and-drop functionality for reordering items.
  • Searching, filtering, or sorting of course items.
  • Persistence of expanded states across page loads or user sessions.
  • Server-side data fetching or mutation.

What interviewers evaluate

  • Correct and robust implementation of recursive rendering for tree structures.
  • Effective use of React state management for UI interactions (expand/collapse).
  • Clean, modular, and readable React component design, demonstrating good separation of concerns.
  • Application of basic CSS for visual hierarchy and responsiveness.

Loading editor...