Frontend School

Pinterest Board Navigation: Build a Breadcrumbs Component

Machine Coding
easy

Pinterest Board Navigation: Build a Breadcrumbs Component

Easy
React
TypeScript
UI
Component
Navigation

Overview

On Pinterest, users often navigate through deeply nested content, from broad categories to specific boards, and then to individual Pins. A clear and intuitive navigation trail is crucial for users to understand their current location within the platform and easily backtrack. In this problem, you will build a reusable Breadcrumbs component that displays the user's current path, allowing them to navigate back up the hierarchy.

What you need to do / Task

Your task is to implement a Breadcrumbs React component that accepts a list of BreadcrumbItem objects and renders them as a navigation path.

  1. Define BreadcrumbItem type: Create a TypeScript interface for BreadcrumbItem with properties label: string and an optional path: string.
  2. Implement Breadcrumbs Component:
    • The component should accept an items: BreadcrumbItem[] prop.
    • Render each item horizontally, separated by a visual divider (e.g., >).
    • Each item, except for the last one, should be a clickable link. When clicked, it should simulate navigation (e.g., by logging the path to the console).
    • The last item in the list represents the current location. It should be rendered as plain text (not a link) and styled to visually indicate it's the current active item.

UI/UX expectations

  • The breadcrumbs should be displayed horizontally in a single line.
  • Each breadcrumb item should be clearly separated by a delimiter (e.g., >).
  • Clickable breadcrumb items should have a visual indication (e.g., underline on hover, distinct color).
  • The last breadcrumb item (current location) should be visually distinct from the clickable links (e.g., bolder text, different color, no underline).
  • Ensure basic semantic HTML (e.g., nav for the overall component, a for links).

Acceptance criteria

  • The Breadcrumbs component renders correctly with provided mock data.
  • All items in the items prop are displayed in the correct order.
  • A separator (e.g., >) is displayed between each breadcrumb item.
  • The last item in the breadcrumb trail is rendered as plain text and is not clickable.
  • All items before the last one are rendered as clickable links.
  • Clicking a link item logs its path to the console.
  • The last item is visually distinct from the other items.

Constraints

Constraints & assumptions

  • The component will receive a maximum of 5-7 BreadcrumbItem objects.
  • You can assume path will always be a valid string when present for a clickable item.
  • No external routing library (like React Router) is required. Simple onClick handlers are sufficient for simulating navigation.
  • Focus on functional React components and TypeScript.
  • Basic styling is expected, but pixel-perfect design is not.

Out of scope

  • Advanced accessibility features beyond basic semantic HTML.
  • Responsive design for different screen sizes.
  • Complex state management or data fetching.
  • Deep customization of separators or item rendering.

What interviewers evaluate

  • Component Design: Ability to create a reusable, well-structured React component.
  • Logical Correctness: Accurate rendering of breadcrumb items, separators, and correct handling of clickable vs. non-clickable items.
  • TypeScript Usage: Effective use of interfaces and types for props and data structures.
  • Basic Styling: Application of CSS to achieve the specified UI/UX requirements.

Loading editor...