From bbdb77004a3b2d16113f141a67c234a06032403e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 15 Nov 2023 16:52:11 +0000 Subject: [PATCH 1/3] Bump iframe-resizer from 4.3.7 to 4.3.9 Bumps [iframe-resizer](https://github.com/davidjbradshaw/iframe-resizer) from 4.3.7 to 4.3.9. - [Release notes](https://github.com/davidjbradshaw/iframe-resizer/releases) - [Changelog](https://github.com/davidjbradshaw/iframe-resizer/blob/master/CHANGELOG.md) - [Commits](https://github.com/davidjbradshaw/iframe-resizer/compare/v4.3.7...v4.3.9) --- updated-dependencies: - dependency-name: iframe-resizer dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index b606fc7075..2ae4702db8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "accessible-autocomplete": "^2.0.4", "clipboard": "^2.0.11", "govuk-frontend": "^4.7.0", - "iframe-resizer": "^4.3.7", + "iframe-resizer": "^4.3.9", "lunr": "^2.3.9" }, "devDependencies": { @@ -9098,9 +9098,9 @@ ] }, "node_modules/iframe-resizer": { - "version": "4.3.7", - "resolved": "https://registry.npmjs.org/iframe-resizer/-/iframe-resizer-4.3.7.tgz", - "integrity": "sha512-a3EGVScU9NtUpj6lWvGhVw3EfOw5AopRs5xGsQU385kWdgQt++OsD6PCnTV+8YkgBu/g28rLIh0EztFg9UQr1Q==", + "version": "4.3.9", + "resolved": "https://registry.npmjs.org/iframe-resizer/-/iframe-resizer-4.3.9.tgz", + "integrity": "sha512-MCt+V/THB4a9OcAdrWo5NsI2CRpeMM4ijhTfiLtsdgDJXWYXf62Ve8yO8rKGmYNs991zty/EolYOxActlkfU+A==", "engines": { "node": ">=0.8.0" }, diff --git a/package.json b/package.json index a683d030d3..bfee2a08be 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "accessible-autocomplete": "^2.0.4", "clipboard": "^2.0.11", "govuk-frontend": "^4.7.0", - "iframe-resizer": "^4.3.7", + "iframe-resizer": "^4.3.9", "lunr": "^2.3.9" }, "devDependencies": { From 185f8cd2f82f4d2738bd64c118ffe8fcdd01dcc3 Mon Sep 17 00:00:00 2001 From: Colin Rotherham Date: Thu, 16 Nov 2023 16:12:39 +0000 Subject: [PATCH 2/3] Consolidate GOV.UK Frontend into application scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cherry picked from https://github.com/alphagov/govuk-design-system/pull/2958/commits/ceef53af4c755a4e28d64b9c204c78aac15eedf1 but without the `type="module”` attribute --- lib/metalsmith.js | 9 ++------- src/javascripts/application-example.mjs | 13 +++++++++++++ src/javascripts/application.mjs | 5 +++++ .../{example.mjs => components/example-page.mjs} | 4 +++- src/javascripts/govuk-frontend.mjs | 12 ------------ src/styles/page-template/block-areas/index.njk | 2 +- src/styles/page-template/custom/index.njk | 3 +-- src/styles/page-template/default/index.njk | 2 +- views/layouts/_generic.njk | 1 - views/layouts/layout-example-full-page-govuk.njk | 3 +-- views/layouts/layout-example-full-page.njk | 3 +-- views/layouts/layout-example.njk | 3 +-- 12 files changed, 29 insertions(+), 31 deletions(-) create mode 100644 src/javascripts/application-example.mjs rename src/javascripts/{example.mjs => components/example-page.mjs} (93%) delete mode 100644 src/javascripts/govuk-frontend.mjs diff --git a/lib/metalsmith.js b/lib/metalsmith.js index 1425d479fc..2e44687c63 100644 --- a/lib/metalsmith.js +++ b/lib/metalsmith.js @@ -147,14 +147,9 @@ module.exports = metalsmith done() }) - // build the entrypoint for application specific JavaScript + // build the entrypoints for application specific JavaScript .use(rollup('javascripts/application.mjs')) - - // build GOV.UK Frontend JavaScript - .use(rollup('javascripts/govuk-frontend.mjs')) - - // build the entrypoint for example specific JavaScript - .use(rollup('javascripts/example.mjs')) + .use(rollup('javascripts/application-example.mjs')) // add hash to files in production .use((files, metalsmith, done) => { diff --git a/src/javascripts/application-example.mjs b/src/javascripts/application-example.mjs new file mode 100644 index 0000000000..abcb0bdd98 --- /dev/null +++ b/src/javascripts/application-example.mjs @@ -0,0 +1,13 @@ +import { initAll } from 'govuk-frontend' + +import ExamplePage from './components/example-page.mjs' + +// Initialise GOV.UK Frontend +initAll({ + // Auto focusing the error summary and notification banner is not useful + // when used in examples, and causes the viewport to scroll + errorSummary: { disableAutoFocus: true }, + notificationBanner: { disableAutoFocus: true } +}) + +new ExamplePage(document).init() diff --git a/src/javascripts/application.mjs b/src/javascripts/application.mjs index 5351f36846..90ce28cd70 100644 --- a/src/javascripts/application.mjs +++ b/src/javascripts/application.mjs @@ -1,3 +1,5 @@ +import { initAll } from 'govuk-frontend' + import Analytics from './components/analytics.mjs' import BackToTop from './components/back-to-top.mjs' import CookieBanner from './components/cookie-banner.mjs' @@ -14,6 +16,9 @@ import OptionsTable from './components/options-table.mjs' import Search from './components/search.mjs' import AppTabs from './components/tabs.mjs' +// Initialise GOV.UK Frontend +initAll() + // Initialise cookie banner var $cookieBanner = document.querySelector( '[data-module="govuk-cookie-banner"]' diff --git a/src/javascripts/example.mjs b/src/javascripts/components/example-page.mjs similarity index 93% rename from src/javascripts/example.mjs rename to src/javascripts/components/example-page.mjs index 01eb479c98..d2c29e7925 100644 --- a/src/javascripts/example.mjs +++ b/src/javascripts/components/example-page.mjs @@ -1,6 +1,7 @@ function ExamplePage($module) { this.$module = $module } + ExamplePage.prototype.init = function () { var $module = this.$module if (!$module) { @@ -9,6 +10,7 @@ ExamplePage.prototype.init = function () { var $form = $module.querySelector('form[action="/form-handler"]') this.preventFormSubmission($form) } + ExamplePage.prototype.preventFormSubmission = function ($form) { // we should only have one form per example if (!$form) { @@ -19,4 +21,4 @@ ExamplePage.prototype.preventFormSubmission = function ($form) { }) } -new ExamplePage(document).init() +export default ExamplePage diff --git a/src/javascripts/govuk-frontend.mjs b/src/javascripts/govuk-frontend.mjs deleted file mode 100644 index 82ae24143c..0000000000 --- a/src/javascripts/govuk-frontend.mjs +++ /dev/null @@ -1,12 +0,0 @@ -import { initAll } from 'govuk-frontend' - -initAll({ - // auto focusing the error summary and notification banner is not useful - // when used in examples, and causes the viewport to scroll - errorSummary: { - disableAutoFocus: true - }, - notificationBanner: { - disableAutoFocus: true - } -}) diff --git a/src/styles/page-template/block-areas/index.njk b/src/styles/page-template/block-areas/index.njk index b8bdb37838..c81bcf4303 100644 --- a/src/styles/page-template/block-areas/index.njk +++ b/src/styles/page-template/block-areas/index.njk @@ -83,7 +83,7 @@ stylesheets: block: bodyEnd {{ super() }} {# Since we’re not extending the Design System layout we need to add this manually #} - + {%- endblock %} diff --git a/src/styles/page-template/custom/index.njk b/src/styles/page-template/custom/index.njk index 8c243c6adb..3a1a056828 100644 --- a/src/styles/page-template/custom/index.njk +++ b/src/styles/page-template/custom/index.njk @@ -151,7 +151,6 @@ ignoreInSitemap: true {% endblock %} {% block bodyEnd %} - - + {% endblock %} diff --git a/src/styles/page-template/default/index.njk b/src/styles/page-template/default/index.njk index 80a53fcb55..4c417b7ccb 100644 --- a/src/styles/page-template/default/index.njk +++ b/src/styles/page-template/default/index.njk @@ -17,6 +17,6 @@ layout: false {% endblock %} {% block bodyEnd %} - + {% endblock %} diff --git a/views/layouts/_generic.njk b/views/layouts/_generic.njk index 697408f5ac..d3965adccf 100644 --- a/views/layouts/_generic.njk +++ b/views/layouts/_generic.njk @@ -37,6 +37,5 @@ {% block footer %}{% endblock %} {% block bodyEnd %} - {% endblock %} diff --git a/views/layouts/layout-example-full-page-govuk.njk b/views/layouts/layout-example-full-page-govuk.njk index f7cfe9b2ea..181e3c1c48 100644 --- a/views/layouts/layout-example-full-page-govuk.njk +++ b/views/layouts/layout-example-full-page-govuk.njk @@ -22,7 +22,6 @@ {{ contents | safe }} {% endblock %} {% block bodyEnd %} - - + {% endblock %} diff --git a/views/layouts/layout-example-full-page.njk b/views/layouts/layout-example-full-page.njk index c039ebe140..ebba5a0483 100644 --- a/views/layouts/layout-example-full-page.njk +++ b/views/layouts/layout-example-full-page.njk @@ -24,7 +24,6 @@ {{ contents | safe }} {% endblock %} {% block bodyEnd %} - - + {% endblock %} diff --git a/views/layouts/layout-example.njk b/views/layouts/layout-example.njk index 749079f825..84a87d71ba 100644 --- a/views/layouts/layout-example.njk +++ b/views/layouts/layout-example.njk @@ -32,8 +32,7 @@ {% endblock %} {% block bodyEnd %} - - + {% endblock %} From 92eb2127408d67cc4a2fc4827d1582328385f357 Mon Sep 17 00:00:00 2001 From: Colin Rotherham Date: Thu, 16 Nov 2023 16:11:52 +0000 Subject: [PATCH 3/3] Import `iframeResizer.contentWindow.js` from example bundle The npm package `iframe-resizer` has deleted the pre-minified `iframeResizer.contentWindow.min.js` file from their published files See: https://github.com/davidjbradshaw/iframe-resizer/issues/1195#issuecomment-1814760496 --- lib/metalsmith.js | 5 ----- src/javascripts/components/example-page.mjs | 2 ++ src/styles/page-template/block-areas/index.njk | 1 - src/styles/page-template/custom/index.njk | 1 - src/styles/page-template/default/index.njk | 1 - views/layouts/layout-example-full-page-govuk.njk | 1 - views/layouts/layout-example-full-page.njk | 1 - views/layouts/layout-example.njk | 1 - 8 files changed, 2 insertions(+), 11 deletions(-) diff --git a/lib/metalsmith.js b/lib/metalsmith.js index 2e44687c63..936d1761e7 100644 --- a/lib/metalsmith.js +++ b/lib/metalsmith.js @@ -136,11 +136,6 @@ module.exports = metalsmith copyAssets('{fonts,images}/*', { cwd: join(dirname(require.resolve('govuk-frontend')), 'assets'), dest: 'assets' - }), - - copyAssets('**/iframeResizer.contentWindow.@(map|min.js)', { - cwd: join(dirname(require.resolve('iframe-resizer')), 'js'), - dest: 'javascripts/vendor' }) ]) diff --git a/src/javascripts/components/example-page.mjs b/src/javascripts/components/example-page.mjs index d2c29e7925..58410519ca 100644 --- a/src/javascripts/components/example-page.mjs +++ b/src/javascripts/components/example-page.mjs @@ -1,3 +1,5 @@ +import 'iframe-resizer/js/iframeResizer.contentWindow.js' + function ExamplePage($module) { this.$module = $module } diff --git a/src/styles/page-template/block-areas/index.njk b/src/styles/page-template/block-areas/index.njk index c81bcf4303..5499fd6298 100644 --- a/src/styles/page-template/block-areas/index.njk +++ b/src/styles/page-template/block-areas/index.njk @@ -84,6 +84,5 @@ stylesheets: {{ super() }} {# Since we’re not extending the Design System layout we need to add this manually #} - {%- endblock %} diff --git a/src/styles/page-template/custom/index.njk b/src/styles/page-template/custom/index.njk index 3a1a056828..f37c998f28 100644 --- a/src/styles/page-template/custom/index.njk +++ b/src/styles/page-template/custom/index.njk @@ -152,5 +152,4 @@ ignoreInSitemap: true {% block bodyEnd %} - {% endblock %} diff --git a/src/styles/page-template/default/index.njk b/src/styles/page-template/default/index.njk index 4c417b7ccb..8e7ea45b08 100644 --- a/src/styles/page-template/default/index.njk +++ b/src/styles/page-template/default/index.njk @@ -18,5 +18,4 @@ layout: false {% block bodyEnd %} - {% endblock %} diff --git a/views/layouts/layout-example-full-page-govuk.njk b/views/layouts/layout-example-full-page-govuk.njk index 181e3c1c48..e5121f7127 100644 --- a/views/layouts/layout-example-full-page-govuk.njk +++ b/views/layouts/layout-example-full-page-govuk.njk @@ -23,5 +23,4 @@ {% endblock %} {% block bodyEnd %} - {% endblock %} diff --git a/views/layouts/layout-example-full-page.njk b/views/layouts/layout-example-full-page.njk index ebba5a0483..d0bbf432d0 100644 --- a/views/layouts/layout-example-full-page.njk +++ b/views/layouts/layout-example-full-page.njk @@ -25,5 +25,4 @@ {% endblock %} {% block bodyEnd %} - {% endblock %} diff --git a/views/layouts/layout-example.njk b/views/layouts/layout-example.njk index 84a87d71ba..8294b5a8c6 100644 --- a/views/layouts/layout-example.njk +++ b/views/layouts/layout-example.njk @@ -33,7 +33,6 @@ {% block bodyEnd %} - {% endblock %} {# Example pages shouldn't have a footer, so blank the one provided by the template #}