Frontend School

Snap Map: Friend Locator

Machine Coding
medium

Snap Map: Friend Locator

Medium
React
UI
State Management
Map
Markers
Interactivity

Overview

Snap Map allows users to see their friends' locations in real-time. This problem challenges you to build a simplified front-end simulation of a key Snap Map feature: displaying a list of friends and visualizing their approximate locations on an interactive map. This exercise focuses on UI component design, state management, and synchronizing interactions between different parts of the user interface.

What you need to do / Task

Your goal is to build a React application with two main panels: a 'Friends List' and a 'Snap Map' view.

  1. Render Friends List: Display a scrollable list of friends using the provided mock data. Each list item should show the friend's name.
  2. Simulate Map View: Implement a basic 'map' component using a div element. This map will display 'markers' at the simulated coordinates of each friend.
  3. Synchronized Selection (List to Map): When a friend's name is clicked in the friends list, that friend should be marked as 'selected'. The selected friend's list item should visually change, and their corresponding marker on the map should also visually highlight.
  4. Synchronized Selection (Map to List): Clicking a marker on the map should select the corresponding friend in the friends list, updating both the list item's visual state and the marker's visual state.
  5. Single Selection: Only one friend can be selected at any given time. Clicking a new friend (either in the list or on the map) should deselect the previously active friend and select the new one.

UI/UX expectations

  • Layout: The application should have a two-panel layout: a 'Friends List' on the left and a 'Snap Map' on the right.
  • Friends List: Each friend's name should be clearly clickable. The selected friend's list item should have a distinct visual style (e.g., different background color, bold text).
  • Map View: The map area should be a distinct rectangular region. Markers should be simple visual elements (e.g., circles). The selected friend's marker should be visually distinct from unselected markers (e.g., different color, larger size).
  • Interactions: Clicks on friend list items and map markers should feel responsive and immediately update the UI across both panels.
  • Accessibility: Basic clickable elements with clear visual feedback are expected.

Acceptance criteria

  • The friends list correctly renders all friends from the FRIENDS_DATA mock data.
  • Clicking a friend in the list selects them, visually highlighting their name.
  • When a friend is selected, their corresponding marker on the map is visually highlighted.
  • Only one friend/marker is selected/highlighted at any given time; selecting a new one deselects the old one.
  • Clicking a marker on the map correctly selects the corresponding friend in the list and highlights both the list item and the marker.
  • The UI consistently reflects the single selected friend across both the list and the map views.

Constraints

Constraints & assumptions

  • Data: Use the provided FRIENDS_DATA mock data.
  • Map Simulation: Do not use any external map libraries (e.g., Google Maps, Leaflet). Simulate the map using standard HTML div elements and CSS for positioning markers. The provided normalizeLat and normalizeLng helper functions should be used to convert lat/lng coordinates to a 0-100 percentage scale for positioning within the map container.
  • Styling: Focus on functional styling to differentiate elements and states. Pixel-perfect design is not required.
  • Environment: Use React functional components and Hooks.
  • Time: The problem is designed to be completed within approximately 45 minutes.

Out of scope

  • Backend integration or API calls.
  • Advanced map features like zooming, panning, routing, or real-time location updates.
  • Complex error handling, loading states, or extensive accessibility features (e.g., full keyboard navigation).
  • Deep optimization for performance or bundle size.

What interviewers evaluate

  • Component Design: How well the application is structured into reusable and maintainable React components.
  • State Management: Effective use of React Hooks (e.g., useState, useCallback) to manage UI state and synchronize interactions.
  • Event Handling: Correct implementation of click handlers and prop passing for component communication.
  • UI Synchronization: Ability to maintain a consistent visual state across disparate UI elements (list and map).
  • Code Quality: Readability, maintainability, and adherence to React best practices.

Loading editor...