-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'otp-ui-icons' of https://github.com/opentripplanner/otp…
…-react-redux into otp-ui-icons
- Loading branch information
Showing
2 changed files
with
58 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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} /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters