Skip to content

Commit 791ddd5

Browse files
committed
feat(ui): add invert route toggle to quickly find reverse path
1 parent 1229901 commit 791ddd5

2 files changed

Lines changed: 80 additions & 5 deletions

File tree

src/components/RoutePlanner.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import maplibregl from 'maplibre-gl';
33
import 'maplibre-gl/dist/maplibre-gl.css';
44
import { AvalancheReportCard } from './AvalancheReportCard';
55
import { logger } from '../utils/logger';
6-
import { Navigation } from 'lucide-react';
7-
import { Region } from '../config/regions';
6+
import type { Region } from '../config/regions';
7+
import { ArrowLeft, Navigation2, AlertCircle, AlertTriangle, Loader2, ArrowRightLeft, Navigation } from 'lucide-react';
88

99
interface RouteStats {
1010
travelTime: string;
@@ -481,8 +481,8 @@ export const RoutePlanner: React.FC<RoutePlannerProps> = ({
481481
</div>
482482
</div>
483483

484-
<div style={{ display: 'flex', gap: '1rem', marginBottom: '1rem' }}>
485-
<div style={{ flex: 1 }}>
484+
<div className="route-inputs-grid">
485+
<div style={{ flex: 1, width: '100%' }}>
486486
<label style={{ display: 'block', marginBottom: '0.5rem', fontWeight: 500 }}>From</label>
487487
<select
488488
value={from}
@@ -498,7 +498,22 @@ export const RoutePlanner: React.FC<RoutePlannerProps> = ({
498498
))}
499499
</select>
500500
</div>
501-
<div style={{ flex: 1 }}>
501+
502+
<div
503+
className="route-swap-btn"
504+
onClick={() => {
505+
const temp = from;
506+
onFromChange(destination);
507+
onDestinationChange(temp);
508+
}}
509+
title="Swap Origin and Destination"
510+
role="button"
511+
tabIndex={0}
512+
>
513+
<ArrowRightLeft size={20} />
514+
</div>
515+
516+
<div style={{ flex: 1, width: '100%' }}>
502517
<label style={{ display: 'block', marginBottom: '0.5rem', fontWeight: 500 }}>To</label>
503518
<select
504519
value={destination}

src/index.css

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,64 @@ body {
194194

195195
[data-theme='dark'] .resort-item.clickable:active {
196196
background-color: #4b5563;
197+
}
198+
199+
/* Route Inputs */
200+
.route-inputs-grid {
201+
display: grid;
202+
grid-template-columns: 1fr auto 1fr;
203+
align-items: end;
204+
gap: 0.5rem;
205+
margin-bottom: 1rem;
206+
}
207+
208+
.route-swap-btn {
209+
background: var(--color-background);
210+
border: 1px solid #e5e7eb;
211+
border-radius: 50%;
212+
width: 32px;
213+
/* Smaller on mobile */
214+
height: 32px;
215+
display: flex;
216+
align-items: center;
217+
justify-content: center;
218+
cursor: pointer;
219+
color: var(--color-text);
220+
transition: all 0.2s;
221+
z-index: 5;
222+
margin-bottom: 3px;
223+
/* Align with inputs */
224+
}
225+
226+
/* Hide labels visually on very small screens if needed,
227+
but for now just rely on compact layout */
228+
@media (max-width: 380px) {
229+
.route-inputs-grid {
230+
gap: 0.25rem;
231+
}
232+
}
233+
234+
.route-swap-btn:hover {
235+
background-color: #e5e7eb;
236+
border-color: #d1d5db;
237+
}
238+
239+
[data-theme='dark'] .route-swap-btn {
240+
border-color: #374151;
241+
}
242+
243+
[data-theme='dark'] .route-swap-btn:hover {
244+
background-color: #374151;
245+
}
246+
247+
@media (min-width: 768px) {
248+
.route-inputs-grid {
249+
gap: 1rem;
250+
}
251+
252+
.route-swap-btn {
253+
width: 40px;
254+
height: 40px;
255+
margin-bottom: 2px;
256+
}
197257
}

0 commit comments

Comments
 (0)