-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from hmrc/PLATUI-924_ur_banner
PLATUI-924: Add new user research component
- Loading branch information
Showing
24 changed files
with
440 additions
and
5 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
Binary file modified
BIN
+16.7 KB
(370%)
...stop_data/bitmaps_reference/backstop_default_HMRC_Header_0_document_0_phone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+20.9 KB
(320%)
...top_data/bitmaps_reference/backstop_default_HMRC_Header_0_document_1_tablet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.5 KB
...aps_reference/backstop_default_HMRC_User_Research_Banner_0_document_0_phone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+15.8 KB
...ps_reference/backstop_default_HMRC_User_Research_Banner_0_document_1_tablet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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 @@ | ||
# HMRC User Research Banner |
58 changes: 58 additions & 0 deletions
58
src/components/user-research-banner/_user-research-banner.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,58 @@ | ||
@import "node_modules/govuk-frontend/govuk/helpers/typography"; | ||
|
||
@mixin hmrc-white-link() { | ||
color: govuk-colour("white"); | ||
|
||
&:link, | ||
&:hover, | ||
&:visited { | ||
color: govuk-colour("white"); | ||
} | ||
|
||
&:active, | ||
&:focus { | ||
color: govuk-colour("black"); | ||
} | ||
} | ||
|
||
.hmrc-user-research-banner { | ||
display: none; | ||
position: relative; | ||
color: govuk-colour("white"); | ||
background-color: $govuk-brand-colour; | ||
box-sizing: border-box; | ||
|
||
@include govuk-responsive-padding(6, "top"); | ||
@include govuk-responsive-padding(6, "bottom"); | ||
@include govuk-font($size: 19); | ||
|
||
&__container { | ||
position: relative; | ||
} | ||
|
||
&__title { | ||
@include govuk-responsive-margin(1, "bottom"); | ||
} | ||
|
||
&__link { | ||
@include hmrc-white-link(); | ||
} | ||
|
||
&--show { | ||
display: block; | ||
} | ||
|
||
&__close { | ||
@include hmrc-white-link(); | ||
@include govuk-responsive-margin(2, "top"); | ||
|
||
outline: 0; | ||
border: 0; | ||
background: none; | ||
text-decoration: underline; | ||
box-shadow: none; | ||
padding: 0; | ||
cursor: pointer; | ||
font-size: inherit; | ||
} | ||
} |
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,3 @@ | ||
{% macro hmrcUserResearchBanner(params) %} | ||
{%- include "./template.njk" -%} | ||
{% endmacro %} |
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,27 @@ | ||
<div class="hmrc-user-research-banner" data-module="hmrc-user-research-banner"> | ||
<div class="hmrc-user-research-banner__container govuk-width-container"> | ||
<div class="hmrc-user-research-banner__text"> | ||
<div class="hmrc-user-research-banner__title govuk-!-font-weight-bold"> | ||
{% if params.language == 'cy' %} | ||
Helpwch i wella gwasanaethau CThEM | ||
{% else %} | ||
Help improve HMRC services | ||
{% endif %} | ||
</div> | ||
<a class="govuk-link hmrc-user-research-banner__link" href="{{ params.url }}" target="_blank"> | ||
{% if params.language == 'cy' %} | ||
Cofrestrwch i gymryd rhan mewn ymchwil defnyddwyr (yn agor tab newydd) | ||
{% else %} | ||
Sign up to take part in user research (opens in new tab) | ||
{% endif %} | ||
</a> | ||
</div> | ||
<button class="govuk-link hmrc-user-research-banner__close"> | ||
{% if params.language == 'cy' %} | ||
Dim diolch | ||
{% else %} | ||
No thanks | ||
{% endif %} | ||
</button> | ||
</div> | ||
</div> |
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,38 @@ | ||
/* eslint-env jest */ | ||
|
||
const axe = require('../../../lib/axe-helper'); | ||
|
||
const { render, getExamples } = require('../../../lib/jest-helpers'); | ||
|
||
const examples = getExamples('user-research-banner'); | ||
|
||
describe('User Research Banner', () => { | ||
describe('by default', () => { | ||
it('passes accessibility tests', async () => { | ||
const $ = render('user-research-banner', examples.default); | ||
|
||
const results = await axe($.html(), { | ||
rules: { | ||
region: { enabled: false }, | ||
}, | ||
}); | ||
|
||
expect(results).toHaveNoViolations(); | ||
}); | ||
|
||
it('should render the correct URL', () => { | ||
const $ = render('user-research-banner', examples.default); | ||
expect($('.hmrc-user-research-banner__link').attr('href')).toEqual('https://www.example.com/user-research'); | ||
}); | ||
|
||
it('should have English text by default', () => { | ||
const $ = render('user-research-banner', examples.default); | ||
expect($('.hmrc-user-research-banner__title').text().trim()).toEqual('Help improve HMRC services'); | ||
}); | ||
|
||
it('should have Welsh text when specified', () => { | ||
const $ = render('user-research-banner', examples.welsh); | ||
expect($('.hmrc-user-research-banner__title').text().trim()).toEqual('Helpwch i wella gwasanaethau CThEM'); | ||
}); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
src/components/user-research-banner/user-research-banner.js
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,28 @@ | ||
import { getCookie, setCookie } from '../../utils/cookies'; | ||
|
||
function UserResearchBanner($module) { | ||
this.$module = $module; | ||
this.$closeLink = this.$module.querySelector('.hmrc-user-research-banner__close'); | ||
this.cookieName = 'mdtpurr'; | ||
this.cookieExpiryDays = 28; | ||
} | ||
|
||
UserResearchBanner.prototype.init = function init() { | ||
const cookieData = getCookie(this.cookieName); | ||
|
||
if (cookieData == null) { | ||
this.$module.classList.add('hmrc-user-research-banner--show'); | ||
this.$closeLink.addEventListener('click', this.eventHandlers.noThanksClick.bind(this)); | ||
} | ||
}; | ||
|
||
UserResearchBanner.prototype.eventHandlers = { | ||
noThanksClick(event) { | ||
event.preventDefault(); | ||
|
||
setCookie(this.cookieName, 'suppress_for_all_services', { days: this.cookieExpiryDays }); | ||
this.$module.classList.remove('hmrc-user-research-banner--show'); | ||
}, | ||
}; | ||
|
||
export default UserResearchBanner; |
Oops, something went wrong.