Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking test failures in use-govuk-frontend-v5 #367

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Changelog

## Unreleased
- Upgrade to govuk-frontend v5.6.0 and introduce new Javascript entry point

You need to
- create a `govuk_frontend.js` file your project’s `source/assets/javascripts` directory
- add `//= require govuk_frontend_all` into it

Note: In stylesheet compilation you'll see some warnings. At the moment we are unable to silence them.
Your stylesheet will compile as normal.

- BREAKING: drop support for end-of-life Ruby versions 2.7 and 3.0. The minimum Ruby version is now 3.1.
- Update gem dependencies.
Expand Down
1 change: 1 addition & 0 deletions example/source/javascripts/govuk_frontend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//= require govuk_frontend_all
6 changes: 4 additions & 2 deletions govuk_tech_docs.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require "govuk_tech_docs/version"
`npm install`
abort "npm install failed" unless $CHILD_STATUS.success?

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

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

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

spec.files = files_in_git + govuk_frontend_assets

Expand All @@ -52,6 +52,8 @@ Gem::Specification.new do |spec|
spec.add_dependency "nokogiri"
spec.add_dependency "openapi3_parser", "~> 0.9.0"
spec.add_dependency "redcarpet", "~> 3.6"
spec.add_dependency "terser", "~> 1.2.3"
spec.add_dependency "sassc-embedded", "~> 1.78.0"

spec.add_development_dependency "byebug"
spec.add_development_dependency "capybara", "~> 3.32"
Expand Down
3 changes: 3 additions & 0 deletions lib/assets/javascripts/govuk_frontend_all.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//= require govuk/all.bundle.js
const { initAll } = window.GOVUKFrontend
initAll()
2 changes: 0 additions & 2 deletions lib/assets/javascripts/govuk_tech_docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
//= require _vendor/lodash
//= require _analytics
//= require _start-modules
//= require govuk/all.js

$(function () {
$('.fixedsticky').fixedsticky()
GOVUKFrontend.initAll()
})
14 changes: 4 additions & 10 deletions lib/assets/stylesheets/_govuk_tech_docs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ $govuk-assets-path: "/assets/govuk/assets/" !default;
$govuk-new-link-styles: true;
@import "govuk/base";

@import "govuk/core/all";
@import "govuk/objects/all";
@import "govuk/core/index";
@import "govuk/objects/index";

@import "govuk/components/footer/index";
@import "govuk/components/header/index";
Expand All @@ -22,14 +22,8 @@ $govuk-new-link-styles: true;
@import "govuk/components/skip-link/index";
@import "govuk/components/warning-text/index";

@import "govuk/utilities/all";
@import "govuk/overrides/all";
@import "govuk/utilities/index";
@import "govuk/overrides/index";

@import "core";
@import "vendor/fixedsticky";

// manual Tudor Crown spacing adjustment from govuk-frontend 4.8
.govuk-header__logotype-crown[width="32"] {
top: -3px;
margin-right: 2px;
}
4 changes: 0 additions & 4 deletions lib/assets/stylesheets/modules/_search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ $input-size: 40px;
outline: $govuk-focus-width solid $govuk-focus-colour;
outline-offset: 0;
box-shadow: inset 0 0 0 $govuk-border-width-form-element * 2 govuk-colour("black");

@include govuk-if-ie8 {
border-width: $govuk-border-width-form-element * 2;
}
}
}

Expand Down
9 changes: 7 additions & 2 deletions lib/govuk_tech_docs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
require "nokogiri"
require "chronic"
require "active_support/all"
require "terser"
require "sassc-embedded"

require "govuk_tech_docs/redirects"
require "govuk_tech_docs/table_of_contents/helpers"
Expand All @@ -32,7 +34,7 @@ module GovukTechDocs
def self.configure(context, options = {})
context.activate :sprockets

context.sprockets.append_path File.join(__dir__, "../node_modules/govuk-frontend/")
context.sprockets.append_path File.join(__dir__, "../node_modules/govuk-frontend/dist")
context.sprockets.append_path File.join(__dir__, "./source")

context.activate :syntax
Expand All @@ -50,14 +52,17 @@ def self.configure(context, options = {})
tables: true,
no_intra_emphasis: true

# this doesnt seem to work
context.set :sass, { output_style: "nested", quiet_deps: true }

# Reload the browser automatically whenever files change
context.configure :development do
activate :livereload, options[:livereload].to_h
end

context.configure :build do
activate :autoprefixer
activate :minify_javascript, ignore: ["/raw_assets/*"]
activate :minify_javascript, compressor: Terser.new, ignore: ["/raw_assets/*"]
end

config_file = ENV.fetch("CONFIG_FILE", "config/tech-docs.yml")
Expand Down
2 changes: 1 addition & 1 deletion lib/govuk_tech_docs/meta_tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def canonical_url
attr_reader :config, :current_page

def page_image
"#{host}/images/govuk-large.png"
"#{host}/assets/govuk/assets/images/govuk-opengraph-image.png"
end

def site_name
Expand Down
Binary file removed lib/source/favicon.ico
Binary file not shown.
18 changes: 7 additions & 11 deletions lib/source/layouts/_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,18 @@
<% end %>
<% if config[:tech_docs][:show_govuk_logo] %>
<svg
aria-hidden="true"
focusable="false"
class="govuk-header__logotype-crown"
role="img"
class="govuk-header__logotype"
xmlns="http://www.w3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7-1.4-.7-.3-1.5-.5-2.4-.5s-1.7.2-2.4.5-1.3.8-1.7 1.4c-.5.6-.8 1.3-1.1 2.2-.2.8-.4 1.7-.4 2.7v.1c0 1 .1 1.9.4 2.7.2.8.6 1.6 1.1 2.2.5.6 1.1 1.1 1.7 1.4.6.3 1.4.5 2.4.5zM88.9 28 83 7h4.7l4 15.7h.1l4-15.7h4.7l-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>
</svg>
<span class="govuk-header__logotype-text">
GOV.UK
</span>
</span>
<% end %>
<span class="govuk-header__product-name">
<%= config[:tech_docs][:service_name] %>
Expand Down
8 changes: 7 additions & 1 deletion lib/source/layouts/core.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
<%= stylesheet_link_tag :manifest %>

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

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

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

<div class="app-pane">
<div class="app-pane__header toc-open-disabled">
Expand Down Expand Up @@ -75,6 +80,7 @@
</div>

<%= partial 'layouts/analytics' %>
<%= javascript_include_tag :govuk_frontend, :type => "module" %>
<%= javascript_include_tag :application %>
</body>
</html>
2 changes: 1 addition & 1 deletion lib/source/stylesheets/manifest.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
//= link_tree ../../../node_modules/govuk-frontend/govuk/assets
//= link_tree ../../../node_modules/govuk-frontend/dist/govuk/assets

//= require screen
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"lint": "standard"
},
"dependencies": {
"govuk-frontend": "~4.7.0"
"govuk-frontend": "~5.6.0"
},
"devDependencies": {
"standard": "^14.3.4"
Expand Down
4 changes: 2 additions & 2 deletions spec/govuk_tech_docs/meta_tags_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def generate_title(site_name:, page_title:)
"description" => "The description.",
"twitter:card" => "summary",
"twitter:domain" => "www.example.org",
"twitter:image" => "https://www.example.org/images/govuk-large.png",
"twitter:image" => "https://www.example.org/assets/govuk/assets/images/govuk-opengraph-image.png",
"twitter:title" => "The Title - Test Site",
"twitter:url" => "https://www.example.org/foo.html",
)
Expand Down Expand Up @@ -139,7 +139,7 @@ def generate_title(site_name:, page_title:)

expect(og_tags).to eql(
"og:description" => "The description.",
"og:image" => "https://www.example.org/images/govuk-large.png",
"og:image" => "https://www.example.org/assets/govuk/assets/images/govuk-opengraph-image.png",
"og:site_name" => "Test Site",
"og:title" => "The Title",
"og:type" => "object",
Expand Down
2 changes: 1 addition & 1 deletion spec/javascripts/support/jasmine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
src_files:
- lib/assets/javascripts/_vendor/jquery.js
- lib/assets/javascripts/**/*.js
- node_modules/govuk-frontend/govuk/all.js
- "!lib/assets/javascripts/govuk_frontend_all.js"

# helpers
#
Expand Down
Loading