Skip to content

Commit aa94dc3

Browse files
committed
Merge branch 'master' into navi
2 parents eec6e8a + be46fcb commit aa94dc3

3 files changed

Lines changed: 54 additions & 3 deletions

File tree

src/sidebar/MobileSidebar.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { Coordinate } from '@/utils'
1717
import PlainButton from '@/PlainButton'
1818
import { tr } from '@/translation/Translation'
1919
import Chevron from '@/sidebar/search/routingProfiles/chevron.svg'
20-
import { icons } from '@/sidebar/search/routingProfiles/profileIcons'
20+
import { findIcon } from '@/sidebar/search/routingProfiles/profileIcons'
2121
import { RoutingProfile } from '@/api/graphhopper'
2222

2323
type MobileSidebarProps = {
@@ -117,8 +117,7 @@ function SmallSearchView(props: { points: QueryPoint[]; selectedProfile: Routing
117117
const from = props.points[0]
118118
const to = props.points[props.points.length - 1]
119119
const isSmallHeight = useMediaQuery({ query: '(max-height: 36rem)' })
120-
const icon = icons[props.selectedProfile.name]
121-
const iconElement = icon ? React.createElement(icon) : React.createElement(icons.question_mark)
120+
const iconElement = React.createElement(findIcon(props.selectedProfile.name))
122121

123122
return (
124123
<div className={styles.btnOpenContainer} onClick={props.onClick}>
Lines changed: 42 additions & 0 deletions
Loading

src/sidebar/search/routingProfiles/profileIcons.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import BicycleIcon from './bike.svg'
2+
import BikeScenicIcon from './bike_scenic.svg'
23
import CarIcon from './car.svg'
34
import FootIcon from './foot.svg'
45
import HikeIcon from './hike.svg'
@@ -25,6 +26,7 @@ export const icons: Record<string, any> = {
2526
foot: FootIcon,
2627
hike: HikeIcon,
2728
bike: BicycleIcon,
29+
bike_scenic: BikeScenicIcon,
2830
mtb: MtbBicycleIcon, // Mountainbike
2931
racingbike: RacingbikeIcon,
3032
ecargobike: EcargobikeIcon,
@@ -35,3 +37,11 @@ export const icons: Record<string, any> = {
3537
car_avoid_ferry: FerryDisabledIcon,
3638
car_avoid_toll: TollDisabledIcon,
3739
}
40+
41+
// Resolve an icon for a routing-profile name. Falls back to the base-profile icon for custom profiles
42+
// like 'bike_scenic' → 'bike', and finally to the question-mark icon if nothing matches.
43+
export function findIcon(profileName: string): any {
44+
if (icons[profileName]) return icons[profileName]
45+
const baseKey = Object.keys(icons).find(k => profileName.startsWith(k + '_'))
46+
return baseKey ? icons[baseKey] : icons.question_mark
47+
}

0 commit comments

Comments
 (0)