File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ import { Coordinate } from '@/utils'
1717import PlainButton from '@/PlainButton'
1818import { tr } from '@/translation/Translation'
1919import Chevron from '@/sidebar/search/routingProfiles/chevron.svg'
20- import { icons } from '@/sidebar/search/routingProfiles/profileIcons'
20+ import { findIcon } from '@/sidebar/search/routingProfiles/profileIcons'
2121import { RoutingProfile } from '@/api/graphhopper'
2222
2323type 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 } >
Original file line number Diff line number Diff line change 11import BicycleIcon from './bike.svg'
2+ import BikeScenicIcon from './bike_scenic.svg'
23import CarIcon from './car.svg'
34import FootIcon from './foot.svg'
45import 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+ }
You can’t perform that action at this time.
0 commit comments