-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: improve responsivness of mobile view #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,18 @@ | ||||||||||||||||
| import { useEffect } from 'react'; | ||||||||||||||||
| import { useLocation } from 'react-router-dom'; | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * ScrollToTop Component | ||||||||||||||||
| * Scrolls to top of page on route changes | ||||||||||||||||
| */ | ||||||||||||||||
| const ScrollToTop = () => { | ||||||||||||||||
| const { pathname } = useLocation(); | ||||||||||||||||
|
|
||||||||||||||||
| useEffect(() => { | ||||||||||||||||
| window.scrollTo(0, 0); | ||||||||||||||||
|
||||||||||||||||
| window.scrollTo(0, 0); | |
| const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches; | |
| window.scrollTo({ | |
| top: 0, | |
| left: 0, | |
| behavior: prefersReducedMotion ? 'auto' : 'smooth' | |
| }); |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||||||||||||||||||
| import React, { useState, useEffect, useCallback } from 'react'; | ||||||||||||||||||||||
| import React, { useState, useEffect, useCallback, useRef } from 'react'; | ||||||||||||||||||||||
| import { useSearchParams } from 'react-router-dom'; | ||||||||||||||||||||||
| import { navigationAPI } from '../api'; | ||||||||||||||||||||||
| import { useTranslation } from '../i18n'; | ||||||||||||||||||||||
|
|
@@ -42,6 +42,9 @@ const NavigationPage = () => { | |||||||||||||||||||||
| const [routeGeometry, setRouteGeometry] = useState(null); | ||||||||||||||||||||||
| const [routeError, setRouteError] = useState(null); // For impossible routes | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Ref for auto-scrolling to results | ||||||||||||||||||||||
| const resultsRef = useRef(null); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Reverse geocode when route data changes | ||||||||||||||||||||||
| const geocodeLocations = useCallback(async () => { | ||||||||||||||||||||||
| if (!routeData) return; | ||||||||||||||||||||||
|
|
@@ -153,6 +156,13 @@ const NavigationPage = () => { | |||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| setRouteData(routeInfo); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Auto-scroll to map on mobile after route calculation | ||||||||||||||||||||||
| setTimeout(() => { | ||||||||||||||||||||||
| if (resultsRef.current) { | ||||||||||||||||||||||
| resultsRef.current.scrollIntoView({ behavior: 'smooth', block: 'start' }); | ||||||||||||||||||||||
|
||||||||||||||||||||||
| resultsRef.current.scrollIntoView({ behavior: 'smooth', block: 'start' }); | |
| const prefersReducedMotion = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches; | |
| resultsRef.current.scrollIntoView({ behavior: prefersReducedMotion ? 'auto' : 'smooth', block: 'start' }); |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The 100ms timeout appears arbitrary. Consider using requestAnimationFrame or a longer delay to ensure the DOM has fully updated and rendered before attempting to scroll. Alternatively, document why 100ms was chosen to help future maintainers.
| setTimeout(() => { | |
| if (resultsRef.current) { | |
| resultsRef.current.scrollIntoView({ behavior: 'smooth', block: 'start' }); | |
| } | |
| }, 100); | |
| requestAnimationFrame(() => { | |
| if (resultsRef.current) { | |
| resultsRef.current.scrollIntoView({ behavior: 'smooth', block: 'start' }); | |
| } | |
| }); |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -646,7 +646,8 @@ | |||||||
|
|
||||||||
| @media (max-width: 768px) { | ||||||||
| .place-hero { | ||||||||
| padding: var(--space-12) 0 var(--space-16); | ||||||||
| padding: var(--space-12) 0 var(--space-24); | ||||||||
| /* Increased bottom padding for action buttons */ | ||||||||
| } | ||||||||
|
|
||||||||
| .place-title { | ||||||||
|
|
@@ -659,11 +660,19 @@ | |||||||
| } | ||||||||
|
|
||||||||
| .place-actions-bar { | ||||||||
| flex-direction: column; | ||||||||
| flex-direction: row; | ||||||||
| /* Keep horizontal on mobile */ | ||||||||
| flex-wrap: wrap; | ||||||||
| justify-content: center; | ||||||||
| margin-top: calc(-1 * var(--space-24)); | ||||||||
| /* Adjust overlap */ | ||||||||
| } | ||||||||
|
|
||||||||
| .place-actions-bar button { | ||||||||
| width: 100%; | ||||||||
| .place-actions-bar button, | ||||||||
| .place-actions-bar a { | ||||||||
| flex: 1 1 auto; | ||||||||
| min-width: 100px; | ||||||||
| max-width: 150px; | ||||||||
| } | ||||||||
|
|
||||||||
| .place-description-card, | ||||||||
|
|
@@ -689,4 +698,32 @@ | |||||||
| .star-btn { | ||||||||
| font-size: 1.5rem; | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| /* Extra small screens (iPhone SE, small phones) */ | ||||||||
| @media (max-width: 480px) { | ||||||||
| .place-hero { | ||||||||
| padding: var(--space-10) 0 calc(var(--space-32) + var(--space-20)); | ||||||||
|
||||||||
| padding: var(--space-10) 0 calc(var(--space-32) + var(--space-20)); | |
| --place-hero-bottom-padding-small: calc(var(--space-32) + var(--space-20)); | |
| padding: var(--space-10) 0 var(--place-hero-bottom-padding-small); |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The complex negative calc expression calc(-1 * (var(--space-32) + var(--space-16))) is difficult to understand and maintain. Consider using a CSS variable for this value to improve code clarity.
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -49,7 +49,8 @@ | |||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| .filters-bar--open { | ||||||||||||||
|
||||||||||||||
| .filters-bar--open { | |
| .filters-bar--open { | |
| /* | |
| * max-height set to 500px to ensure all filter options and the Apply button are visible | |
| * when the filter bar is expanded, especially on mobile devices. Adjust if filter content changes. | |
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
!importantflag should be avoided unless absolutely necessary as it makes styles harder to override and maintain. If the globe container is appearing on mobile despite this rule, consider investigating the specificity issue in the original CSS rather than using!important.