Skip to content

Commit

Permalink
feat: add journey planner pattern and update pattern page (#781)
Browse files Browse the repository at this point in the history
* Add jorney planner (based on the widget code). Update the pattern page for both.

* Adding missing aria-labels.

* Delete Anything else section.

* Update used domain.

* Add missing endblock.

* Update button mode active color and update switch color.
  • Loading branch information
catiarodriguescosta committed May 17, 2021
1 parent f968ff0 commit cd44140
Show file tree
Hide file tree
Showing 9 changed files with 408 additions and 26 deletions.
5 changes: 5 additions & 0 deletions src/wmnds/components/button/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ $btn-transition: ease-in-out background-color 0.2s, ease-in-out border 0.2s;
width: 100%;
}

// block modifier for full width buttons
&--align-left {
text-align: left;
}

// Show button like a normal link modifier
&--link {
display: inline;
Expand Down
3 changes: 2 additions & 1 deletion src/wmnds/patterns/_patterns.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
@import "travel-updates/travel-updates"; // Travel updates styles
@import "travel-mode-page-banner/travel-mode-page-banner"; // page-banner
@import "search/search"; // Search pattern styles
@import "journey-planner-widget/journey-planner-widget"; // Search pattern styles
@import "journey-planner-widget/journey-planner-widget"; // Journey planner widget styles
@import "journey-planner/journey-planner"; // Journey planner styles
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<h2>{{formTitle}}</h2>

<form class="wmnds-journey-planner-widget__form" action="//journeyplanner.networkwestmidlands.com/Home/HandleWidgetQuery" method="GET" name="planYourJourneySmallForm" novalidate="novalidate">
<form class="wmnds-journey-planner-widget__form" action="//journeyplanner.wmnetwork.co.uk/Home/HandleWidgetQuery" method="GET" name="planYourJourneySmallForm">

<div class="wmnds-journey-planner-widget__from wmnds-m-b-md">
{{
Expand Down
3 changes: 3 additions & 0 deletions src/wmnds/patterns/journey-planner/_example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const journeyPlannerJS = () => {};

export default journeyPlannerJS;
11 changes: 11 additions & 0 deletions src/wmnds/patterns/journey-planner/_example.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% raw %}
{% from "wmnds/components/journey-planner/_journey-planner.njk" import wmndsJourneyPlanner %}
{{
wmndsJourneyPlanner({
isOpen: true,
isHowOpen: false,
isWhenOpen: false
})
}}
{% endraw %}
228 changes: 228 additions & 0 deletions src/wmnds/patterns/journey-planner/_journey-planner.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
{% macro wmndsJourneyPlanner(params) %}

{# Imports of components #}
{% from "wmnds/patterns/autocomplete/_autocomplete.njk" import wmndsAutocomplete %}
{% from "wmnds/components/button/_button.njk" import wmndsButton %}
{% from "wmnds/components/link/link/_link.njk" import wmndsLink %}
{% from "wmnds/components/icon/_icon.njk" import wmndsIcon %}
{% from "wmnds/components/form-elements/dropdown/_dropdown.njk" import wmndsDropdown %}
{% from "wmnds/components/message/summary/_summary.njk" import wmndsMsgSummary %}


{# Set params #}
{% set formTitle = params.formTitle if params.formTitle else "Plan your journey" %}
{% set isOpen = " wmnds-is--open" if params.isOpen %}
{% set suffix = "--opened" if params.isOpen else "--collapsed" %}
{% set detailsBtnText = "Hide details" if params.isOpen else "Add details" %}
{% set detailsBtnIcon = "general-minimise" if params.isOpen else "general-expand" %}
{% set marginTopClass = "" if params.isOpen else "wmnds-m-t-lg" %}




<div style="max-width: 448px">

<div class="wmnds-journey-planner {{isOpen}}">

<div class="wmnds-p-md">

<h2>{{formTitle}}</h2>

<form class="wmnds-journey-planner__form" name="jphome" action="//journeyplanner.wmnetwork.co.uk/Home/HandleWidgetQuery" method="GET">

<div class="wmnds-journey-planner__from">
{{
wmndsAutocomplete({
id: ("mainjp-from" + suffix ),
name: "origin",
label: {
contentText: 'From',
classes: "h5"
},
placeholder: 'Enter station or postcode',
loading: false,
showSuggestions: false,
textSuggestions: true,
isRequired: true
})
}}
</div>

<div class="wmnds-journey-planner__to">
<div class="wmnds-journey-planner__switch">
{{
wmndsButton({
type: "link",
contentText: "Switch",
classes: "wmnds-m-t--lg"
})
}}

{{
wmndsIcon({
icon: 'general-swap',
class: 'wmnds-journey-planner__switch-icon'
}) | safe
}}
</div>

{{
wmndsAutocomplete({
id: ("mainjp-to" + suffix),
name: "destination",
label: {
contentText: 'To',
classes: "h5"
},
placeholder: 'Enter station or postcode',
loading: false,
showSuggestions: false,
textSuggestions: true,
isRequired: true
})
}}

</div>


<div class="wmnds-journey-planner__how">
<h5>Which modes of transport will you use?</h5>
<div class="wmnds-grid wmnds-grid--spacing-3-sm">
<div class="wmnds-col-1-3">
<input type="checkbox" class="wmnds-screenreaders-only" name="useBus" aria-label="bus" checked/>
{{
wmndsButton({
iconLeft: "modes-isolated-bus",
contentText: "Bus",
type: "mode",
classes:"wmnds-col-1"
})
}}
</div>
<div class="wmnds-col-1-3">
<input type="checkbox" class="wmnds-screenreaders-only" name="useTram" aria-label="tram" checked/>
{{
wmndsButton({
iconLeft: "modes-isolated-metro",
contentText: "Tram",
type: "mode",
classes:"wmnds-col-1"
})
}}
</div>
<div class="wmnds-col-1-3">
<input type="checkbox" class="wmnds-screenreaders-only" name="useTrain" aria-label="train" checked />
{{
wmndsButton({
iconLeft: "modes-isolated-rail",
contentText: "Train",
type: "mode",
classes:"wmnds-col-1"
})
}}
</div>


</div>
</div>

<div class="wmnds-journey-planner__when">

<h5>Leaving</h5>
<input type="hidden" name="journeyTimeType" value="leave"/>

<div class="wmnds-grid wmnds-grid--spacing-2-lg">
<div class="wmnds-col-2-3">
{{
wmndsDropdown({
id: ("mainjp-day" + suffix ),
secondaryColor: true,
name: "day",
items: [
{
value: "today",
contentText: "Today",
selected: true,
disabled: false
},
{
value: "tomorrow",
contentText: "Tomorrow",
selected: false,
disabled: false
}
],
describedBy: null,
label: "Day",
labelClasses: "wmnds-screenreaders-only",
classes: null,
error: false,
errorMessage: {
id: null,
contentText: "Please select an option",
contentHTML: null,
classes: null
}
})
}}
</div>
<div class="wmnds-col-1-3">
{{
wmndsDropdown({
id: ("mainjp-time" + suffix),
name: "SelectJourneyTime",
secondaryColor: true,
type: "time",
describedBy: null,
label: "Time",
labelClasses: "wmnds-screenreaders-only",
classes: null,
error: false,
errorMessage: {
id: null,
contentText: "Please select an option",
contentHTML: null,
classes: null
}
})
}}
</div>
</div>

</div>

<div class="wmnds-journey-planner__submit {{marginTopClass}}">
<div class="wmnds-grid wmnds-grid--spacing-2-lg">
<div class="wmnds-col-1-2">
{{
wmndsButton({
contentText: detailsBtnText,
classes: "wmnds-btn--block wmnds-btn--align-left",
role: "button",
isDarkBg: true,
iconRight: detailsBtnIcon
})
}}
</div>
<div class="wmnds-col-1-2">
{{
wmndsButton({
contentText: "Plan my journey",
classes: "wmnds-btn--block wmnds-btn--align-left",
role: "submit",
iconRight: "general-chevron-right"
})
}}
</div>
</div>
</div>

</form>
</div>


</div>
</div>


{% endmacro %}
54 changes: 54 additions & 0 deletions src/wmnds/patterns/journey-planner/_journey-planner.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
.wmnds-journey-planner {
color: $white;
background-color: get-color(primary);

h2,
.wmnds-btn--link {
color: $white;
}

&__form {
& > div:not(.wmnds-journey-planner__from):not(.wmnds-journey-planner__to):not(.wmnds-journey-planner__submit) {
display: none;
}
}

&.wmnds-is--open {
& .wmnds-journey-planner__form > div {
display: block !important;
}
}

&__to {
position: relative;
}

&__switch {
display: flex;
position: absolute;
top: 0;
right: 0;
align-items: center;
justify-content: flex-end;
}

&__switch-icon {
width: 17px;
height: 23px;
margin-left: 8px;
fill: $white;
}

.wmnds-btn--mode:active,
.wmnds-btn--mode:focus,
.wmnds-btn--mode:target {
background-color: get-color(secondary, 50);
}

// Leave and arrive for when, modes for how
&__when,
&__how {
position: relative;

}
}
19 changes: 19 additions & 0 deletions src/wmnds/patterns/journey-planner/_properties.njk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"wmndsJourneyPlannerProps": [
{
"name": "isOpen",
"type": "boolean",
"description": "If true, journey planner will be expanded. Defaults to <code class='wmnds-website-inline-code'>false</code>."
},
{
"name": "isWhenOpen",
"type": "boolean",
"description": "If true, journey planner area to define when you want to travel will be expanded. Defaults to <code class='wmnds-website-inline-code'>false</code>."
},
{
"name": "isHowOpen",
"type": "boolean",
"description": "If true, journey planner area to define how (the mode of travel) do you want to travel will be expanded. Defaults to <code class='wmnds-website-inline-code'>false</code>."
}
]
}
Loading

0 comments on commit cd44140

Please sign in to comment.