A complete mobile-responsive layout has been added to the PMIS Highway Heatmaps page without modifying the existing desktop layout. The mobile layout provides a card-based interface optimized for touch interactions.
- Custom React hook to detect mobile viewport
- Uses 768px (md breakpoint) as the threshold
- Returns boolean indicating if device is mobile
- Represents a single highway/county data row
- Layout:
- Title: Highway + County/District
- Map button (top-right)
- Current metric thumbnail (full width)
- Click thumbnail to open charts view
- Uses
MiniSegmentChartfor metric visualization
- Full-screen charts display for mobile
- Features:
- Header with back button and "Close All" option
- Score gauges displayed horizontally (scrollable)
- Vertically stacked chart cards
- Individual chart removal
- Individual score removal within charts
- Uses the same
HeatMapModalcomponents as desktop
- Main mobile container component
- Features:
- Metric selector header with left/right arrows
- Swipe gestures to switch between metrics (left/right)
- Scrollable list of
Cardcomponents - Shows one metric at a time across all cards
- Automatically switches to charts view when user taps a metric
- Metrics available:
- Condition Score
- Distress Score
- Ride Score
- AADT
- Maintenance Cost
Changes:
- Added
useIsMobilehook import - Added mobile-specific state:
processedData: Array of processed highway/county datasegmentDataByHighwayCounty: Map of segment data for chartsavailableHighways: Set of available highways for map displayviewType: County or district view mode
- Added helper functions:
isHighwayAvailable(): Check if highway has map datahandleRemoveChart(): Remove a chart by IDhandleRemoveScore(): Remove a score from a charthandleMobileMapClick(): Wrapper for mobile map clickshandleMobileChartClick(): Wrapper for mobile chart clicks
- Conditional rendering:
- If
isMobile === true: RenderMobileLayout - If
isMobile === false: Render desktop layout (unchanged)
- If
Changes:
- Updated interface to accept new optional props:
viewType: External control of county/district viewsetViewType: Callback to update view typeonDataProcessed: Callback when data is processedonSegmentDataReady: Callback when segment data is readyonAvailableHighwaysReady: Callback when highway availability data is ready
- Updated
mapModalInfotype to match parent component - Internal/external state management for
viewType - Callbacks invoked when data is ready to share with mobile components
- User opens page on mobile →
useIsMobile()returnstrue - MobileLayout renders with card list showing first metric (Condition Score)
- User swipes left/right → Switches metric shown on all cards
- User taps metric thumbnail → Opens ChartsView with chart for that highway/county
- User taps map button → Opens map modal (full screen)
- ChartsView "Back" button → Returns to card list
- ChartsView "Close All" → Closes all charts and returns to card list
- User opens page on desktop →
useIsMobile()returnsfalse - Desktop layout renders (existing grid-based layout, unchanged)
- All existing desktop functionality works as before
- ✅ Large tap targets for buttons
- ✅ Swipe gestures for metric switching
- ✅ Full-width cards for easy scrolling
- ✅ Full-screen charts view
- ✅ Same data source as desktop
- ✅ Reuses existing chart components
- ✅ Reuses existing map modal
- ✅ Same color schemes and categories
- ✅ Breakpoint: 768px (Tailwind 'md')
- ✅ Automatic layout switching
- ✅ No desktop code changes needed
- Test on mobile device (< 768px width)
- Test swipe left/right to change metrics
- Test tapping metric thumbnail to open charts
- Test map button functionality
- Test charts view back button
- Test charts view close all button
- Test removing individual charts
- Test removing individual scores from charts
- Test on tablet (768px - 1024px) - should show desktop layout
- Test on desktop (> 1024px) - should show desktop layout
- Test resizing browser window to trigger layout switch
Potential improvements:
- Add search functionality to mobile layout
- Add sorting options for mobile cards
- Add filter by county/district in mobile
- Add pagination or virtual scrolling for large datasets
- Add pull-to-refresh functionality
- Add animations for metric transitions
- Add haptic feedback for swipe gestures (on supported devices)
- The mobile layout is completely separate from desktop layout
- No existing desktop functionality has been modified
- Both layouts share the same data and business logic
- Mobile layout uses the same color schemes and scoring categories
- The implementation follows React best practices (hooks, memoization, callbacks)