|
| 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 |
0 commit comments