forked from opentripplanner/otp-react-redux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom-icons.js
47 lines (43 loc) · 1.38 KB
/
custom-icons.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import {
ClassicBus,
ClassicGondola,
ClassicModeIcon,
Ferry,
LegIcon,
StandardGondola
} from '@opentripplanner/icons'
/**
* For more advanced users, you can replicate and customize components and
* observe the change in icons.
* - For LegIcon: https://github.com/opentripplanner/otp-ui/blob/master/packages/icons/src/trimet-leg-icon.js
* - For ModeIcon: https://github.com/opentripplanner/otp-ui/blob/master/packages/icons/src/trimet-mode-icon.js
* The example below shuffles some icons around from what you might normally
* expect for demonstration purposes.
*/
const CustomTransitIcon = Ferry
const CustomRailIcon = ClassicGondola
const CustomStreetcarIcon = StandardGondola
const CustomBikeRentalIcon = ClassicBus
export const CustomModeIcon = ({ mode, ...props }) => {
if (!mode) return null
switch (mode.toLowerCase()) {
// Place custom icons for each mode here.
case 'transit':
return <CustomTransitIcon {...props} />
case 'rail':
return <CustomRailIcon {...props} />
default:
return <ClassicModeIcon mode={mode} {...props} />
}
}
export const CustomLegIcon = ({ leg, ...props }) => {
if (
leg.routeLongName &&
leg.routeLongName.startsWith('MAX')
) {
return <CustomStreetcarIcon />
} else if (leg.rentedBike) {
return <CustomBikeRentalIcon />
}
return <LegIcon leg={leg} ModeIcon={CustomModeIcon} {...props} />
}