From 52bee9361493a860f19b95d174a7d9e663c9be62 Mon Sep 17 00:00:00 2001 From: Patrick Cartlidge Date: Thu, 16 Nov 2023 13:38:31 +0000 Subject: [PATCH 1/4] Move Javascript modules to es6-components To prevent browsers evaluating JS that isn't supported, components that contain code from govuk-frontend have been moved to a separate file `es6-components.js` which is included in `application.html.erb` as a script tag with `type="module"`. --- app/assets/config/manifest.js | 1 + app/assets/javascripts/application.js | 3 --- app/assets/javascripts/es6-components.js | 12 ++++++++++++ app/views/layouts/application.html.erb | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 app/assets/javascripts/es6-components.js diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index 1b6313e59..7cb2ec743 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -1,4 +1,5 @@ //= link_tree ../images //= link application.js +//= link es6-components.js //= link webchat.js //= link_tree ../builds diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index fdd109291..3110fcc69 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -1,13 +1,10 @@ //= require govuk_publishing_components/lib -//= require govuk_publishing_components/components/accordion //= require govuk_publishing_components/components/details -//= require govuk_publishing_components/components/error-summary //= require govuk_publishing_components/components/govspeak //= require govuk_publishing_components/components/image-card //= require govuk_publishing_components/components/intervention //= require govuk_publishing_components/components/metadata //= require govuk_publishing_components/components/print-link -//= require govuk_publishing_components/components/radio //= require govuk_publishing_components/components/single-page-notification-button //= require govuk_publishing_components/components/step-by-step-nav diff --git a/app/assets/javascripts/es6-components.js b/app/assets/javascripts/es6-components.js new file mode 100644 index 000000000..d5bc4c711 --- /dev/null +++ b/app/assets/javascripts/es6-components.js @@ -0,0 +1,12 @@ +// These modules from govuk_publishing_components +// depend on govuk-frontend modules. govuk-frontend +// now targets browsers that support `type="module"`. +// +// To gracefully prevent execution of these scripts +// on browsers that don't support ES6, this script +// should be included in a `type="module"` script tag +// which will ensure they are never loaded. + +//= require govuk_publishing_components/components/accordion +//= require govuk_publishing_components/components/error-summary +//= require govuk_publishing_components/components/radio diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index cb7dc363a..b8a944baf 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -49,6 +49,7 @@ <%= stylesheet_link_tag "application", :media => "all", integrity: false %> <%= javascript_include_tag "application", integrity: false %> + <%= javascript_include_tag 'es6-components', type: "module" %> <%= csrf_meta_tags %> <%= render 'govuk_publishing_components/components/meta_tags', content_item: @content_item.content_item %> From ecd8c9d83d0dba18259255dbab3856d05b219081 Mon Sep 17 00:00:00 2001 From: Jon Kirwan <87758239+jon-kirwan@users.noreply.github.com> Date: Fri, 15 Mar 2024 12:37:45 +0000 Subject: [PATCH 2/4] Remove deprecated SCSS variables - $govuk-new-link-styles is now set to true by default - The other SCSS variables are deprecated from v5 of govuk-frontend --- app/assets/stylesheets/application.scss | 4 ---- .../stylesheets/components/_contents-list-with-body.scss | 2 +- app/assets/stylesheets/helpers/_parts.scss | 2 +- app/assets/stylesheets/views/_manual.scss | 2 +- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 5f3f96f13..1b1c78da7 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -1,8 +1,4 @@ // The main application stylesheet -$govuk-compatibility-govuktemplate: false; -$govuk-typography-use-rem: false; -$govuk-use-legacy-palette: false; -$govuk-new-link-styles: true; // This flag stops the font from being included in this application's // stylesheet - the font is being served by Static across all of GOV.UK, so is diff --git a/app/assets/stylesheets/components/_contents-list-with-body.scss b/app/assets/stylesheets/components/_contents-list-with-body.scss index e7dc44966..f38e8bf5f 100644 --- a/app/assets/stylesheets/components/_contents-list-with-body.scss +++ b/app/assets/stylesheets/components/_contents-list-with-body.scss @@ -23,7 +23,7 @@ } .app-c-contents-list-with-body__link-wrapper.sticky-element--stuck-to-window { - background-color: govuk-colour("light-grey", $legacy: "grey-3"); + background-color: govuk-colour("light-grey"); bottom: -1px; // 'Fix' for anomalous 1px margin which sporadically appears below this element. left: 0; margin: 0; diff --git a/app/assets/stylesheets/helpers/_parts.scss b/app/assets/stylesheets/helpers/_parts.scss index 4837e7b4a..97d97960c 100644 --- a/app/assets/stylesheets/helpers/_parts.scss +++ b/app/assets/stylesheets/helpers/_parts.scss @@ -9,7 +9,7 @@ margin-bottom: 0; } - border-bottom: 1px solid govuk-colour("mid-grey", $legacy: "grey-2"); + border-bottom: 1px solid govuk-colour("mid-grey"); } .part-navigation { diff --git a/app/assets/stylesheets/views/_manual.scss b/app/assets/stylesheets/views/_manual.scss index d387a4297..d3a94a6f0 100644 --- a/app/assets/stylesheets/views/_manual.scss +++ b/app/assets/stylesheets/views/_manual.scss @@ -61,7 +61,7 @@ list-style: none; &:hover { - background-color: govuk-colour("light-grey", $legacy: "grey-4"); + background-color: govuk-colour("light-grey"); } &:last-child { From dc5954da707de04aa658bcb18dd9c50286daf7ff Mon Sep 17 00:00:00 2001 From: Jon Kirwan <87758239+jon-kirwan@users.noreply.github.com> Date: Thu, 21 Mar 2024 15:33:48 +0000 Subject: [PATCH 3/4] Update service_manual_phase_label_test.rb --- test/integration/service_manual_phase_label_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/service_manual_phase_label_test.rb b/test/integration/service_manual_phase_label_test.rb index d321b3f03..728e36666 100644 --- a/test/integration/service_manual_phase_label_test.rb +++ b/test/integration/service_manual_phase_label_test.rb @@ -29,7 +29,7 @@ class ServiceManualPhaseLabelTest < ActionDispatch::IntegrationTest stub_content_store_has_item(guide["base_path"], guide) visit guide["base_path"] - assert_text("ALPHA") + assert_text("Alpha") end test "No phase label is displayed for a guide without a phase field" do From a64367e83815f77bd2430ee9c5a69b1fd43874a3 Mon Sep 17 00:00:00 2001 From: Jessica Jones Date: Mon, 15 Jul 2024 10:58:08 +0100 Subject: [PATCH 4/4] Bump to govuk-publishing-components 40.0 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index d128655f1..87d0673cf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -162,7 +162,7 @@ GEM govuk_personalisation (0.16.0) plek (>= 1.9.0) rails (>= 6, < 8) - govuk_publishing_components (39.2.5) + govuk_publishing_components (40.0.0) govuk_app_config govuk_personalisation (>= 0.7.0) kramdown