Skip to content

Commit 52c18a8

Browse files
committed
show profile for mobile view
1 parent 615e82c commit 52c18a8

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/sidebar/RoutingResult.module.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,16 @@
201201
font-size: small;
202202
padding: 10px 5px 10px 3rem;
203203
}
204+
205+
.profileIcon {
206+
display: inline-flex;
207+
align-items: center;
208+
margin-right: 0.5rem;
209+
width: 20px;
210+
height: 20px;
211+
}
212+
213+
.profileIcon svg {
214+
width: 100%;
215+
height: 100%;
216+
}

src/sidebar/RoutingResults.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,24 @@ import DangerousIcon from '@/sidebar/routeHints/warn_report.svg'
2929
import { Bbox } from '@/api/graphhopper'
3030
import { SettingsContext } from '@/contexts/SettingsContext'
3131
import { Settings } from '@/stores/SettingsStore'
32+
import { icons } from '@/sidebar/search/routingProfiles/profileIcons'
33+
import React from 'react'
34+
35+
function getProfileIcon(profileName: string) {
36+
// First try to get exact match
37+
let icon = icons[profileName]
38+
if (icon) return React.createElement(icon)
39+
40+
// If no exact match, try to find a base profile
41+
const baseProfile = Object.keys(icons).find(k => profileName.startsWith(k + '_'))
42+
if (baseProfile) {
43+
icon = icons[baseProfile]
44+
if (icon) return React.createElement(icon)
45+
}
46+
47+
// Fallback to question mark
48+
return React.createElement(icons.question_mark)
49+
}
3250

3351
export interface RoutingResultsProps {
3452
info: RoutingResultInfo
@@ -67,6 +85,7 @@ function RoutingResult({
6785
useEffect(() => setExpanded(isSelected && isExpanded), [isSelected])
6886
const settings = useContext(SettingsContext)
6987
const showDistanceInMiles = settings.showDistanceInMiles
88+
const isMobile = useMediaQuery({ query: '(max-width: 44rem)' })
7089

7190
const fordInfo = getInfoFor(path.points, path.details.road_environment, s => s === 'ford')
7291
const tollInfo = getInfoFor(
@@ -144,7 +163,10 @@ function RoutingResult({
144163
<div className={styles.resultSelectableArea} onClick={() => Dispatcher.dispatch(new SetSelectedPath(path))}>
145164
<div className={resultSummaryClass}>
146165
<div className={styles.resultValues}>
147-
<span className={styles.resultMainText}>{milliSecondsToText(path.time)}</span>
166+
<span className={styles.resultMainText}>
167+
{isMobile && <span className={styles.profileIcon}>{getProfileIcon(profile)}</span>}
168+
{milliSecondsToText(path.time)}
169+
</span>
148170
<span className={styles.resultSecondaryText}>
149171
{metersToShortText(path.distance, showDistanceInMiles)}
150172
</span>

0 commit comments

Comments
 (0)