govuk_publishing_components 35.12.0 → 35.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (21) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-page-views.js +1 -0
  3. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-scroll-tracker.js +3 -3
  4. data/app/assets/stylesheets/govuk_publishing_components/components/_document-list.scss +3 -1
  5. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +8 -2
  6. data/app/controllers/govuk_publishing_components/audit_controller.rb +3 -2
  7. data/app/models/govuk_publishing_components/audit_applications.rb +3 -1
  8. data/app/models/govuk_publishing_components/audit_comparer.rb +1 -1
  9. data/app/models/govuk_publishing_components/audit_components.rb +3 -2
  10. data/app/models/govuk_publishing_components/component_wrapper_helper_options.rb +1 -0
  11. data/app/views/govuk_publishing_components/audit/_applications.html.erb +1 -1
  12. data/app/views/govuk_publishing_components/components/_button.html.erb +3 -1
  13. data/app/views/govuk_publishing_components/components/_document_list.html.erb +29 -27
  14. data/app/views/govuk_publishing_components/components/_heading.html.erb +8 -5
  15. data/app/views/govuk_publishing_components/components/docs/heading.yml +1 -4
  16. data/app/views/govuk_publishing_components/components/docs/single_page_notification_button.yml +1 -6
  17. data/app/views/govuk_publishing_components/components/docs/tabs.yml +1 -1
  18. data/lib/govuk_publishing_components/config.rb +3 -0
  19. data/lib/govuk_publishing_components/presenters/component_wrapper_helper.rb +17 -1
  20. data/lib/govuk_publishing_components/version.rb +1 -1
  21. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d923b79189269417363dd2c12781e9ee9644a03bf2c514b21e24d71efe0c07c7
4
- data.tar.gz: ce1f69cdb8ef0eaf3fcf836e359311e8b38a0f401bb931a3e8bfc27c1b568f56
3
+ metadata.gz: 1337364c8c59cc2f98de9c4919d17bbb17356257fcc90eb90f25e15db301a0ae
4
+ data.tar.gz: 70b99e1a524455dc905f457addfb78aa46f0a4fa7be0a69c64a5e34952228be3
5
5
  SHA512:
6
- metadata.gz: bffc7c115facd8c323182b04f089ecae6b5b2a6991ebed42aea17fc748b1a95bcbf1093f75e238291819bb9d821152b7f4ef3f2b95f0a4b2b1b14021ccbb5a14
7
- data.tar.gz: 03c818b7b4f9731f3075020ad5273256a30c3cdef0862f92892edea1dd6cd19e0e65ea781d8c9bb7fb2c87403c5478503442453c68ff80a2deea73ba820e3721
6
+ metadata.gz: 9a85f01e30436be8cb8f2131f851353e28a8cbad3c0269758789991491ad5ed232ae1e2e9d782e2fa8349c4863c38faadb254a788abb416e3b4ba35f32d196d7
7
+ data.tar.gz: 103018230befe8fca5796df4f9d2ebff20f255584253d37d5e3aa2c9cd997b7a17a6fdb719932c758f31647a84fb1c85329fc33082bf68ac1ca99fa48fcd7b36
@@ -21,6 +21,7 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
21
21
  title: this.getTitle(),
22
22
  status_code: this.getStatusCode(),
23
23
 
24
+ ab_test: this.getMetaContent('ab-test'),
24
25
  document_type: this.getMetaContent('format'),
25
26
  publishing_app: this.getMetaContent('publishing-app'),
26
27
  rendering_app: this.getMetaContent('rendering-app'),
@@ -199,14 +199,14 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
199
199
  Ga4ScrollTracker.Percentage.prototype.getTrackingNodes = function (trackedNodes) {
200
200
  var body = document.body
201
201
  var html = document.documentElement
202
- var pageHeight = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight)
202
+ // remove 20px from the calculated page height to allow for a possible horizontal scrollbar
203
+ var pageHeight = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight) - 20
203
204
 
204
205
  var percentDetails = []
205
206
 
206
207
  for (var i = 0; i < this.config.percentages.length; i++) {
207
208
  var percent = this.config.percentages[i]
208
- // subtract 1 pixel to solve a bug where 100% can't be reached in some cases
209
- var pos = ((pageHeight / 100) * percent) - 1
209
+ var pos = ((pageHeight / 100) * percent)
210
210
  var alreadySeen = false
211
211
  if (trackedNodes.length) {
212
212
  alreadySeen = trackedNodes[i].alreadySeen
@@ -25,7 +25,9 @@
25
25
 
26
26
  .gem-c-document-list--no-underline {
27
27
  .gem-c-document-list__item-title {
28
- text-decoration: none;
28
+ .govuk-link {
29
+ text-decoration: none;
30
+ }
29
31
  }
30
32
  }
31
33
 
@@ -110,6 +110,10 @@ $large-input-size: 50px;
110
110
  border: 0;
111
111
  cursor: pointer;
112
112
  border-radius: 0;
113
+ // render a border in high contrast mode
114
+ outline: $govuk-border-width-form-element solid transparent;
115
+ // Ensure outline appears outside of the element
116
+ outline-offset: 0;
113
117
  position: relative;
114
118
  padding: 0;
115
119
  width: $input-size;
@@ -124,8 +128,6 @@ $large-input-size: 50px;
124
128
  &:focus {
125
129
  z-index: 2;
126
130
  outline: $govuk-focus-width solid $govuk-focus-colour;
127
- // Ensure outline appears outside of the element
128
- outline-offset: 0;
129
131
  // Double the border by adding its width again. Use `box-shadow` for this // instead of changing `border-width` - this is for consistency with
130
132
  // Also, `outline` cannot be utilised
131
133
  // here as it is already used for the yellow focus state.
@@ -161,6 +163,10 @@ $large-input-size: 50px;
161
163
 
162
164
  .gem-c-search__input {
163
165
  border-width: 0;
166
+ // Render a border in high contrast mode
167
+ outline: $govuk-border-width-form-element solid transparent;
168
+ // Ensure outline appears outside of the element
169
+ outline-offset: 0;
164
170
 
165
171
  // no need for black outline as there is enough contrast
166
172
  // with the blue background
@@ -14,7 +14,6 @@ module GovukPublishingComponents
14
14
  government-frontend
15
15
  govspeak-preview
16
16
  info-frontend
17
- licence-finder
18
17
  release
19
18
  search-admin
20
19
  signon
@@ -49,7 +48,9 @@ module GovukPublishingComponents
49
48
 
50
49
  application_dirs.each do |application|
51
50
  application_path = [path, application].join("/")
52
- app = AuditApplications.new(application_path, application)
51
+ dir = application
52
+ dir = Rails.application.class.module_parent_name.underscore.dasherize unless ENV["MAIN_COMPONENT_GUIDE"]
53
+ app = AuditApplications.new(application_path, application, dir)
53
54
  applications_found += 1 if app.data[:application_found]
54
55
  results << app.data
55
56
  end
@@ -2,7 +2,7 @@ module GovukPublishingComponents
2
2
  class AuditApplications
3
3
  attr_reader :data
4
4
 
5
- def initialize(path, name)
5
+ def initialize(path, name, dir)
6
6
  @path = path
7
7
  application_found = application_exists(path)
8
8
  components_found = []
@@ -59,6 +59,7 @@ module GovukPublishingComponents
59
59
  # applications might not have all of these things for all components
60
60
  options = {
61
61
  application_name: name,
62
+ application_dir: dir,
62
63
  templates_path: "app/views/components",
63
64
  stylesheets_path: "app/assets/stylesheets/components",
64
65
  javascripts_path: "app/assets/javascripts/components/",
@@ -72,6 +73,7 @@ module GovukPublishingComponents
72
73
 
73
74
  @data = {
74
75
  name: name,
76
+ dir: dir,
75
77
  application_found: application_found,
76
78
  components_found: components_found,
77
79
  gem_style_references: @gem_style_references.flatten.uniq.sort,
@@ -12,7 +12,6 @@ module GovukPublishingComponents
12
12
  frontend
13
13
  government-frontend
14
14
  info-frontend
15
- licence-finder
16
15
  service-manual-frontend
17
16
  smart-answers
18
17
  whitehall
@@ -93,6 +92,7 @@ module GovukPublishingComponents
93
92
 
94
93
  data << {
95
94
  name: result[:name],
95
+ dir: result[:dir],
96
96
  application_found: result[:application_found],
97
97
  uses_static: application_uses_static,
98
98
  summary: summary,
@@ -13,6 +13,7 @@ module GovukPublishingComponents
13
13
  @helpers_path = options[:helpers_path] || "lib/govuk_publishing_components/presenters"
14
14
 
15
15
  @application_name = options[:application_name] || "govuk_publishing_components"
16
+ @application_dir = options[:application_dir] || "govuk_publishing_components"
16
17
  @all_templates = Dir["#{path}/#{@templates_path}/*.erb"].sort
17
18
  @templates_full_path = "#{path}/#{@templates_path}/"
18
19
 
@@ -57,7 +58,7 @@ module GovukPublishingComponents
57
58
  component_templates.each do |component|
58
59
  component_detail = {}
59
60
  component_detail[:name] = component
60
- component_detail[:application] = @application_name
61
+ component_detail[:application] = @application_dir
61
62
  component_detail[:link] = get_component_link(component) unless @auditing_an_application
62
63
  file_details = [
63
64
  {
@@ -214,7 +215,7 @@ module GovukPublishingComponents
214
215
 
215
216
  def get_asset_link(a_thing, component)
216
217
  url = "https://github.com/alphagov"
217
- repo = @application_name
218
+ repo = @application_dir
218
219
  blob = "blob/main"
219
220
  link = nil
220
221
  link = "#{url}/#{repo}/#{blob}/#{@templates_path}/_#{component.gsub(' ', '_')}.html.erb" if a_thing == "template"
@@ -9,6 +9,7 @@ This component uses the component wrapper helper. It accepts the following optio
9
9
  - `aria` - accepts a hash of aria attributes
10
10
  - `classes` - accepts a space separated string of classes, these should not be used for styling and must be prefixed with `js-`
11
11
  - `role` - accepts a space separated string of roles
12
+ - `lang` - accepts a language attribute value
12
13
  "
13
14
  end
14
15
  end
@@ -34,7 +34,7 @@
34
34
 
35
35
  <% accordion_content = capture do %>
36
36
  <% if application[:application_found] %>
37
- <% github_link = 'https://github.com/alphagov/' + application[:name] + '/blob/main/' %>
37
+ <% github_link = 'https://github.com/alphagov/' + application[:dir] + '/blob/main/' %>
38
38
 
39
39
  <% if @other_applications %>
40
40
  <% if application[:uses_individual_asset_model] %>
@@ -8,7 +8,9 @@
8
8
  %>
9
9
 
10
10
  <% start_button_text = capture do %>
11
- <%= button.text %>
11
+ <span>
12
+ <%= button.text %>
13
+ </span>
12
14
  <svg class="govuk-button__start-icon govuk-!-display-none-print" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewBox="0 0 33 40" focusable="false" aria-hidden="true">
13
15
  <path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z" />
14
16
  </svg>
@@ -29,35 +29,37 @@
29
29
  <p class='gem-c-document-list__highlight-text'><%= item[:highlight_text] %></p>
30
30
  <% end %>
31
31
 
32
- <%=
33
- item_classes = "gem-c-document-list__item-title #{brand_helper.color_class} #{title_with_context_class if item[:link][:context]}"
32
+ <%= content_tag :div, class: "gem-c-document-list__item-title" do -%>
33
+ <%=
34
+ item_classes = "#{brand_helper.color_class} #{title_with_context_class if item[:link][:context]}"
34
35
 
35
- if item[:link][:path]
36
- rel = [
37
- "external",
38
- "nofollow",
39
- "noopener",
40
- "noreferrer",
41
- "opener",
42
- ].include?(item[:link][:rel]) ? item[:link][:rel] : nil
36
+ if item[:link][:path]
37
+ rel = [
38
+ "external",
39
+ "nofollow",
40
+ "noopener",
41
+ "noreferrer",
42
+ "opener",
43
+ ].include?(item[:link][:rel]) ? item[:link][:rel] : nil
43
44
 
44
- link_to(
45
- item[:link][:text],
46
- item[:link][:path],
47
- data: item[:link][:data_attributes],
48
- class: "#{item_classes} govuk-link",
49
- lang: item[:link][:locale].presence,
50
- rel: rel,
51
- )
52
- else
53
- content_tag(
54
- "span",
55
- item[:link][:text],
56
- data: item[:link][:data_attributes],
57
- class: item_classes,
58
- )
59
- end
60
- %>
45
+ link_to(
46
+ item[:link][:text],
47
+ item[:link][:path],
48
+ data: item[:link][:data_attributes],
49
+ class: "#{item_classes} govuk-link",
50
+ lang: item[:link][:locale].presence,
51
+ rel: rel,
52
+ )
53
+ else
54
+ content_tag(
55
+ "span",
56
+ item[:link][:text],
57
+ data: item[:link][:data_attributes],
58
+ class: item_classes,
59
+ )
60
+ end
61
+ %>
62
+ <% end %>
61
63
 
62
64
  <% if item[:link][:context] %>
63
65
  <span class="gem-c-document-list__item-context"><%= item[:link][:context] %></span>
@@ -7,15 +7,18 @@
7
7
  brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand)
8
8
  heading_helper = GovukPublishingComponents::Presenters::HeadingHelper.new(local_assigns)
9
9
  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
10
+ component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
10
11
 
11
12
  classes = %w(gem-c-heading)
12
13
  classes << heading_helper.classes
13
14
  classes << brand_helper.brand_class
14
15
  classes << brand_helper.border_color_class
15
16
  classes << shared_helper.get_margin_bottom if [*0..9].include?(local_assigns[:margin_bottom])
17
+
18
+ component_helper.add_class(classes.join(" "))
19
+ component_helper.set_id(heading_helper.id)
20
+ element = shared_helper.get_heading_level
16
21
  %>
17
- <%= content_tag(shared_helper.get_heading_level, text,
18
- class: classes,
19
- id: heading_helper.id,
20
- lang: lang
21
- ) %>
22
+ <%= content_tag(element, component_helper.all_attributes) do %>
23
+ <%= text %>
24
+ <% end %>
@@ -15,6 +15,7 @@ accessibility_criteria: |
15
15
  - be part of a correct heading structure for a page
16
16
  - be semantically represented as a heading
17
17
  - convey the heading level
18
+ uses_component_wrapper_helper: true
18
19
  examples:
19
20
  default:
20
21
  data:
@@ -31,10 +32,6 @@ examples:
31
32
  data:
32
33
  text: 'One big heading'
33
34
  font_size: "xl"
34
- with_id_attribute:
35
- data:
36
- text: 'Detail of outcome'
37
- id: 'detail_of_outcome'
38
35
  right_to_left:
39
36
  data:
40
37
  text: 'مستندات'
@@ -9,6 +9,7 @@ body: |
9
9
  When the button is clicked, the `base_path` is submitted to an endpoint which proceeds to check the user's authentication status and whether they are already subscribed to the page or not. Depending on these factors, they will be routed accordingly.
10
10
  accessibility_criteria: |
11
11
  - The bell icon must be presentational and ignored by screen readers.
12
+ uses_component_wrapper_helper: true
12
13
  examples:
13
14
  default:
14
15
  description: By default this component prompts the user to subscribe to email notifications to this page.
@@ -19,12 +20,6 @@ examples:
19
20
  data:
20
21
  base_path: '/current-page-path'
21
22
  already_subscribed: true
22
- with_data_attributes:
23
- description: The component accepts data attributes (for example, for analytics)
24
- data:
25
- base_path: '/current-page-path'
26
- data_attributes:
27
- test_attribute: "testing"
28
23
  with_ga4_tracking:
29
24
  description: To add GA4 tracking, pass a `ga4_data_attributes` object with the necessary properties to the component. For example:-
30
25
  data:
@@ -17,7 +17,7 @@ accessibility_criteria: |
17
17
  * be usable with touch
18
18
  * be usable with voice commands
19
19
  * have visible text
20
-
20
+ uses_component_wrapper_helper: true
21
21
  examples:
22
22
  default:
23
23
  data:
@@ -9,6 +9,9 @@ module GovukPublishingComponents
9
9
  mattr_accessor :component_guide_title
10
10
  self.component_guide_title = "Component Guide"
11
11
 
12
+ mattr_accessor :application_dir
13
+ self.application_dir = ""
14
+
12
15
  mattr_accessor :application_stylesheet
13
16
  self.application_stylesheet = "application"
14
17
 
@@ -9,6 +9,7 @@ module GovukPublishingComponents
9
9
  check_classes_are_valid(@options[:classes]) if @options.include?(:classes)
10
10
  check_aria_is_valid(@options[:aria]) if @options.include?(:aria)
11
11
  check_role_is_valid(@options[:role]) if @options.include?(:role)
12
+ check_lang_is_valid(@options[:lang]) if @options.include?(:lang)
12
13
  end
13
14
 
14
15
  def all_attributes
@@ -19,6 +20,7 @@ module GovukPublishingComponents
19
20
  attributes[:aria] = @options[:aria] unless @options[:aria].blank?
20
21
  attributes[:class] = @options[:classes] unless @options[:classes].blank?
21
22
  attributes[:role] = @options[:role] unless @options[:role].blank?
23
+ attributes[:lang] = @options[:lang] unless @options[:lang].blank?
22
24
 
23
25
  attributes
24
26
  end
@@ -48,6 +50,11 @@ module GovukPublishingComponents
48
50
  extend_string(:role, role)
49
51
  end
50
52
 
53
+ def set_lang(lang)
54
+ check_lang_is_valid(lang)
55
+ @options[:lang] = lang
56
+ end
57
+
51
58
  private
52
59
 
53
60
  def check_id_is_valid(id)
@@ -69,7 +76,7 @@ module GovukPublishingComponents
69
76
  return if classes.blank?
70
77
 
71
78
  class_array = classes.split(" ")
72
- unless class_array.all? { |c| c.start_with?("js-", "gem-c-", "govuk-", "brand--") }
79
+ unless class_array.all? { |c| c.start_with?("js-", "gem-c-", "govuk-", "brand--", "brand__") }
73
80
  raise(ArgumentError, "Classes (#{classes}) must be prefixed with `js-`")
74
81
  end
75
82
  end
@@ -98,6 +105,15 @@ module GovukPublishingComponents
98
105
  end
99
106
  end
100
107
 
108
+ def check_lang_is_valid(lang)
109
+ return if lang.blank?
110
+
111
+ langs = %w[ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh zh-Hans zh-Hant cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl gd gv ka de el kl gn gu ht ha he hz hi ho hu is io ig id in ia ie iu ik ga it ja jv kl kn kr ks kk km ki rw rn ky kv kg ko ku kj lo la lv li ln lt lu lg lb gv mk mg ms ml mt mi mr mh mo mn na nv ng nd ne no nb nn ii oc oj cu or om os pi ps fa pl pt pa qu rm ro ru se sm sg sa sr sh st tn sn ii sd si ss sk sl so nr es su sw ss sv tl ty tg ta tt te th bo ti to ts tr tk tw ug uk ur uz ve vi vo wa cy wo fy xh yi ji yo za zu]
112
+ unless langs.include? lang
113
+ raise(ArgumentError, "lang attribute (#{lang}) is not recognised")
114
+ end
115
+ end
116
+
101
117
  def extend_string(option, string)
102
118
  ((@options[option] ||= "") << " #{string}").strip!
103
119
  end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "35.12.0".freeze
2
+ VERSION = "35.13.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 35.12.0
4
+ version: 35.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-24 00:00:00.000000000 Z
11
+ date: 2023-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config