Skip to content

Commit bc7e27e

Browse files
feat(route-viewer): route details viewer prototype
1 parent ade744e commit bc7e27e

File tree

4 files changed

+108
-11
lines changed

4 files changed

+108
-11
lines changed

example.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
.sidebar {
4040
height: 100%;
41-
padding: 10px;
41+
padding: 0;
4242
box-shadow: 3px 0px 12px #00000052;
4343
z-index: 1000;
4444
}

lib/components/app/app.css

+5
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,8 @@
5151
margin-bottom: 30px;
5252
box-sizing: border-box;
5353
}
54+
55+
/* Batch routing panel requires top padding missing from sidebar */
56+
.batch-routing-panel {
57+
padding-top: 10px;
58+
}
+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import React, { Component } from 'react'
2+
import PropTypes from 'prop-types'
3+
import styled from 'styled-components'
4+
import { Button } from 'react-bootstrap'
5+
6+
import Icon from '../narrative/icon'
7+
8+
/** Converts text color (either black or white) to rgb */
9+
const textHexToRgb = (color) => (color === '#ffffff' ? '255,255,255' : '0,0,0')
10+
11+
const Wrapper = styled.div`
12+
padding: 8px;
13+
`
14+
const LogoLinkContainer = styled.div`
15+
display: flex;
16+
padding-top: 10px;
17+
justify-content: space-between;
18+
`
19+
const MoreDetailsLink = styled.a`
20+
color: ${(props) => props.color};
21+
background-color: rgba(${(props) => textHexToRgb(props.color)},0.1);
22+
padding: 5px;
23+
border-radius: 5px;
24+
transition: 0.1s all ease-in-out;
25+
26+
&:hover {
27+
background-color: rgba(255,255,255,0.8);
28+
color: #333;
29+
}
30+
}
31+
`
32+
const PatternContainer = styled.div`
33+
background-color: ${(props) => props.color};
34+
color: ${(props) => props.textColor};
35+
display: flex;
36+
justify-content: flex-start;
37+
align-items: baseline;
38+
gap: 16px;
39+
padding: 0 8px;
40+
margin: 0;
41+
filter: saturate(200%);
42+
43+
h4 {
44+
margin-bottom: 0px;
45+
}
46+
47+
button {
48+
color: inherit;
49+
border-bottom: 3px solid ${(props) => props.textColor};
50+
}
51+
52+
button:hover {
53+
color: ${(props) => props.color};
54+
background-color: ${(props) => props.textColor};
55+
text-decoration: none;
56+
}
57+
}
58+
`
59+
60+
class RouteDetails extends Component {
61+
static propTypes = {
62+
color: PropTypes.string,
63+
contrastColor: PropTypes.string,
64+
route: PropTypes.shape({ id: PropTypes.string })
65+
};
66+
render () {
67+
const { className, route, routeColor, textColor } = this.props
68+
const { agency, url } = route
69+
return (
70+
<div>
71+
<Wrapper className={className}>
72+
This route runs every ?? minutes, ?? days of the week.
73+
<LogoLinkContainer>
74+
{agency && <span>Run by {agency.name}</span>}
75+
{url && (
76+
<span>
77+
<MoreDetailsLink color={textColor} href={url} target='_blank'>
78+
<Icon type='link' />
79+
More details
80+
</MoreDetailsLink>
81+
</span>
82+
)}
83+
</LogoLinkContainer>
84+
</Wrapper>
85+
<PatternContainer color={routeColor} textColor={textColor}>
86+
<h4>Stops To</h4>
87+
<Button bsStyle='link'>Place one</Button>
88+
</PatternContainer>
89+
</div>
90+
)
91+
}
92+
}
93+
94+
const StyledRouteDetails = styled(RouteDetails)`
95+
background-color: ${(props) => props.routeColor};
96+
color: ${(props) => props.textColor};
97+
`
98+
99+
export default StyledRouteDetails

lib/components/viewers/route-viewer.js

+3-10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { findRoutes, findRoute } from '../../actions/api'
1212
import { ComponentContext } from '../../util/contexts'
1313
import { getModeFromRoute } from '../../util/viewer'
1414

15+
import RouteDetails from './route-details'
16+
1517
/**
1618
* Determine the appropriate contrast color for text (white or black) based on
1719
* the input hex string (e.g., '#ff00ff') value.
@@ -152,10 +154,6 @@ const RouteNameElement = styled(Label)`
152154
text-overflow: ellipsis;
153155
`
154156

155-
const RouteDetails = styled.div`
156-
padding: 8px;
157-
`
158-
159157
class RouteRow extends PureComponent {
160158
static contextType = ComponentContext
161159

@@ -228,12 +226,7 @@ class RouteRow extends PureComponent {
228226
</RouteRowButton>
229227
<VelocityTransitionGroup enter={{animation: 'slideDown'}} leave={{animation: 'slideUp'}}>
230228
{isActive && (
231-
<RouteDetails>
232-
{route.url
233-
? <a href={route.url} target='_blank'>Route Details</a>
234-
: 'No route URL provided.'
235-
}
236-
</RouteDetails>
229+
<RouteDetails route={route} routeColor={backgroundColor} textColor={color} />
237230
)}
238231
</VelocityTransitionGroup>
239232
</StyledRouteRow>

0 commit comments

Comments
 (0)