Skip to content

Commit 64e7cb3

Browse files
committed
PP-12322 - Upgrade to govuk-frontend V5
Co-authored by: @marcotranchino Make changes as per the V5 release notes: https://github.com/alphagov/govuk-frontend/releases/tag/v5.0.0 Included doing the following: - Update JS to work with ES6 format used by V5 Update the Percy config to ignore checking anything under: - Assets/Govuk/Components/**
1 parent 8309c61 commit 64e7cb3

14 files changed

Lines changed: 64 additions & 70 deletions

.percy.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"exclude": [
1919
"/contact/index.html",
2020
"/features/index.html",
21-
"/payment-links/index.html"
21+
"/payment-links/index.html",
22+
"/Assets/Govuk/Components/**"
2223
]
2324
},
2425
"upload": {

.secrets.baseline

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
{
7676
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
7777
},
78+
{
79+
"path": "detect_secrets.filters.common.is_baseline_file",
80+
"filename": ".secrets.baseline"
81+
},
7882
{
7983
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
8084
"min_level": 2
@@ -114,9 +118,9 @@
114118
"filename": "source/layouts/layout.html.erb",
115119
"hashed_secret": "e0cadc1a99504f3acead6e976b5773d8f34e1b94",
116120
"is_verified": false,
117-
"line_number": 30
121+
"line_number": 27
118122
}
119123
]
120124
},
121-
"generated_at": "2024-07-22T13:19:52Z"
125+
"generated_at": "2025-04-07T21:09:15Z"
122126
}

config.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def tel_to(text, className)
6262
config.expose_middleman_helpers = true
6363
end
6464

65-
sprockets.append_path File.join(root, "node_modules/govuk-frontend/")
65+
sprockets.append_path File.join(root, "node_modules/govuk-frontend/dist/")
6666
sprockets.append_path File.join(root, "node_modules/gaap-analytics/build")
6767

6868
redirect "security.txt.html", to: "https://vdp.cabinetoffice.gov.uk/.well-known/security.txt"

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
"homepage": "https://www.payments.service.gov.uk",
2020
"dependencies": {
2121
"gaap-analytics": "^3.1.0",
22-
"govuk-frontend": "^4.9.0"
22+
"govuk-frontend": "^5.9.0"
2323
},
2424
"devDependencies": {
25-
"@percy/cli": "^1.26.0",
25+
"@percy/cli": "^1.30.9",
2626
"@prettier/plugin-ruby": "^1.0.0",
2727
"jest": "^29.6.0",
2828
"jest-environment-jsdom": "^29.6.0",

source/javascripts/analytics/analytics.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
window.GovUkPay = window.GovUkPay || {}
22
window.GovUkPay.Analytics = (function () {
3-
LoadGoogleAnalytics = function () {
3+
const LoadGoogleAnalytics = function () {
44
var gtagScript = document.createElement('script')
55
gtagScript.async = true
66
gtagScript.setAttribute('src', 'https://www.googletagmanager.com/gtag/js?id=G-XE9K05CFFE')

source/javascripts/analytics/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
window.GovUkPay = window.GovUkPay || {}
44
window.GovUkPay.InitAnalytics = (function () {
5-
InitialiseAnalytics = function () {
5+
const InitialiseAnalytics = function () {
66
window.GovUkPay.Analytics.LoadGoogleAnalytics()
77
}
88

source/javascripts/analytics/init.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ beforeAll(() => {
1414
describe('InitialiseAnalytics component', () => {
1515
describe('If initAnalytics has not yet been called', () => {
1616
beforeEach(() => {
17-
InitialiseAnalytics()
17+
window.GovUkPay.InitAnalytics.InitialiseAnalytics()
1818
})
1919

2020
it('the Google Analytics libraries will have been loaded', () => {

source/javascripts/application.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//= require govuk/all.js
1+
//= require govuk/all.bundle.js
22
//= require gaap-analytics.min.js
33
//= require cookies.js
44
//= require ./cookie-banner/cookie-banner.js

source/javascripts/cookie-banner/cookie-banner.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
window.GovUkPay = window.GovUkPay || {}
55

66
window.GovUkPay.CookieBanner = (function () {
7-
$module = {}
8-
COOKIE_NAME = 'govuk_pay_cookie_policy'
7+
let $module = {}
8+
const COOKIE_NAME = 'govuk_pay_cookie_policy'
99

10-
setModule = function ($module) {
10+
const setModule = function ($module) {
1111
$module = $module
1212
}
1313

14-
checkForBannerAndInit = function () {
14+
const checkForBannerAndInit = function () {
1515
var $cookieBanner = document.querySelector('[data-module="pay-cookie-banner"]')
1616

1717
if ($cookieBanner) {
@@ -20,37 +20,37 @@ window.GovUkPay.CookieBanner = (function () {
2020
}
2121
}
2222

23-
init = function ($module) {
23+
const init = function ($module) {
2424
$module.cookieBanner = document.querySelector('.pay-cookie-banner')
2525
$module.cookieBannerConfirmationMessage = document.querySelector('.pay-cookie-banner__confirmation')
2626

2727
setupCookieMessage()
2828
}
2929

30-
setupCookieMessage = function () {
31-
this.$hideLink = $module.cookieBannerConfirmationMessage.querySelector('button[data-hide-cookie-banner]')
32-
if (this.$hideLink) {
33-
this.$hideLink.addEventListener('click', hideCookieMessage)
30+
const setupCookieMessage = function () {
31+
const $hideLink = $module.cookieBannerConfirmationMessage.querySelector('button[data-hide-cookie-banner]')
32+
if ($hideLink) {
33+
$hideLink.addEventListener('click', hideCookieMessage)
3434
}
3535

36-
this.$acceptCookiesLink = $module.cookieBanner.querySelector('button[data-accept-cookies=true]')
37-
if (this.$acceptCookiesLink) {
38-
this.$acceptCookiesLink.addEventListener('click', function () {
36+
const $acceptCookiesLink = $module.cookieBanner.querySelector('button[data-accept-cookies=true]')
37+
if ($acceptCookiesLink) {
38+
$acceptCookiesLink.addEventListener('click', function () {
3939
setCookieConsent(true)
4040
})
4141
}
4242

43-
this.$rejectCookiesLink = $module.cookieBanner.querySelector('button[data-accept-cookies=false]')
44-
if (this.$rejectCookiesLink) {
45-
this.$rejectCookiesLink.addEventListener('click', function () {
43+
const $rejectCookiesLink = $module.cookieBanner.querySelector('button[data-accept-cookies=false]')
44+
if ($rejectCookiesLink) {
45+
$rejectCookiesLink.addEventListener('click', function () {
4646
setCookieConsent(false)
4747
})
4848
}
4949

50-
this.showCookieMessage()
50+
showCookieMessage()
5151
}
5252

53-
showCookieMessage = function () {
53+
const showCookieMessage = function () {
5454
// Show the cookie banner if policy cookie not set
5555
var hasCookiesPolicy = window.GovUkPay.Cookie.getCookie(COOKIE_NAME)
5656

@@ -67,7 +67,7 @@ window.GovUkPay.CookieBanner = (function () {
6767
}
6868
}
6969

70-
hideCookieMessage = function (event) {
70+
const hideCookieMessage = function (event) {
7171
if ($module.cookieBannerConfirmationMessage) {
7272
$module.cookieBannerConfirmationMessage.style.display = 'none'
7373
}
@@ -77,7 +77,7 @@ window.GovUkPay.CookieBanner = (function () {
7777
}
7878
}
7979

80-
setCookieConsent = function (analyticsConsent) {
80+
const setCookieConsent = function (analyticsConsent) {
8181
window.GovUkPay.Cookie.setConsentCookie({ analytics: analyticsConsent })
8282

8383
showConfirmationMessage(analyticsConsent)
@@ -87,7 +87,7 @@ window.GovUkPay.CookieBanner = (function () {
8787
}
8888
}
8989

90-
showConfirmationMessage = function (analyticsConsent) {
90+
const showConfirmationMessage = function (analyticsConsent) {
9191
var messagePrefix = analyticsConsent ? 'You’ve accepted analytics cookies. ' : 'You told us not to use analytics cookies. '
9292

9393
var $cookieBannerMainContent = document.querySelector('.pay-cookie-banner__wrapper')

0 commit comments

Comments
 (0)