Skip to content

Commit

Permalink
feat: add purple branded banner pattern (#785)
Browse files Browse the repository at this point in the history
* add branded banner files

* add description text

* style banner

* add pattern params

* replace home page with new banner

* update props & example

* update description

Co-authored-by: Catia Costa <34938764+catiarodriguescosta@users.noreply.github.com>
  • Loading branch information
houbly and catiarodriguescosta authored May 19, 2021
1 parent cd44140 commit 5ce3a3b
Show file tree
Hide file tree
Showing 8 changed files with 240 additions and 41 deletions.
3 changes: 2 additions & 1 deletion src/wmnds/patterns/_patterns.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// This file is imported from ./assets/sass/wmnds-components.scss

@import "autocomplete/autocomplete"; // Autocomplete
@import "banner/banner"; // Banner styles
@import "banner/banner"; // Header styles
@import "branded-banner/branded-banner"; // Header styles
@import "buy-a-ticket/buy-a-ticket"; // Buy a ticket styles
@import "cookies/cookies"; // Cookies styles
@import "contact-details/contact-details"; // contact-details styles
Expand Down
82 changes: 82 additions & 0 deletions src/wmnds/patterns/branded-banner/_branded-banner.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{% macro wmndsBrandedBanner(params) %}
{# Imports #}
{% from "wmnds/components/breadcrumb/_breadcrumb.njk" import wmndsBreadcrumb %}
{% from "wmnds/components/icon/_icon.njk" import wmndsIcon %}
{% from "wmnds/components/link/as-button/_as-button.njk" import wmndsLinkAsButton %}

{# Set vars #}
{% set titleHTML = params.title if params.title else "" %}
{% set breadcrumbItems = params.breadcrumbItems %}
{% set contentCol1 = params.contentCol1 %}
{% set contentCol2 = params.contentCol2 %}
{% set ctaButton = params.ctaButton %}

<div class="wmnds-branded-banner">
<div class="wmnds-container">
<div class="wmnds-grid wmnds-grid--spacing-lg-2-xl wmnds-m-t-sm wmnds-m-b-sm">
<div class="wmnds-col-1 wmnds-col-md-2-3">
{% if breadcrumbItems %}
{{
wmndsBreadcrumb({
items: breadcrumbItems
})
}}
{% endif %}
{% if titleHTML %}
<h1 class="wmnds-branded-banner__title">
{{ titleHTML | safe }}
</h1>
{% endif %}
{% if contentCol1 %}
{{ contentCol1 | safe }}
{% else %}
{% if titleHtml !== null %}
<h1 class="wmnds-branded-banner__title">
{{
wmndsIcon({
icon: 'swift-full-logo',
class: 'wmnds-swift-logo-inline'
})
}} and tickets
</h1>
{% endif %}
<p class="h3">We sell lots of tickets for bus, train and tram travel in the West Midlands</p>
<p>You can also combine different modes of travel to suit your needs. <br>Tickets can last from 1 day to a year.</p>
{% endif %}
</div>
{% if contentCol2 %}
<div class="wmnds-col-1 wmnds-col-md-1-3">
<div class="wmnds-col-1">
{{ contentCol2 | safe }}
</div>
</div>
{% endif %}
</div>
{% if ctaButton %}
<div class="wmnds-col-1">
{{
wmndsLinkAsButton({
contentText: ctaButton.contentText if ctaButton.contentText else "Button text",
link: ctaButton.link if ctaButton.link else "#",
linkTitle: ctaButton.linkTitle if ctaButton.linkTitle else ctaButton.contentText,
linkTarget: ctaButton.linkTarget if ctaButton.linkTarget else "_self",
iconRight: 'general-chevron-right',
classes: 'wmnds-btn--dark-bg'
})
}}
</div>
{% else %}
<div class="wmnds-col-1">
{{
wmndsLinkAsButton({
contentText: 'Find a ticket',
iconRight: 'general-chevron-right',
iconRight: 'general-chevron-right',
classes: 'wmnds-btn--dark-bg'
})
}}
</div>
{% endif %}
</div>
</div>
{% endmacro %}
34 changes: 34 additions & 0 deletions src/wmnds/patterns/branded-banner/_branded-banner.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.wmnds-branded-banner {
padding: $size-lg 0;
color: $white;
background-color: get-color(primary);

.wmnds-breadcrumb {
padding: 0;

&__link,
&__list-item::before {
color: $white;
}
}

&__title {
color: currentColor;

svg {
width: 1em;
height: 1em;
fill: currentColor;
vertical-align: text-top;
}
}

// helper class for aligning swift logo icon
.wmnds-swift-logo-inline {
width: 3.6em;
height: 1.3em;
margin-top: -0.175em;
fill: currentColor;
vertical-align: middle;
}
}
15 changes: 15 additions & 0 deletions src/wmnds/patterns/branded-banner/_example.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% raw %}
{% from "wmnds/patterns/branded-banner/_branded-banner.njk" import wmndsBrandedBanner %}
{{
wmndsBrandedBanner({
title: "<svg class=\"wmnds-swift-logo-inline\"><use xlink:href=\"#wmnds-swift-full-logo\" href=\"#wmnds-swift-full-logo\"></use></svg> and tickets",
contentCol1: "<p class=\"h3\">We sell lots of tickets for bus, train and tram travel in the West Midlands</p><p>You can also combine different modes of travel to suit your needs. <br>Tickets can last from 1 day to a year.</p>",
ctaButton: {
contentText: 'Find a ticket',
link: '#',
linkTitle: 'Find a ticket'
}
})
}}
{% endraw %}
51 changes: 51 additions & 0 deletions src/wmnds/patterns/branded-banner/_properties.njk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"wmndsBrandedBannerProps": [
{
"name": "title",
"type": "string",
"description": "<strong>Required.</strong> HTML content to use as the title in the banner."
},
{
"name": "contentCol1",
"type": "string",
"description": "<strong>Required.</strong> HTML content to use in the first column of the banner."
},
{
"name": "contentCol2",
"type": "string",
"description": "HTML content to use in the second column of the banner. If left blank, this column will not display."
},
{
"name": "breadcrumbItems",
"type": "array",
"description": "Array of breadcrumb items to show in the banner. See the <code class='wmnds-website-inline-code'>items</code> property under <a href='/components/breadcrumb/'>Breadcrumb</a>."
},
{
"name": "ctaButton",
"type": "object",
"description": "Call to action link (displayed as a button) to use in the banner. If not supplied, no button will be displayed.",
"arrayOptions": [
{
"name": "contentText",
"type": "string",
"description": "<strong>Required.</strong> Text to use within the button."
},
{
"name": "link",
"type": "string",
"description": "<strong>Required.</strong> Link for the button."
},
{
"name": "linkTitle",
"type": "string",
"description": "Text to use as the link title."
},
{
"name": "linkTarget",
"type": "string",
"description": "Target attribute for the link. Defaults to \"_self\""
}
]
}
]
}
2 changes: 0 additions & 2 deletions src/www/_layouts/layout-homepage.njk
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

{% block summary %}
<div class="wmnds-website-summary-content">
<div class="wmnds-grid wmnds-container">
{% block summaryContent %}{% endblock summaryContent %}
</div>
</div>
{% endblock summary %}
{% block body %}
Expand Down
54 changes: 17 additions & 37 deletions src/www/pages/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,26 @@
{# Imports #}
{% from "wmnds/components/link/link/_link.njk" import wmndsLink %}
{% from "wmnds/components/content-card/_content-card.njk" import wmndsContentCard %}
{% from "wmnds/patterns/branded-banner/_branded-banner.njk" import wmndsBrandedBanner %}
{% from "wmnds/components/link/as-button/_as-button.njk" import wmndsLinkAsButton %}

{# Top/purple section #}
{% block summaryContent %}
<div class="wmnds-col-1 wmnds-m-t-lg wmnds-m-b-lg">
<div class="wmnds-grid wmnds-grid--spacing-lg-2-xl wmnds-m-t-sm wmnds-m-b-sm">
<div class="wmnds-col-1 wmnds-col-lg-2-3 white">
<h1 id="wmnds-main-content" class="white">Design and build digital services for transport in the West Midlands</h1>
<p class="emphasised">
Use this design system to build consistent, usable services. Learn from the research and experience of other teams.
</p>
<br>
<p>
You can use GitHub to <a href="https://github.com/wmcadigital/wmn-design-system/blob/master/doc/contributing.md" title="View and contribute code to the Design System on GitHub" target="_blank" rel="noopener noreferrer" class="wmnds-link wmnds-website-summary-content__link">view and contribute code</a>, <a href="https://github.com/wmcadigital/wmn-design-system/issues/new?assignees=mrmjprice%2CKaterinaKir&labels=feature_request&template=feature_proposal.md&title=" title="Give feedback or propose an idea about the Design System on GitHub" target="_blank" rel="noopener noreferrer" class="wmnds-link wmnds-website-summary-content__link">give feedback or propose an idea</a>, or <a href="https://github.com/wmcadigital/wmn-design-system/issues/new?assignees=&labels=&template=report_bug.md&title=" title="Report an issue with the Design System on GitHub" target="_blank" rel="noopener noreferrer" class="wmnds-link wmnds-website-summary-content__link">report an issue</a>.
</p>
</div>
{# Design system version / Current release #}
<div class="wmnds-col-1 wmnds-col-lg-1-3">
<div class="wmnds-col-1">
{{
wmndsContentCard({
contentHTML: "<div class=\"wmnds-p-sm\"><h2>Current release</h2><p>The current release is <a href=\"https://github.com/wmcadigital/wmn-design-system/releases/tag/v$*version\" title=\"View release notes for version $*version on GitHub\" target=\"_blank\" rel=\"noopener noreferrer\">version $*version</a> which was released on $*releaseDate.</p><p>You can get alerts about new releases by <a href=\"https://docs.github.com/en/free-pro-team@latest/github/managing-subscriptions-and-notifications-on-github/viewing-your-subscriptions\" target=\"_blank\" rel=\"noopener noreferrer\">watching the design system on GitHub</a>.</p></div>"
})
}}
</div>
</div>
</div>

{# Get started button #}
{{
wmndsLinkAsButton({
{{
wmndsBrandedBanner({
title: 'Design and build digital services for transport in the West Midlands',
contentCol1: "<p class=\"emphasised\">Use this design system to build consistent, usable services. Learn from the research and experience of other teams.</p><br><p>You can use GitHub to <a href=\"https://github.com/wmcadigital/wmn-design-system/blob/master/doc/contributing.md\" title=\"View and contribute code to the Design System on GitHub\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"wmnds-link wmnds-website-summary-content__link\">view and contribute code</a>, <a href=\"https://github.com/wmcadigital/wmn-design-system/issues/new?assignees=mrmjprice%2CKaterinaKir&labels=feature_request&template=feature_proposal.md&title=\" title=\"Give feedback or propose an idea about the Design System on GitHub\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"wmnds-link wmnds-website-summary-content__link\">give feedback or propose an idea</a>, or <a href=\"https://github.com/wmcadigital/wmn-design-system/issues/new?assignees=&labels=&template=report_bug.md&title=\" title=\"Report an issue with the Design System on GitHub\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"wmnds-link wmnds-website-summary-content__link\">report an issue</a>.</p>",
contentCol2: wmndsContentCard({
contentHTML: "<div class=\"wmnds-p-sm\"><h2>Current release</h2><p>The current release is <a href=\"https://github.com/wmcadigital/wmn-design-system/releases/tag/v$*version\" title=\"View release notes for version $*version on GitHub\" target=\"_blank\" rel=\"noopener noreferrer\">version $*version</a> which was released on $*releaseDate.</p><p>You can get alerts about new releases by <a href=\"https://docs.github.com/en/free-pro-team@latest/github/managing-subscriptions-and-notifications-on-github/viewing-your-subscriptions\" target=\"_blank\" rel=\"noopener noreferrer\">watching the design system on GitHub</a>.</p></div>"
}),
ctaButton: {
contentText: 'Get started',
link: '/docs/get-started/',
linkTitle: 'Get started with the Transport for West Midlands Design System',
classes: 'wmnds-btn--dark-bg',
iconRight: 'general-chevron-right'
})
}}

</div>
linkTitle: 'Get started with the Transport for West Midlands Design System'
}
})
}}
{% endblock summaryContent %}


Expand All @@ -52,14 +32,14 @@
<div class="wmnds-grid wmnds-grid--align-stretch wmnds-grid--spacing-sm-2-xsm wmnds-grid--spacing-lg-4-xsm wmnds-m-t-md wmnds-m-b-md">
{# User research #}
<div class="wmnds-col-1 wmnds-col-sm-1-2 wmnds-col-lg-1-4 wmnds-p-b-xsm">
{{
{{
wmndsContentCard({
link: "/user-research/",
linkTitle: "User research",
contentHTML: "<div class=\"wmnds-p-sm\">
<h2>User research</h2>
<p>Start with user needs to build the right thing</p>
</div>"
<h2>User research</h2>
<p>Start with user needs to build the right thing</p>
</div>"
})
}}
</div>
Expand Down
40 changes: 39 additions & 1 deletion src/www/pages/patterns/banner/index.njk.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@

{# Travel mode page banner #}

## Travel Mode Page Banner
## Travel mode page banner

{# What #}

Expand Down Expand Up @@ -175,6 +175,44 @@

{% markdown %}

## Purple branded banner

<h3>What does it do?</h3>

- Helps user to identify the brand or a service provider

<h3>When to use it?</h3>

- Only on Swift product landing pages such as Swift Go, PAYG, Swift and tickets and TfWM corporate landing page

<h3>When not to use it?</h3>

- On informational content pages

<h3>How it works</h3>

- The banner container width will expand if users are viewing the page with a browser width higher than 1280px
- User can add/remove text and call to action button
- User can add a logo in the title

{% endmarkdown %}

{% from "wmnds/patterns/branded-banner/_branded-banner.njk" import wmndsBrandedBanner %}

{{
compExample([
wmndsBrandedBanner()
], {
componentPath: "wmnds/patterns/branded-banner/",
njk: true,
njkProps: wmndsBrandedBannerProps,
js: false,
iframe: true
})
}}

{% markdown %}

{# Homepage banner #}

## Homepage
Expand Down

0 comments on commit 5ce3a3b

Please sign in to comment.