Skip to content

Commit

Permalink
Merge pull request #36 from wmcadigital/next-release
Browse files Browse the repository at this point in the history
fix: show correct rail zone names and mobile key styling
  • Loading branch information
daylesalmon authored May 5, 2021
2 parents 232e004 + 97d90b2 commit a464b14
Show file tree
Hide file tree
Showing 27 changed files with 332 additions and 46 deletions.
21 changes: 0 additions & 21 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -196,27 +196,6 @@ <h3>Your privacy settings</h3>
</div>
</div>
<!-- End feedback form -->
<!-- Breadcrumbs -->
<nav aria-label="Breadcrumb" class="wmnds-breadcrumb">
<ol class="wmnds-breadcrumb__list">
<li class="wmnds-breadcrumb__list-item">
<a href="//wmnetwork.co.uk" class="wmnds-breadcrumb__link">Home</a>
</li>
<!-- <li class="wmnds-breadcrumb__list-item">
<a href="//wmnetwork.co.uk/sub-page/" class="wmnds-breadcrumb__link"> Sub page </a>
</li> -->
<li class="wmnds-breadcrumb__list-item">
<a
href="/"
class="wmnds-breadcrumb__link wmnds-breadcrumb__link--current"
aria-current="page"
>
%REACT_APP_TITLE%
</a>
</li>
</ol>
</nav>
<!-- End Breadcrumbs -->
</div>
</header>

Expand Down
5 changes: 2 additions & 3 deletions src/components/RailZoneFinder/ListView/ListView.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React, { useState } from 'react';

import Button from '../../shared/Button/Button';
import AccessIcon from '../../shared/Icon/AccessIcon';
import Icon from '../../shared/Icon/Icon';
import AccessibilityKey from '../../shared/AccessibilityKey/AccessibilityKey';
import Accordion from '../../shared/Accordion/Accordion';
import TrayComponents from '../../shared/SearchComponents/SearchComponents';
import AutoComplete from '../../shared/AutoComplete/AutoComplete';
import s from './ListView.module.scss';

import railData from '../RailData.json';
Expand Down Expand Up @@ -39,7 +38,7 @@ const ListView = () => {
<div className="wmnds-grid wmnds-grid--spacing-md-2-lg wmnds-p-b-md">
<div className="wmnds-col-1-1 wmnds-col-md-2-3">
<div className={`bg-white wmnds-p-md ${s.trayComponents}`}>
<TrayComponents />
<AutoComplete />
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/RailZoneFinder/MapView/MapView.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
// Rail zone svg component
import Map from '../Map/Map';
import TrayComponents from '../../shared/SearchComponents/SearchComponents';
import AutoComplete from '../../shared/AutoComplete/AutoComplete';
import s from './MapView.module.scss';

const MapView = () => {
Expand All @@ -10,7 +10,7 @@ const MapView = () => {
<div className={`${s.container} wmnds-grid wmnds-grid--spacing-md-2-lg`}>
<div className="wmnds-col-1-1 wmnds-col-md-1-2 wmnds-col-lg-1-3">
<div className="bg-white wmnds-p-md">
<TrayComponents />
<AutoComplete />
</div>
</div>
<div className="wmnds-col-1-1 wmnds-col-md-1-2 wmnds-col-lg-2-3">
Expand Down
18 changes: 17 additions & 1 deletion src/components/RailZoneFinder/RailZoneFinder.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import React, { useContext } from 'react';
import { MapContext } from 'globalState';
import { MapContext, AutoCompleteContext } from 'globalState';
// Rail zone svg component
import Button from '../shared/Button/Button';
import Icon from '../shared/Icon/Icon';
import Breadcrumbs from '../shared/Breadcrumbs/Breadcrumbs';
import MapView from './MapView/MapView';
import ListView from './ListView/ListView';
import s from './RailZoneFinder.module.scss';

function RailZoneFinder() {
const [autoCompleteState] = useContext(AutoCompleteContext);
const [mapState, mapDispatch] = useContext(MapContext);
const { mapView } = mapState;
// Toggle between map and list view
Expand All @@ -16,9 +19,22 @@ function RailZoneFinder() {
payload: !mapView,
});
};

return (
<>
<div className="wmnds-container">
{autoCompleteState.ticketMode ? (
<div className="wmnds-m-b-lg wmnds-m-t-md">
<a
href="https://find-a-ticket.wmnetwork.co.uk/"
className={`wmnds-btn wmnds-btn--link ${s.backLink}`}
>
<Icon iconName="general-chevron-right" /> Back to ticket finder
</a>
</div>
) : (
<Breadcrumbs />
)}
<div className={`wmnds-grid wmnds-grid--justify-between ${s.mainHeading}`}>
<div className="wmnds-col-auto">
<h1>Find my rail zones</h1>
Expand Down
11 changes: 11 additions & 0 deletions src/components/RailZoneFinder/RailZoneFinder.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,14 @@
white-space: nowrap;
}
}

.backLink {
display: inline-flex;
align-items: center;

svg {
margin-right: $size-xsm;
transform: rotate(180deg);
fill: currentColor;
}
}
2 changes: 1 addition & 1 deletion src/components/shared/AccessibilityKey/AccessibilityKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const AccessibilityKey = ({ mapView }) => {
/>
) : (
<div className={`wmnds-p-md bg-white ${s.accessMenu} ${s.mapKey}`}>
<div className="wmnds-grid wmnds-grid--justify-between">
<div className={`wmnds-grid wmnds-grid--justify-between ${s.keyHeader}`}>
<h3 className="wmnds-col-auto">Show parking and accessibility</h3>
<div className="wmnds-col-auto">
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@
text-align: right;
}

.keyHeader {
flex-wrap: nowrap;

& > h3 {
text-align: left;
}

& > .hideKeyBtn {
display: inline-flex;
flex-wrap: nowrap;
}
}

@media (min-width: $breakpoint-md) and (min-height: $breakpoint-sm) {
.mapKeyContainer {
position: sticky;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import React, { useContext } from 'react';
import { AutoCompleteContext } from 'globalState';
// Import components
import Button from '../Button/Button';
import Icon from '../Icon/Icon';
import Result from '../Result/Result';
import TrainAutoComplete from './TrainAutoComplete/TrainAutocomplete';
import s from './SearchComponents.module.scss';
import s from './AutoComplete.module.scss';
// Import custom hook
import useMapControls from '../../RailZoneFinder/Map/customHooks/useMapControls';

const TrayComponents = () => {
const AutoComplete = () => {
const [autoCompleteState, autoCompleteDispatch] = useContext(AutoCompleteContext);
const { selectedStations } = autoCompleteState;
const { resetMap } = useMapControls();
Expand All @@ -23,6 +24,22 @@ const TrayComponents = () => {
autoCompleteDispatch({ type: 'RESET_SELECTED_SERVICES' });
};

// Spread ids of selected stations into an array
const selectedStationIds = [...selectedStations.map((stn) => stn.id)];
let linkParams = '';
// Loop through station ids and append a selected station id param to string
selectedStationIds.forEach((id, i) => {
if (id) {
linkParams += `${i === 0 ? '?' : '&'}selectedStation${i}=${id}`;
}
});

// Show continue button if:
// - ticket search mode is true
// - more than one station is selected
const continueBtn =
autoCompleteState.ticketMode && selectedStations.filter((stn) => stn.id).length > 1;

return (
<>
<div className={`${s.trayHeader}`}>
Expand Down Expand Up @@ -59,8 +76,20 @@ const TrayComponents = () => {
/>
</div>
<Result />
{continueBtn && (
<a
href={`https://find-a-ticket.wmnetwork.co.uk/${linkParams}`}
className="wmnds-btn wmnds-btn--icon wmnds-col-1 wmnds-col-sm-auto"
>
Continue
<Icon
className="wmnds-btn__icon wmnds-btn__icon--right"
iconName="general-chevron-right"
/>
</a>
)}
</>
);
};

export default TrayComponents;
export default AutoComplete;
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const useAutoCompleteAPI = (queryId) => {
? railData.railStationAccess.filter((station) => {
return station.stationName.toLowerCase().includes(query.trim().toLowerCase());
})
: [];
: railData.railStationAccess;
handleAutoCompleteApiResponse(response);
}, [handleAutoCompleteApiResponse, query]);

Expand Down
28 changes: 28 additions & 0 deletions src/components/shared/Breadcrumbs/Breadcrumbs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';

const { REACT_APP_TITLE } = process.env;

function Breadcrumbs() {
return (
<nav ariaLabel="Breadcrumb" className="wmnds-breadcrumb">
<ol className="wmnds-breadcrumb__list">
<li className="wmnds-breadcrumb__list-item">
<a href="//wmnetwork.co.uk" className="wmnds-breadcrumb__link">
Home
</a>
</li>
<li className="wmnds-breadcrumb__list-item">
<a
href="/"
className="wmnds-breadcrumb__link wmnds-breadcrumb__link--current"
ariaCurrent="page"
>
{REACT_APP_TITLE}
</a>
</li>
</ol>
</nav>
);
}

export default Breadcrumbs;
54 changes: 54 additions & 0 deletions src/components/shared/Radios/Radio/Radio.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* eslint-disable jsx-a11y/label-has-associated-control */
import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import dompurify from 'dompurify';

// Import contexts
import { FormContext } from 'globalState';

import s from './Radio.module.scss';

const { sanitize } = dompurify;

const Radio = ({ name = '', onChange, text, value, info }) => {
const [formState] = useContext(FormContext); // Get the state/dispatch of form data from FormContext

return (
<>
<label className={`${s.radioContainer} wmnds-fe-radios__container`}>
<div className={s.text} dangerouslySetInnerHTML={{ __html: sanitize(text) }} />
<input
className={`${s.radio} wmnds-fe-radios__input`}
value={value}
name={name}
type="radio"
onChange={onChange}
defaultChecked={formState[name] && formState[name] === value}
/>
{info && (
<div
className={`${s.insetText} wmnds-inset-text wmnds-m-t-xs`}
dangerouslySetInnerHTML={{ __html: sanitize(info) }}
/>
)}
<span className="wmnds-fe-radios__checkmark" />
</label>
</>
);
};

Radio.propTypes = {
name: PropTypes.string,
onChange: PropTypes.func,
text: PropTypes.string.isRequired,
value: PropTypes.string.isRequired,
info: PropTypes.string,
};

Radio.defaultProps = {
name: '',
onChange: null,
info: null,
};

export default Radio;
34 changes: 34 additions & 0 deletions src/components/shared/Radios/Radio/Radio.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Refer to https://create-react-app.dev/docs/adding-a-css-modules-stylesheet
// On how to use scss modules with React

// Import WMN Design System scss for use in this scss file
// Tilde (~) represents the root folder(src)
@import '~assets/wmnds/vars';
@import '~assets/wmnds/mixins';

.text {
display: inline-flex;
min-height: 35px;
flex-direction: column;
justify-content: center;
align-items: flex-start;

strong {
display: block;
}
}

.radioContainer {
flex-wrap: wrap;
}

.insetText {
display: none;
flex: 0 0 100%;
}

.radio {
&:checked + .insetText {
display: block;
}
}
Loading

0 comments on commit a464b14

Please sign in to comment.