Frontend School

Interactive Breadcrumbs for Zomato Dish Pages

Machine Coding
easy

Interactive Breadcrumbs for Zomato Dish Pages

Easy
React
UI
Component
Breadcrumbs
Navigation

Overview

On Zomato, users often navigate through various categories and filters to find their desired restaurants or dishes. A clear and intuitive navigation trail is crucial for a smooth user experience. Breadcrumbs serve this purpose by showing the user's current location within the site hierarchy and providing easy access to parent pages. This problem challenges you to build a reusable Breadcrumbs component to enhance navigation on Zomato's dish detail pages.

What you need to do / Task

Your task is to create a Breadcrumbs React component that displays a navigational path. The component should be dynamic, accepting an array of breadcrumb items as props.

  1. Component Creation: Develop a functional React component named Breadcrumbs.
  2. Dynamic Rendering: The Breadcrumbs component should accept a prop, items, which is an array of objects. Each object will have a label (string) and a path (string).
  3. Link vs. Current Page: All breadcrumb items except the last one should be rendered as clickable links. The last item represents the current page and should be displayed as plain text, without a link.
  4. Navigation Simulation: When a clickable breadcrumb item is clicked, it should trigger a provided onNavigate callback function with its corresponding path as an argument. For this exercise, you can simulate navigation by logging the path to the console or using alert().
  5. Separator: Display a clear visual separator (e.g., > or /) between breadcrumb items.

UI/UX expectations

  • Layout: Breadcrumb items should be displayed horizontally, from left to right.
  • Separation: Each item should be visually separated by a character (e.g., >).
  • Clickable States: Link items should have a default cursor (pointer) and ideally a subtle visual feedback on hover (e.g., text color change, underline).
  • Current Item: The last item (current page) should be visually distinct from the clickable links (e.g., different color, no underline).
  • Accessibility: Ensure the breadcrumbs are wrapped in a <nav> element with an appropriate aria-label.

Acceptance criteria

  • The Breadcrumbs component correctly renders all items passed in the items prop.
  • Each item's label is displayed correctly.
  • All items, except the last one, are rendered as clickable links.
  • Clicking a link item correctly invokes the onNavigate callback with the item's path.
  • The last item is rendered as plain text and is not clickable.
  • A visible separator character is present between items.
  • Basic styling is applied to ensure readability and visual distinction between links and the current item.

Constraints

Constraints & assumptions

  • You should use React for this task.
  • No external routing library (e.g., React Router) is required. Simulate navigation using console.log or alert().
  • The items prop will always be an array of BreadcrumbItem objects, and it will not be empty.
  • Focus on functional components and basic React hooks if necessary.
  • The maximum number of breadcrumb items will not exceed 5-6, so performance for long lists is not a primary concern.

Out of scope

  • Complex responsive design beyond basic layout.
  • Accessibility features beyond aria-label for the navigation element.
  • Dynamic data fetching for breadcrumbs; assume data is provided as a prop.

What interviewers evaluate

  • Component Design: How well the Breadcrumbs component is structured, its reusability, and props interface.
  • Conditional Rendering: Correctly distinguishing and rendering clickable links versus plain text for the current page.
  • Event Handling: Proper implementation of click handlers and interaction with the onNavigate prop.
  • UI/UX Adherence: Implementation of the specified visual layout, separators, and basic interactive states.
  • Code Quality: Readability, maintainability, and clarity of the React code.

Loading editor...