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
- Render Hierarchical Data: Display the provided
COURSE_DATA as a tree-like structure.
- 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').
- 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.
- State Management: Maintain the expanded/collapsed state for each module. The component should re-render correctly when the state changes.
- 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.