Skip to content

Commit

Permalink
Merge pull request #2732 from HSLdevcom/revert-2730-DT-2954
Browse files Browse the repository at this point in the history
Revert "DT-2954"
  • Loading branch information
vesameskanen authored Apr 2, 2019
2 parents d4e4d35 + 88c5013 commit b77c046
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 100 deletions.
12 changes: 0 additions & 12 deletions app/component/CardHeader.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import PropTypes from 'prop-types';
import React from 'react';
import cx from 'classnames';
import { FormattedMessage } from 'react-intl';
import ComponentUsageExample from './ComponentUsageExample';
import Icon from './Icon';
import SplitBars from './SplitBars';
import Favourite from './Favourite';
import { getCityBikeNetworkName } from '../util/citybikes';

const CardHeader = ({
className,
Expand All @@ -19,7 +17,6 @@ const CardHeader = ({
icon,
icons,
unlinked,
network,
}) => (
<div className={cx('card-header', className)}>
{children}
Expand All @@ -44,14 +41,6 @@ const CardHeader = ({
{unlinked ? null : <span className="link-arrow"></span>}
</span>
<div className="card-sub-header">
{network && (
<p className="network-header">
<FormattedMessage
id={`network-${getCityBikeNetworkName(network)}`}
defaultMessage="Citybike Network"
/>
</p>
)}
{code != null ? <p className="card-code">{code}</p> : null}
{description != null && description !== 'null' ? (
<p className="sub-header-h4">{description}</p>
Expand Down Expand Up @@ -99,7 +88,6 @@ CardHeader.propTypes = {
icons: PropTypes.arrayOf(PropTypes.node),
children: PropTypes.node,
unlinked: PropTypes.bool,
network: PropTypes.string,
};

CardHeader.defaultProps = {
Expand Down
8 changes: 2 additions & 6 deletions app/component/CityBikeCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import CardHeader from './CardHeader';
import { station as exampleStation } from './ExampleData';
import ComponentUsageExample from './ComponentUsageExample';
import Card from './Card';
import {
getCityBikeNetworkIcon,
getCityBikeNetworkName,
} from '../util/citybikes';
import { getCityBikeNetworkIcon } from '../util/citybikes';

const CityBikeCard = ({ station, children, className }, { config }) => {
if (!station || !children || children.length === 0) {
Expand All @@ -18,10 +15,9 @@ const CityBikeCard = ({ station, children, className }, { config }) => {
return (
<Card className={className}>
<CardHeader
name={station.name}
description={config.cityBike.showStationId ? station.stationId : ''}
icon={getCityBikeNetworkIcon(station.networks)}
name={station.name}
network={getCityBikeNetworkName(station.networks)}
unlinked
/>
{children}
Expand Down
9 changes: 0 additions & 9 deletions app/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -833,10 +833,7 @@ const translations = {
navigate: 'Navigate',
'near-you': 'Near you',
nearest: 'Nearest',
'network-citybike': 'Helsinki and Espoo',
'network-citybike-vantaa': 'Vantaa',
'network-error': 'Network error',
'network-scooter': 'Vuosaari',
next: 'Next',
'no-bike-allowed-popup':
'Bicycles are not allowed on buses or trams. If you are using these vehicles on your route, leave the bicycle at the stop or at a Park-and-Ride. ',
Expand Down Expand Up @@ -1535,10 +1532,7 @@ const translations = {
navigate: 'Navigoi',
'near-you': 'Lähelläsi',
nearest: 'Lähimmät',
'network-citybike': 'Helsinki ja Espoo',
'network-citybike-vantaa': 'Vantaa',
'network-error': 'Verkkovirhe',
'network-scooter': 'Vuosaari',
next: 'Seuraava',
'no-bike-allowed-popup':
'Pyörää ei voi ottaa bussiin tai raitiovaunuun. Jos käytät reitilläsi näitä kulkuvälineitä, jätä pyörä pysäkille tai liityntäpysäköintiin.',
Expand Down Expand Up @@ -2546,10 +2540,7 @@ const translations = {
navigate: 'Navigera',
'near-you': 'Nära dig',
nearest: 'Närmaste',
'network-citybike': 'Helsingfors och Esbo',
'network-citybike-vantaa': 'Vanda',
'network-error': 'Nätverksfel',
'network-scooter': 'Nordsjö',
next: 'Nästa',
'no-bike-allowed-popup':
'Cyklar är inte tillåtna i bussar eller spårvagnar. Om du använder dessa fordon på din färd, lämna cykeln vid hållplatsen eller vid infartsparkeringen.',
Expand Down
16 changes: 7 additions & 9 deletions app/util/citybikes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,20 @@ export const BIKESTATION_CLOSED = 'Station closed';
const scooterNetwork = 'Samocat';
const vantaaNetwork = 'vantaa';

export const getCityBikeNetworkName = networks => {
const defaultName = 'citybike';
export const getCityBikeNetworkIcon = networks => {
const iconTemplate = iconName => `icon-icon_${iconName}`;
const defaultIcon = iconTemplate('citybike');

if (!Array.isArray(networks) || networks.length === 0) {
return defaultName;
return defaultIcon;
}

switch (networks[0]) {
case scooterNetwork:
return 'scooter';
return iconTemplate('scooter');
case vantaaNetwork:
return 'citybike-vantaa';
return iconTemplate('citybike-vantaa');
default:
return defaultName;
return defaultIcon;
}
};

export const getCityBikeNetworkIcon = networks =>
`icon-icon_${getCityBikeNetworkName(networks)}`;
7 changes: 0 additions & 7 deletions sass/base/_elements.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ $border-radius-rounded: 30px;

.card-header-wrapper {
flex-grow: 1;
.network-header{
font-family: $font-family;
font-weight: $font-weight-book;
font-size: $font-size-small;
margin-right: 5px;
color: $gray;
}
}
}

Expand Down
21 changes: 0 additions & 21 deletions test/unit/component/CardHeader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,4 @@ describe('<CardHeader />', () => {
const wrapper = shallowWithIntl(<CardHeader {...props} />);
expect(wrapper.find('.header-icon')).to.have.lengthOf(1);
});
it('should render the text for the network', () => {
const props = {
description: 'Ratapihantie',
headerIcon: <div className="header-icon" />,
name: 'Pasilan asema',
network: 'citybike',
};
const wrapper = shallowWithIntl(<CardHeader {...props} />);
expect(wrapper.find('.network-header').text());
});
it('should render the station code', () => {
const props = {
description: 'Ratapihantie',
headerIcon: <div className="header-icon" />,
name: 'Pasilan asema',
code: '7528',
network: 'citybike',
};
const wrapper = shallowWithIntl(<CardHeader {...props} />);
expect(wrapper.find('.card-code').text()).to.equal('7528');
});
});
14 changes: 0 additions & 14 deletions test/unit/component/CityBikeCard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,6 @@ describe('<CityBikeCard />', () => {
expect(wrapper.find(CardHeader).props().icon).to.equal('icon-icon_scooter');
});

it("should have the citybike network's name", () => {
const props = {
children: <div />,
station: {
name: 'Valimon asema',
networks: ['Samocat'],
},
};
const wrapper = shallowWithIntl(<CityBikeCard {...props} />, {
context: { config: { cityBike: {} } },
});
expect(wrapper.find(CardHeader).props().network).to.equal('scooter');
});

it("should include the citybike station's id in the description", () => {
const props = {
children: <div />,
Expand Down
23 changes: 1 addition & 22 deletions test/unit/util/citybikes.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
getCityBikeNetworkIcon,
getCityBikeNetworkName,
} from '../../../app/util/citybikes';
import { getCityBikeNetworkIcon } from '../../../app/util/citybikes';

describe('citybikes', () => {
describe('getCityBikeNetworkIcon', () => {
Expand All @@ -21,22 +18,4 @@ describe('citybikes', () => {
expect(result).to.equal('icon-icon_scooter');
});
});

describe('getCityBikeNetworkName', () => {
it('should default to "citybike" if the networks are falsy', () => {
const result = getCityBikeNetworkName(undefined);
expect(result).to.equal('citybike');
});

it('should default to "citybike" if no matching network is found', () => {
const result = getCityBikeNetworkName(['foobar']);
expect(result).to.equal('citybike');
});

it('should pick the first network', () => {
const networks = ['Samocat', 'Smoove'];
const result = getCityBikeNetworkName(networks);
expect(result).to.equal('scooter');
});
});
});

0 comments on commit b77c046

Please sign in to comment.