-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60c8e38
commit a429f4a
Showing
10 changed files
with
99 additions
and
157 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
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
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
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,59 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' | ||
import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons' | ||
import busIcon from '../resources/bus.svg' | ||
import trainIcon from '../resources/train.svg' | ||
import { isHexLight } from '../util' | ||
import { OverlayTrigger } from 'react-bootstrap' | ||
import { Tooltip } from 'react-bootstrap' | ||
import { Link } from 'react-router-dom' | ||
import './TransitRouteHeader.scss' | ||
|
||
function TransitRouteHeader({route, alerts, showRouteType}) { | ||
|
||
const routeStyle = { | ||
backgroundColor: '#' + route.route_color, | ||
color: isHexLight(route.route_color) ? '#000' : '#FFF' | ||
} | ||
|
||
let vehicleIcon = busIcon | ||
if (route.route_type === "2") { | ||
vehicleIcon = trainIcon | ||
} | ||
|
||
return( | ||
<div className="transit-route-header d-flex" style={routeStyle} title={route.route_desc}> | ||
{showRouteType && ( | ||
<div> | ||
<img className="me-2" style={{height: '1.5rem'}} src={vehicleIcon} alt="Icon" title={'Route Type: ' + route.route_type } /> | ||
</div> | ||
)} | ||
<div className="flex-grow-1 align-bottom"> | ||
<Link to={'/routes/' + route.route_short_name}>{route.route_short_name} - {route.route_long_name}</Link> | ||
</div> | ||
<div> | ||
{alerts.length > 0 && ( | ||
<div className="ms-2"> | ||
<OverlayTrigger placement={'top'} overlay={<Tooltip>{alerts.length > 1 ? alerts.length + ' alerts' : '1 alert'}</Tooltip>}> | ||
<FontAwesomeIcon icon={faExclamationTriangle} fixedWidth={true}></FontAwesomeIcon> | ||
</OverlayTrigger> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
TransitRouteHeader.propTypes = { | ||
route: PropTypes.object.isRequired, | ||
alerts: PropTypes.array, | ||
showRouteType: PropTypes.bool | ||
} | ||
|
||
TransitRouteHeader.defaultProps = { | ||
alerts: [], | ||
showRouteType: false | ||
} | ||
|
||
export default TransitRouteHeader |
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,12 @@ | ||
.transit-route-header { | ||
border-radius: 10px; | ||
background-color: #999; | ||
color: #fff; | ||
padding: 1rem; | ||
font-weight: bold; | ||
margin-bottom: 0.5rem; | ||
a:any-link { | ||
text-decoration: none; | ||
color: white; | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.