Skip to content

Commit 64d0492

Browse files
authored
Merge pull request #363 from alphagov/use-govuk-frontend-v5
Upgrade to use govuk-frontend v5
2 parents bd11dd8 + 0882b97 commit 64d0492

File tree

19 files changed

+78
-51
lines changed

19 files changed

+78
-51
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Changelog
22

33
## Unreleased
4+
- Upgrade to govuk-frontend v5.6.0 and introduce new Javascript entry point
5+
BREAKING: drop support for IE8
6+
7+
You need to
8+
- create a `govuk_frontend.js` file your project’s `source/assets/javascripts` directory
9+
- add `//= require govuk_frontend_all` into it
410

511
- BREAKING: drop support for end-of-life Ruby versions 2.7 and 3.0. The minimum Ruby version is now 3.1.
612
- Update gem dependencies.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//= require govuk_frontend_all

govuk_tech_docs.gemspec

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require "govuk_tech_docs/version"
77
`npm install`
88
abort "npm install failed" unless $CHILD_STATUS.success?
99

10-
unless File.exist?("node_modules/govuk-frontend/govuk/all.scss")
10+
unless File.exist?("node_modules/govuk-frontend/dist/govuk/all.scss")
1111
abort "govuk-frontend npm package not installed"
1212
end
1313

@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
2525
files_in_git = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
2626

2727
# Include assets from GOV.UK Frontend library in the distributed gem
28-
govuk_frontend_assets = Dir["node_modules/govuk-frontend/**/*.{scss,js,woff,woff2,png,svg,ico}"]
28+
govuk_frontend_assets = Dir["node_modules/govuk-frontend/**/*.{scss,js,mjs,woff,woff2,png,svg,ico}"]
2929

3030
spec.files = files_in_git + govuk_frontend_assets
3131

@@ -52,6 +52,8 @@ Gem::Specification.new do |spec|
5252
spec.add_dependency "nokogiri"
5353
spec.add_dependency "openapi3_parser", "~> 0.9.0"
5454
spec.add_dependency "redcarpet", "~> 3.6"
55+
spec.add_dependency "terser", "~> 1.2.3"
56+
spec.add_dependency "sassc-embedded", "~> 1.78.0"
5557

5658
spec.add_development_dependency "byebug"
5759
spec.add_development_dependency "capybara", "~> 3.32"

lib/assets/javascripts/_modules/table-of-contents.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
this.isMonitoring = false
1111
}
1212
StickyOverlapMonitors.prototype.run = function () {
13-
var stickyIsVisible = this.$sticky.is(':visible')
13+
var stickyIsVisible = this.$sticky.length > 0 && this.$sticky.is(':visible')
1414
if (stickyIsVisible && !this.isMonitoring) {
1515
document.addEventListener('focus', this.onFocus, true)
1616
this.isMonitoring = true
@@ -26,11 +26,13 @@
2626

2727
if (!applicable) { return }
2828

29-
var stickyEdge = this.$sticky.get(0).getBoundingClientRect().bottom + this.offset
30-
var diff = focused.getBoundingClientRect().top - stickyEdge
29+
if (this.$sticky && this.$sticky.is(':visible') && this.$sticky.get(0)) {
30+
var stickyEdge = this.$sticky.get(0).getBoundingClientRect().bottom + this.offset
31+
var diff = focused.getBoundingClientRect().top - stickyEdge
3132

32-
if (diff < 0) {
33-
$(window).scrollTop($(window).scrollTop() + diff)
33+
if (diff < 0) {
34+
$(window).scrollTop($(window).scrollTop() + diff)
35+
}
3436
}
3537
}
3638

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//= require govuk/all.bundle.js
2+
const { initAll } = window.GOVUKFrontend
3+
initAll()

lib/assets/javascripts/govuk_tech_docs.js

-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
//= require _vendor/lodash
55
//= require _analytics
66
//= require _start-modules
7-
//= require govuk/all.js
87

98
$(function () {
109
$('.fixedsticky').fixedsticky()
11-
GOVUKFrontend.initAll()
1210
})

lib/assets/stylesheets/_govuk_tech_docs.scss

+4-10
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ $govuk-assets-path: "/assets/govuk/assets/" !default;
1111
$govuk-new-link-styles: true;
1212
@import "govuk/base";
1313

14-
@import "govuk/core/all";
15-
@import "govuk/objects/all";
14+
@import "govuk/core/index";
15+
@import "govuk/objects/index";
1616

1717
@import "govuk/components/footer/index";
1818
@import "govuk/components/header/index";
@@ -22,14 +22,8 @@ $govuk-new-link-styles: true;
2222
@import "govuk/components/skip-link/index";
2323
@import "govuk/components/warning-text/index";
2424

25-
@import "govuk/utilities/all";
26-
@import "govuk/overrides/all";
25+
@import "govuk/utilities/index";
26+
@import "govuk/overrides/index";
2727

2828
@import "core";
2929
@import "vendor/fixedsticky";
30-
31-
// manual Tudor Crown spacing adjustment from govuk-frontend 4.8
32-
.govuk-header__logotype-crown[width="32"] {
33-
top: -3px;
34-
margin-right: 2px;
35-
}

lib/assets/stylesheets/modules/_search.scss

-4
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ $input-size: 40px;
4545
outline: $govuk-focus-width solid $govuk-focus-colour;
4646
outline-offset: 0;
4747
box-shadow: inset 0 0 0 $govuk-border-width-form-element * 2 govuk-colour("black");
48-
49-
@include govuk-if-ie8 {
50-
border-width: $govuk-border-width-form-element * 2;
51-
}
5248
}
5349
}
5450

lib/govuk_tech_docs.rb

+19-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
require "nokogiri"
1111
require "chronic"
1212
require "active_support/all"
13+
require "terser"
14+
require "sassc-embedded"
1315

1416
require "govuk_tech_docs/redirects"
1517
require "govuk_tech_docs/table_of_contents/helpers"
@@ -23,6 +25,18 @@
2325
require "govuk_tech_docs/warning_text_extension"
2426
require "govuk_tech_docs/api_reference/api_reference_extension"
2527

28+
module SassWarningSupressor
29+
def warn(message)
30+
if message.to_s.match?(/Sass|dart-sass/i)
31+
# suppress dart sass warnings
32+
else
33+
super
34+
end
35+
end
36+
end
37+
38+
Warning.extend(SassWarningSupressor)
39+
2640
module GovukTechDocs
2741
# Configure the tech docs template
2842
#
@@ -32,7 +46,7 @@ module GovukTechDocs
3246
def self.configure(context, options = {})
3347
context.activate :sprockets
3448

35-
context.sprockets.append_path File.join(__dir__, "../node_modules/govuk-frontend/")
49+
context.sprockets.append_path File.join(__dir__, "../node_modules/govuk-frontend/dist")
3650
context.sprockets.append_path File.join(__dir__, "./source")
3751

3852
context.activate :syntax
@@ -50,14 +64,17 @@ def self.configure(context, options = {})
5064
tables: true,
5165
no_intra_emphasis: true
5266

67+
# this doesnt seem to work
68+
context.set :sass, { output_style: "nested", quiet_deps: true }
69+
5370
# Reload the browser automatically whenever files change
5471
context.configure :development do
5572
activate :livereload, options[:livereload].to_h
5673
end
5774

5875
context.configure :build do
5976
activate :autoprefixer
60-
activate :minify_javascript, ignore: ["/raw_assets/*"]
77+
activate :minify_javascript, compressor: Terser.new, ignore: ["/raw_assets/*"]
6178
end
6279

6380
config_file = ENV.fetch("CONFIG_FILE", "config/tech-docs.yml")

lib/govuk_tech_docs/meta_tags.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def canonical_url
4848
attr_reader :config, :current_page
4949

5050
def page_image
51-
"#{host}/images/govuk-large.png"
51+
"#{host}/assets/govuk/assets/images/govuk-opengraph-image.png"
5252
end
5353

5454
def site_name

lib/source/favicon.ico

-13.9 KB
Binary file not shown.

lib/source/layouts/_header.erb

+7-11
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,18 @@
88
<% end %>
99
<% if config[:tech_docs][:show_govuk_logo] %>
1010
<svg
11-
aria-hidden="true"
1211
focusable="false"
13-
class="govuk-header__logotype-crown"
12+
role="img"
13+
class="govuk-header__logotype"
1414
xmlns="http://www.w3.org/2000/svg"
15-
viewBox="0 0 32 30"
15+
viewBox="0 0 148 30"
1616
height="30"
17-
width="32"
17+
width="148"
18+
aria-label="GOV.UK"
1819
>
19-
<path
20-
fill="currentColor" fill-rule="evenodd"
21-
d="M22.6 10.4c-1 .4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 2 .1 2.4 1s-.1 2-1 2.4m-5.9 6.7c-.9.4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-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-5.9 21h-5.7zm28.8-3.6c.6 0 1.2-.1 1.7-.3.5-.2 1-.4 1.4-.8.4-.4.7-.8.9-1.4.2-.6.3-1.2.3-2v-13h4.1v13.6c0 1.2-.2 2.2-.6 3.1s-1 1.7-1.8 2.4c-.7.7-1.6 1.2-2.7 1.5-1 .4-2.2.5-3.4.5-1.2 0-2.4-.2-3.4-.5-1-.4-1.9-.9-2.7-1.5-.8-.7-1.3-1.5-1.8-2.4-.4-.9-.6-2-.6-3.1V6.9h4.2v13c0 .8.1 1.4.3 2 .2.6.5 1 .9 1.4.4.4.8.6 1.4.8.6.2 1.1.3 1.8.3zm13-17.4h4.2v9.1l7.4-9.1h5.2l-7.2 8.4L148 28h-4.9l-5.5-9.4-2.7 3V28h-4.2V7zm-27.6 16.1c-1.5 0-2.7 1.2-2.7 2.7s1.2 2.7 2.7 2.7 2.7-1.2 2.7-2.7-1.2-2.7-2.7-2.7z"></path>
2222
</svg>
23-
<span class="govuk-header__logotype-text">
24-
GOV.UK
25-
</span>
26-
</span>
2723
<% end %>
2824
<span class="govuk-header__product-name">
2925
<%= config[:tech_docs][:service_name] %>

lib/source/layouts/core.erb

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
<%= stylesheet_link_tag :manifest %>
1111

1212
<link rel="canonical" href="<%= meta_tags.canonical_url %>">
13+
<link rel="icon" sizes="48x48" href="/assets/govuk/assets/images/favicon.ico">
14+
<link rel="icon" sizes="any" href="/assets/govuk/assets/images/favicon.svg" type="image/svg+xml">
15+
<link rel="mask-icon" href="/assets/govuk/assets/images/govuk-icon-mask.svg" color="#0b0c0c">
16+
<link rel="apple-touch-icon" href="/assets/govuk/assets/images/govuk-icon-180.png">
17+
<link rel="manifest" href="/assets/govuk/assets/manifest.json">
1318

1419
<% meta_tags.tags.each do |name, content| %>
1520
<%= tag :meta, name: name, content: content %>
@@ -23,7 +28,7 @@
2328
</head>
2429

2530
<body class="govuk-template__body">
26-
<script>document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled');</script>
31+
<script>document.body.className += ' js-enabled' + ('noModule' in HTMLScriptElement.prototype ? ' govuk-frontend-supported' : '');</script>
2732

2833
<div class="app-pane">
2934
<div class="app-pane__header toc-open-disabled">
@@ -75,6 +80,7 @@
7580
</div>
7681

7782
<%= partial 'layouts/analytics' %>
83+
<%= javascript_include_tag :govuk_frontend, :type => "module" %>
7884
<%= javascript_include_tag :application %>
7985
</body>
8086
</html>

lib/source/stylesheets/manifest.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
//= link_tree ../../../node_modules/govuk-frontend/govuk/assets
1+
//= link_tree ../../../node_modules/govuk-frontend/dist/govuk/assets
22

33
//= require screen

package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"lint": "standard"
77
},
88
"dependencies": {
9-
"govuk-frontend": "~4.7.0"
9+
"govuk-frontend": "~5.6.0"
1010
},
1111
"devDependencies": {
1212
"standard": "^14.3.4"

spec/govuk_tech_docs/meta_tags_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def generate_title(site_name:, page_title:)
5050
"description" => "The description.",
5151
"twitter:card" => "summary",
5252
"twitter:domain" => "www.example.org",
53-
"twitter:image" => "https://www.example.org/images/govuk-large.png",
53+
"twitter:image" => "https://www.example.org/assets/govuk/assets/images/govuk-opengraph-image.png",
5454
"twitter:title" => "The Title - Test Site",
5555
"twitter:url" => "https://www.example.org/foo.html",
5656
)
@@ -139,7 +139,7 @@ def generate_title(site_name:, page_title:)
139139

140140
expect(og_tags).to eql(
141141
"og:description" => "The description.",
142-
"og:image" => "https://www.example.org/images/govuk-large.png",
142+
"og:image" => "https://www.example.org/assets/govuk/assets/images/govuk-opengraph-image.png",
143143
"og:site_name" => "Test Site",
144144
"og:title" => "The Title",
145145
"og:type" => "object",

spec/javascripts/support/jasmine.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
src_files:
1414
- lib/assets/javascripts/_vendor/jquery.js
1515
- lib/assets/javascripts/**/*.js
16-
- node_modules/govuk-frontend/govuk/all.js
16+
- "!lib/assets/javascripts/govuk_frontend_all.js"
1717

1818
# helpers
1919
#

spec/javascripts/table-of-contents-spec.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ describe('Table of contents', function () {
77
var $toc
88
var $closeButton
99
var $openButton
10+
var $tocStickyHeader
1011
var module
1112

1213
beforeAll(function () {
@@ -64,13 +65,18 @@ describe('Table of contents', function () {
6465

6566
$closeButton = $toc.find('.js-toc-close')
6667
$openButton = $html.find('.js-toc-show')
68+
69+
$tocStickyHeader = $html.find('.toc-show')
6770
})
6871

6972
afterEach(function () {
7073
// clear up any classes left on <html>
71-
$html.removeClass('.toc-open')
74+
$html.removeClass('toc-open')
7275
$html.find('body #toc-heading').remove()
7376
$html.find('body .toc').remove()
77+
if ($tocStickyHeader && $tocStickyHeader.length) {
78+
$tocStickyHeader.remove()
79+
}
7480
})
7581

7682
describe('when the module is started', function () {

0 commit comments

Comments
 (0)