Skip to content

Commit b4fe975

Browse files
authored
Merge pull request #30 from fraidakis/fraidakis
refactor: improve responsivness of mobile view
2 parents b84858e + 34fdd08 commit b4fe975

7 files changed

Lines changed: 81 additions & 8 deletions

File tree

src/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ThemeProvider } from './context';
55
import { ToastProvider, BottomNavigation } from './components/ui';
66
import Header from './components/Header.jsx';
77
import Footer from './components/Footer.jsx';
8+
import ScrollToTop from './components/ScrollToTop.jsx';
89
import AppRoutes from './router/index.jsx';
910
import './App.css';
1011

@@ -39,6 +40,7 @@ function App() {
3940
<LanguageProvider>
4041
<ToastProvider>
4142
<Router>
43+
<ScrollToTop />
4244
<div className="App">
4345
<Header />
4446
<main className="main-content">

src/components/Hero.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@
207207
}
208208

209209
@media (max-width: 768px) {
210+
/* Hide globe on mobile to prevent cutoff issues */
211+
.hero__globe-container {
212+
display: none !important;
213+
}
214+
210215
.hero--small {
211216
min-height: 250px;
212217
padding: var(--space-10) 0;

src/components/ScrollToTop.jsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { useEffect } from 'react';
2+
import { useLocation } from 'react-router-dom';
3+
4+
/**
5+
* ScrollToTop Component
6+
* Scrolls to top of page on route changes
7+
*/
8+
const ScrollToTop = () => {
9+
const { pathname } = useLocation();
10+
11+
useEffect(() => {
12+
window.scrollTo(0, 0);
13+
}, [pathname]);
14+
15+
return null;
16+
};
17+
18+
export default ScrollToTop;

src/components/ui/BottomNavigation.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const BottomNavigation = ({ isAuthenticated = false }) => {
1717
{ path: '/recommendations', icon: 'star', label: 'Recs', requiresAuth: true },
1818
{ path: '/favourites', icon: 'heart', label: 'Saved', requiresAuth: true },
1919
{ path: '/navigation', icon: 'navigation', label: 'Navigate' },
20-
{ path: isAuthenticated ? '/profile' : '/login', icon: 'user', label: isAuthenticated ? 'Profile' : 'Login' },
20+
// Profile button removed - accessible via header user dropdown
2121
];
2222

2323
const filteredItems = navItems.filter(item => !item.requiresAuth || isAuthenticated);

src/pages/NavigationPage.jsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect, useCallback } from 'react';
1+
import React, { useState, useEffect, useCallback, useRef } from 'react';
22
import { useSearchParams } from 'react-router-dom';
33
import { navigationAPI } from '../api';
44
import { useTranslation } from '../i18n';
@@ -42,6 +42,9 @@ const NavigationPage = () => {
4242
const [routeGeometry, setRouteGeometry] = useState(null);
4343
const [routeError, setRouteError] = useState(null); // For impossible routes
4444

45+
// Ref for auto-scrolling to results
46+
const resultsRef = useRef(null);
47+
4548
// Reverse geocode when route data changes
4649
const geocodeLocations = useCallback(async () => {
4750
if (!routeData) return;
@@ -153,6 +156,13 @@ const NavigationPage = () => {
153156
}
154157

155158
setRouteData(routeInfo);
159+
160+
// Auto-scroll to map on mobile after route calculation
161+
setTimeout(() => {
162+
if (resultsRef.current) {
163+
resultsRef.current.scrollIntoView({ behavior: 'smooth', block: 'start' });
164+
}
165+
}, 100);
156166
} catch (err) {
157167
setError(err.message || t('errorCalculatingRoute'));
158168
console.error('Error calculating route:', err);
@@ -320,7 +330,7 @@ const NavigationPage = () => {
320330
</div>
321331

322332
{/* Results */}
323-
<div className="results-column">
333+
<div className="results-column" ref={resultsRef}>
324334
{routeData ? (
325335
<div className="route-results-card animate-fadeInUp">
326336
<div className="card-title">

src/pages/PlaceDetailsPage.css

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,8 @@
646646

647647
@media (max-width: 768px) {
648648
.place-hero {
649-
padding: var(--space-12) 0 var(--space-16);
649+
padding: var(--space-12) 0 var(--space-24);
650+
/* Increased bottom padding for action buttons */
650651
}
651652

652653
.place-title {
@@ -659,11 +660,19 @@
659660
}
660661

661662
.place-actions-bar {
662-
flex-direction: column;
663+
flex-direction: row;
664+
/* Keep horizontal on mobile */
665+
flex-wrap: wrap;
666+
justify-content: center;
667+
margin-top: calc(-1 * var(--space-24));
668+
/* Adjust overlap */
663669
}
664670

665-
.place-actions-bar button {
666-
width: 100%;
671+
.place-actions-bar button,
672+
.place-actions-bar a {
673+
flex: 1 1 auto;
674+
min-width: 100px;
675+
max-width: 150px;
667676
}
668677

669678
.place-description-card,
@@ -689,4 +698,32 @@
689698
.star-btn {
690699
font-size: 1.5rem;
691700
}
701+
}
702+
703+
/* Extra small screens (iPhone SE, small phones) */
704+
@media (max-width: 480px) {
705+
.place-hero {
706+
padding: var(--space-10) 0 calc(var(--space-32) + var(--space-20));
707+
/* Increased bottom padding for 3 stacked buttons */
708+
}
709+
710+
.place-title {
711+
font-size: var(--text-2xl);
712+
}
713+
714+
.place-actions-bar {
715+
flex-direction: column;
716+
/* Stack vertically on very small screens */
717+
align-items: stretch;
718+
gap: var(--space-2);
719+
margin-top: calc(-1 * (var(--space-32) + var(--space-16)));
720+
/* Move buttons higher up to stay inside hero */
721+
}
722+
723+
.place-actions-bar button,
724+
.place-actions-bar a {
725+
min-width: auto;
726+
max-width: none;
727+
width: 100%;
728+
}
692729
}

src/pages/RecommendationsPage.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
}
5050

5151
.filters-bar--open {
52-
max-height: 200px;
52+
max-height: 500px;
53+
/* Increased for mobile to show Apply button */
5354
opacity: 1;
5455
margin-top: var(--space-4);
5556
}

0 commit comments

Comments
 (0)