mirror of
https://github.com/HSLdevcom/digitransit-ui
synced 2026-01-31 03:00:29 +01:00
Configuration exposed a limited set of theme colors prefixes with 'mode-' to component libraries. Many parts of UI used either a hard coded color or incorrectly HSL theme color. Now all relevant colors can put into a general use color map and component can access them. First use case is near you mode icon row's expand arrow.
64 lines
2.1 KiB
JavaScript
64 lines
2.1 KiB
JavaScript
import PropTypes from 'prop-types';
|
|
import React from 'react';
|
|
import Link from 'found/Link';
|
|
import { FormattedMessage } from 'react-intl';
|
|
import { configShape } from '../../../util/shapes';
|
|
import Icon from '../../Icon';
|
|
import { hasVehicleRentalCode } from '../../../util/vehicleRentalUtils';
|
|
import { getIdWithoutFeed } from '../../../util/feedScopedIdUtils';
|
|
|
|
/* eslint-disable jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */
|
|
function SelectVehicleRentalClusterRow(
|
|
{ name, id, desc, prefix, networks: networksInCluster, isScooter },
|
|
{ config },
|
|
) {
|
|
const img = isScooter ? 'icon_scooter-lollipop' : 'icon_citybike-lollipop';
|
|
const color = config.colors[isScooter ? 'scooter' : 'citybike'];
|
|
const linkAddress = `/${prefix}/${encodeURIComponent(id)}/${[
|
|
...networksInCluster,
|
|
]}`;
|
|
|
|
const address = desc || <FormattedMessage id="citybike-station-no-id" />;
|
|
return (
|
|
<Link className="stop-popup-choose-row" to={linkAddress}>
|
|
<span className="choose-row-left-column" aria-hidden="true">
|
|
<Icon img={img} color={color} />
|
|
</span>
|
|
<span className="choose-row-center-column">
|
|
<h5 className="choose-row-header">{name}</h5>
|
|
<span className="choose-row-text">
|
|
<span className="choose-row-address">{address}</span>
|
|
{hasVehicleRentalCode(id) && (
|
|
<span className="choose-row-number">{getIdWithoutFeed(id)}</span>
|
|
)}
|
|
</span>
|
|
</span>
|
|
<span className="choose-row-right-column">
|
|
<Icon img="icon_arrow-collapse--right" />
|
|
</span>
|
|
</Link>
|
|
);
|
|
}
|
|
|
|
SelectVehicleRentalClusterRow.displayName = 'SelectVehicleRentalRow';
|
|
|
|
SelectVehicleRentalClusterRow.propTypes = {
|
|
name: PropTypes.string,
|
|
id: PropTypes.string.isRequired,
|
|
desc: PropTypes.string,
|
|
prefix: PropTypes.string.isRequired,
|
|
networks: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
isScooter: PropTypes.bool,
|
|
};
|
|
|
|
SelectVehicleRentalClusterRow.defaultProps = {
|
|
desc: undefined,
|
|
name: undefined,
|
|
isScooter: false,
|
|
};
|
|
|
|
SelectVehicleRentalClusterRow.contextTypes = {
|
|
config: configShape.isRequired,
|
|
};
|
|
|
|
export default SelectVehicleRentalClusterRow;
|