-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding find a timetable pattern page and pattern files themselves. * Update find a table widget. * Add params to label inside autocomplete. * Rename page and widget. Update widget page structure. * import scss into patterns scss. * Fix eslint error. * Update page title Co-authored-by: Gil <43111519+gldgrnt@users.noreply.github.com> * Update src/wmnds/patterns/find-a-timetable-widget/_find-a-timetable-widget.njk Co-authored-by: Gil <43111519+gldgrnt@users.noreply.github.com> * remove vscode custom settings * Update buttons order and remove design link. * Update tram link. * Update tram link. * Update to wmnetwork domain. * Update checkbox. * Adding js file. * Form submission is now working properly. JS is updated and html are updated. * Change tram link. * Update tram link. Co-authored-by: Gil <43111519+gldgrnt@users.noreply.github.com>
- Loading branch information
1 parent
fb7aca8
commit c76153e
Showing
8 changed files
with
242 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const findATimetableJS = () => { | ||
const findATimetableComponents = document.querySelectorAll('.wmnds-find-a-timetable-widget'); | ||
const toggleOpenClass = e => { | ||
e.target.closest('.wmnds-find-a-timetable-widget').classList.toggle('wmnds-is--open'); | ||
}; | ||
|
||
const onSubmitForm = e => { | ||
e.preventDefault(); | ||
const data = new FormData(e.target); | ||
const queryString = new URLSearchParams(data).toString(); | ||
window.location.href = `https://www.wmnetwork.co.uk/plan-your-journey/timetables/#/?${queryString}`; | ||
}; | ||
|
||
findATimetableComponents.forEach(findATimetableComponent => { | ||
findATimetableComponent | ||
.querySelector('div.wmnds-btn.wmnds-btn--mode') | ||
.addEventListener('click', toggleOpenClass); | ||
findATimetableComponent | ||
.querySelector('.wmnds-find-a-timetable-widget__form') | ||
.addEventListener('submit', onSubmitForm); | ||
}); | ||
}; | ||
|
||
export default findATimetableJS(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% raw %} | ||
{% from "wmnds/patterns/find-timetable-widget/_find-timetable-widget.njk" import wmndsFindTimetableWidget %} | ||
{{ | ||
wmndsFindTimetableWidget({ | ||
isOpen: true | ||
}) | ||
}} | ||
{% endraw %} |
108 changes: 108 additions & 0 deletions
108
src/wmnds/patterns/find-a-timetable-widget/_find-a-timetable-widget.njk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
{% macro wmndsFindATimetableWidget(params) %} | ||
|
||
{# Imports of components #} | ||
{% from "wmnds/components/content-card/_content-card.njk" import wmndsContentCard %} | ||
{% from "wmnds/components/form-elements/text-input/_text-input.njk" import wmndsTextInput %} | ||
{% from "wmnds/components/button/_button.njk" import wmndsButton %} | ||
{% from "wmnds/components/link/as-button/_as-button.njk" import wmndsLinkAsButton %} | ||
{% from "wmnds/components/icon/_icon.njk" import wmndsIcon %} | ||
|
||
{# Set params #} | ||
{% set formTitle = params.formTitle if params.formTitle else "Find a timetable" %} | ||
{% set contentText = params.contentText if params.contentText else "Select your transport mode" %} | ||
{% set contentHTML = params.contentHTML if params.contentHTML else null %} | ||
{% set _content = contentHTML | safe if contentHTML else contentText %} {# change content based on what user has input #} | ||
{% set isOpen = " wmnds-is--open" if params.isOpen %} | ||
{% set placeholder = "" if params.placeholder else "Enter a service number" %} | ||
{% set isChecked = "checked" if params.isOpen else "" %} | ||
|
||
|
||
<div style="max-width: 448px"> | ||
|
||
<div class="wmnds-find-a-timetable-widget {{isOpen}}"> | ||
|
||
{% call wmndsContentCard() %} | ||
<div class="wmnds-p-md"> | ||
|
||
<h2>{{formTitle}}</h2> | ||
<div class="wmnds-find-a-timetable__content"> | ||
{{_content}} | ||
</div> | ||
|
||
<form class="wmnds-find-a-timetable-widget__form"> | ||
|
||
<div class="wmnds-find-a-timetable-widget__travel-modes wmnds-grid wmnds-grid--spacing-3-sm wmnds-m-t-sm"> | ||
|
||
<label class="wmnds-col-1-3"> | ||
<input type="checkbox" class="wmnds-find-a-timetable-widget__mode-checkbox wmnds-screenreaders-only" name="mode" value="Bus" {{ isChecked }}> | ||
<div class="wmnds-btn wmnds-btn--mode wmnds-btn--block"> | ||
{{ | ||
wmndsIcon({ | ||
icon: 'modes-isolated-bus', | ||
class: 'wmnds-btn__icon ' | ||
}) | ||
}} | ||
Bus | ||
</div> | ||
</label> | ||
|
||
<div class="wmnds-col-1-3"> | ||
|
||
{{ | ||
wmndsLinkAsButton({ | ||
type: "mode", | ||
contentText: "Train", | ||
link: "https://www.wmnetwork.co.uk/plan-your-journey/timetables/#/?mode=Train", | ||
linkTarget: "_blank", | ||
classes:"wmnds-col-1 wmnds-m-b-sm", | ||
iconLeft: "modes-isolated-rail" | ||
}) | ||
}} | ||
|
||
</div> | ||
<div class="wmnds-col-1-3"> | ||
|
||
{{ | ||
wmndsLinkAsButton({ | ||
type: "mode", | ||
contentText: "Tram", | ||
link: "https://www.wmnetwork.co.uk/plan-your-journey/timetables/#/?mode=Tram&serviceNo=MM1&limit=6#%2F", | ||
linkTarget: "_blank", | ||
classes:"wmnds-col-1 wmnds-m-b-sm", | ||
iconLeft: "modes-isolated-metro" | ||
}) | ||
}} | ||
|
||
</div> | ||
</div> | ||
|
||
{% if params.isOpen %} | ||
<div class="wmnds-find-a-timetable-widget__services"> | ||
{{ | ||
wmndsTextInput({ | ||
id: "busServices", | ||
name: "serviceNo", | ||
label: { | ||
contentText: 'Bus Services', | ||
classes: 'wmnds-screenreaders-only' | ||
}, | ||
placeholder: 'Enter a service number', | ||
required: true, | ||
formGroup: { | ||
classes: 'wmnds-m-b-md' | ||
} | ||
}) | ||
}} | ||
<input type="submit" hidden="true"/> | ||
</div> | ||
{% endif %} | ||
|
||
</form> | ||
</div> | ||
{% endcall %} | ||
|
||
</div> | ||
</div> | ||
|
||
|
||
{% endmacro %} |
9 changes: 9 additions & 0 deletions
9
src/wmnds/patterns/find-a-timetable-widget/_properties.njk.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"wmndsFindATimetableProps": [ | ||
{ | ||
"name": "isOpen", | ||
"type": "boolean", | ||
"description": "If true, find timetable widget will be expanded upon initial load. Defaults to <code class='wmnds-website-inline-code'>false</code>." | ||
} | ||
] | ||
} |
23 changes: 23 additions & 0 deletions
23
src/wmnds/patterns/find-a-timetable-widget/find-a-timetable-widget.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.wmnds-find-a-timetable-widget { | ||
&__services { | ||
display: none; | ||
} | ||
|
||
&.wmnds-is--open { | ||
.wmnds-find-a-timetable-widget__services { | ||
display: block; | ||
} | ||
} | ||
|
||
&__mode-checkbox { | ||
&:focus + .wmnds-btn--mode { | ||
background-color: $white; | ||
box-shadow: 0 0 0 2px $white, 0 0 0 4px get-color(secondary); | ||
} | ||
|
||
&:checked + .wmnds-btn--mode { | ||
background-color: get-color(secondary, 50); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -227,6 +227,9 @@ | |
{ | ||
"name": "Feedback loop" | ||
}, | ||
{ | ||
"name": "Find a timetable" | ||
}, | ||
{ | ||
"name": "Footer" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{% extends "www/_layouts/layout-left-pane.njk" %} | ||
{% set pageTitle = "Find a timetable" %} | ||
|
||
{% set section="Patterns" %} | ||
{% from "www/_partials/component-example/component-example.njk" import compExample %} | ||
{% from "wmnds/patterns/find-a-timetable-widget/_find-a-timetable-widget.njk" import wmndsFindATimetableWidget %} | ||
|
||
{% block content %} | ||
|
||
{% markdown %} | ||
|
||
## What does it do? | ||
* Helps users to find a timetable for their chosen service | ||
|
||
|
||
## When to use it? | ||
* On the homepage | ||
|
||
|
||
## How it works? | ||
* This will direct users to the timetables page | ||
* Users can only select one travel mode | ||
* Users will need to enter a service number if they select bus. If train or tram are selected, then users can go straight to the timetables page through the [Call to action button](https://designsystem.wmnetwork.co.uk/components/buttons/). | ||
|
||
|
||
### Default | ||
|
||
{% endmarkdown %} | ||
|
||
{{ | ||
compExample([ | ||
wmndsFindATimetableWidget() | ||
], { | ||
componentPath: "wmnds/patterns/find-a-timetable-widget/", | ||
njk: true, | ||
njkProps: wmndsFindATimetableWidgetProps, | ||
js: true, | ||
iframe: false | ||
} | ||
) | ||
}} | ||
|
||
{% markdown %} | ||
|
||
### Expanded (bus) | ||
|
||
|
||
{% endmarkdown %} | ||
|
||
{{ | ||
compExample([ | ||
wmndsFindATimetableWidget({ | ||
isOpen: true | ||
}) | ||
], { | ||
componentPath: "wmnds/patterns/find-a-timetable-widget/", | ||
njk: true, | ||
njkProps: wmndsFindATimetableWidgetProps, | ||
js: true, | ||
iframe: false | ||
} | ||
) | ||
}} | ||
|
||
{% endblock %} |