govuk_publishing_components 21.42.0 → 21.43.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (23) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/govuk_publishing_components/components/_button.scss +2 -1
  3. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-header.scss +5 -7
  4. data/app/controllers/govuk_publishing_components/component_guide_controller.rb +1 -1
  5. data/app/models/govuk_publishing_components/component_doc.rb +1 -1
  6. data/app/models/govuk_publishing_components/component_docs.rb +1 -1
  7. data/app/views/govuk_publishing_components/components/_button.html.erb +1 -1
  8. data/app/views/govuk_publishing_components/components/docs/button.yml +7 -0
  9. data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_header.yml +4 -0
  10. data/config/initializers/assets.rb +6 -6
  11. data/lib/generators/govuk_publishing_components/component_generator.rb +2 -2
  12. data/lib/govuk_publishing_components/app_helpers/table_helper.rb +5 -5
  13. data/lib/govuk_publishing_components/presenters/breadcrumbs.rb +3 -3
  14. data/lib/govuk_publishing_components/presenters/button_helper.rb +10 -6
  15. data/lib/govuk_publishing_components/presenters/checkboxes_helper.rb +5 -5
  16. data/lib/govuk_publishing_components/presenters/contents_list_helper.rb +3 -3
  17. data/lib/govuk_publishing_components/presenters/machine_readable/article_schema.rb +1 -1
  18. data/lib/govuk_publishing_components/presenters/machine_readable/organisation_schema.rb +2 -3
  19. data/lib/govuk_publishing_components/presenters/meta_tags.rb +2 -2
  20. data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +2 -2
  21. data/lib/govuk_publishing_components/presenters/translation_nav_helper.rb +1 -1
  22. data/lib/govuk_publishing_components/version.rb +1 -1
  23. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24829cd84e2ddb267b818d1d885391681240e46cac461922e7389dc173c797c6
4
- data.tar.gz: 1e07e232b562ebfc957807cc4c08a28ce29d3d7b4ae5c31ad00283f5ce30f651
3
+ metadata.gz: 8fbab4c4935ddd5876ef31433f8fbfbd3dc7289928bbdd9baab16f59f84b81e9
4
+ data.tar.gz: 9b90c661ad7d473726a88c4763e4dac161f09b80bc091e4a9985880ed2c86cd4
5
5
  SHA512:
6
- metadata.gz: a59631eac2c60297c23f7fac1b136baa6d4ed48a75d03aace3ddd5b9eba136d39c772df2602bb88d7336824e581137acf8a3a78e273a1b681241183eb9155f43
7
- data.tar.gz: 45bfd361a06cfcff26f939f5469c6e6f1c9790059fdb63ae3556b731308e1a6ae86e60be28c01c94b67ed3fa7dfaea0803dd737607023f59ebd8876b11aec84f
6
+ metadata.gz: c6efa64dea7e1b4ec9392b80805697479a3faf46a5dd462f655e875ec06ca1b0dacc9a644da2335c449f57ee29579e98b22f055358c2567fea4e224f34fa806d
7
+ data.tar.gz: 6c65d073df5f1e5e21435b5dac6e4bfa6381b9edb0ea212520abe123bdbdf41462f9324bf4828d73151f511d69bf06d4afcf9c296794c3c9a069d71891a9d4f1
@@ -18,7 +18,8 @@ $gem-quiet-button-hover-colour: darken($gem-quiet-button-colour, 5%);
18
18
  // this will be moved and extended into a model for general component spacing
19
19
  // once this has been decided upon and other work completed, see:
20
20
  // https://trello.com/c/KEkNsxG3/142-3-implement-customisable-spacing-for-components
21
- .gem-c-button--bottom-margin {
21
+ .gem-c-button--bottom-margin,
22
+ .gem-c-button__info-text--bottom-margin {
22
23
  @include responsive-bottom-margin;
23
24
  }
24
25
 
@@ -3,26 +3,24 @@
3
3
  position: relative;
4
4
  padding: 10px;
5
5
  background: govuk-colour("light-grey", $legacy: "grey-4");
6
- border-top: solid 1px govuk-colour("mid-grey", $legacy: "grey-2");
7
- border-bottom: solid 1px govuk-colour("mid-grey", $legacy: "grey-2");
6
+ border-bottom: solid 1px govuk-colour("blue");
7
+ margin-top: govuk-spacing(3);
8
8
 
9
9
  @include govuk-media-query($from: tablet) {
10
- padding: govuk-spacing(3);
10
+ padding: govuk-spacing(5);
11
11
  }
12
12
  }
13
13
 
14
14
  // scss-lint:disable SelectorFormat
15
15
 
16
16
  .gem-c-step-nav-header__part-of {
17
- @include govuk-font(16, $weight: bold);
18
-
17
+ @include govuk-font(19, $weight: bold);
19
18
  display: block;
20
- padding-bottom: .2em;
21
19
  }
22
20
 
23
21
  .gem-c-step-nav-header__title {
24
22
  @extend %govuk-link;
25
- @include govuk-font(24, $weight: bold);
23
+ @include govuk-font(24, $weight: bold, $line-height: 1);
26
24
  }
27
25
 
28
26
  // scss-lint:enable SelectorFormat
@@ -109,7 +109,7 @@ module GovukPublishingComponents
109
109
  end
110
110
 
111
111
  def component_breadcrumb(component_doc, component_example = nil)
112
- Hash.new.tap do |h|
112
+ {}.tap do |h|
113
113
  h[:title] = component_doc.name
114
114
  h[:url] = component_doc_path(component_doc.id) if component_example
115
115
  end
@@ -75,7 +75,7 @@ module GovukPublishingComponents
75
75
 
76
76
  def examples
77
77
  @examples ||= component[:examples].map do |id, example_data|
78
- example_data = example_data || {}
78
+ example_data ||= {}
79
79
  example_data["embed"] ||= embed
80
80
  ComponentExample.new(id.to_s, example_data)
81
81
  end
@@ -45,7 +45,7 @@ module GovukPublishingComponents
45
45
  end
46
46
 
47
47
  def parse_documentation(file)
48
- { id: File.basename(file, ".yml") }.merge(YAML::load_file(file)).with_indifferent_access
48
+ { id: File.basename(file, ".yml") }.merge(YAML.load_file(file)).with_indifferent_access
49
49
  end
50
50
 
51
51
  def app_documentation_directory
@@ -22,5 +22,5 @@
22
22
  <% end %>
23
23
 
24
24
  <% if button.info_text %>
25
- <%= tag.span button.info_text, class: "gem-c-button__info-text" %>
25
+ <%= tag.span button.info_text, class: button.info_text_classes %>
26
26
  <% end %>
@@ -62,6 +62,13 @@ examples:
62
62
  href: "#"
63
63
  start: true
64
64
  info_text: "Sometimes you want to explain where a user is going to."
65
+ start_now_button_with_info_text_and_margin_bottom:
66
+ data:
67
+ text: "Start now"
68
+ href: "#"
69
+ start: true
70
+ info_text: "Sometimes you want to explain where a user is going to and have a margin bottom"
71
+ margin_bottom: true
65
72
  with_margin_bottom:
66
73
  description: "Sometimes it's useful to break up a page, for example if a button is at the bottom of a page."
67
74
  data:
@@ -16,6 +16,10 @@ examples:
16
16
  data:
17
17
  title: 'Having children: step by step'
18
18
  path: /childcare-parenting/pregnancy-and-birth
19
+ with_a_long_text:
20
+ data:
21
+ title: 'Coronavirus: businesses and self-employed people'
22
+ path: /childcare-parenting/pregnancy-and-birth
19
23
  with_unique_tracking:
20
24
  description: In order to identify the step by step navigation the component is part of, we need to track a unique ID of the navigation in Google Analytics. This ID should be the same across all pages that are linked from and are part of that navigation. Its value is included in any tracking events, specifically in dimension96. It refers to the ID of the step nav that the component links to.
21
25
  data:
@@ -1,7 +1,7 @@
1
1
  return unless Rails.application.config.respond_to?(:assets)
2
2
 
3
3
  # GOV.UK Publishing Components assets
4
- Rails.application.config.assets.precompile += %w(
4
+ Rails.application.config.assets.precompile += %w[
5
5
  component_guide/accessibility-test.js
6
6
  component_guide/application.js
7
7
  component_guide/filter-components.js
@@ -25,16 +25,16 @@ Rails.application.config.assets.precompile += %w(
25
25
  govuk_publishing_components/icon-important.svg
26
26
  govuk_publishing_components/chevron-banner/*.svg
27
27
  govuk_publishing_components/crests/*.png
28
- )
28
+ ]
29
29
 
30
30
  # GOV.UK Frontend assets
31
- Rails.application.config.assets.precompile += %w(
31
+ Rails.application.config.assets.precompile += %w[
32
32
  govuk-logotype-crown.png
33
- )
33
+ ]
34
34
 
35
- Rails.application.config.assets.paths += %W(
35
+ Rails.application.config.assets.paths += %W[
36
36
  #{__dir__}/../../node_modules/govuk-frontend/govuk/assets/images
37
37
  #{__dir__}/../../node_modules/govuk-frontend/govuk/assets/fonts
38
38
  #{__dir__}/../../node_modules/govuk-frontend/
39
39
  #{__dir__}/../../node_modules/
40
- )
40
+ ]
@@ -26,9 +26,9 @@ module GovukPublishingComponents
26
26
  private
27
27
 
28
28
  def create_directory_if_not_exists(dir)
29
- if not File.directory?(dir)
29
+ if !File.directory?(dir)
30
30
  puts("Directory #{dir} not found, creating")
31
- FileUtils::mkdir_p dir
31
+ FileUtils.mkdir_p dir
32
32
  end
33
33
  end
34
34
  end
@@ -4,10 +4,10 @@ module GovukPublishingComponents
4
4
  def self.helper(context, caption = nil, opt = {})
5
5
  builder = TableBuilder.new(context.tag)
6
6
 
7
- classes = %w(gem-c-table govuk-table)
7
+ classes = %w[gem-c-table govuk-table]
8
8
  classes << "govuk-table--sortable" if opt[:sortable]
9
9
 
10
- caption_classes = %w(govuk-table__caption)
10
+ caption_classes = %w[govuk-table__caption]
11
11
  caption_classes << opt[:caption_classes] if opt[:caption_classes]
12
12
 
13
13
  context.tag.table class: classes do
@@ -46,17 +46,17 @@ module GovukPublishingComponents
46
46
  end
47
47
 
48
48
  def header(str, opt = {})
49
- classes = %w(govuk-table__header)
49
+ classes = %w[govuk-table__header]
50
50
  classes << "govuk-table__header--#{opt[:format]}" if opt[:format]
51
51
  classes << "govuk-table__header--active" if opt[:sort_direction]
52
- link_classes = %w(app-table__sort-link)
52
+ link_classes = %w[app-table__sort-link]
53
53
  link_classes << "app-table__sort-link--#{opt[:sort_direction]}" if opt[:sort_direction]
54
54
  str = link_to str, opt[:href], class: link_classes, data: opt[:data_attributes] if opt[:href]
55
55
  tag.th str, class: classes, scope: opt[:scope] || "col"
56
56
  end
57
57
 
58
58
  def cell(str, opt = {})
59
- classes = %w(govuk-table__cell)
59
+ classes = %w[govuk-table__cell]
60
60
  classes << "govuk-table__cell--" + opt[:format] if opt[:format]
61
61
  classes << "govuk-table__cell--empty" unless str
62
62
  str ||= "Not set"
@@ -18,9 +18,9 @@ module GovukPublishingComponents
18
18
  attr_reader :breadcrumbs
19
19
 
20
20
  def item_list_element
21
- breadcrumbs.each_with_index.map { |crumb, index| Breadcrumb.new(crumb, index) }.
22
- select(&:is_link?).
23
- map(&:item_list_element)
21
+ breadcrumbs.each_with_index.map { |crumb, index| Breadcrumb.new(crumb, index) }
22
+ .select(&:is_link?)
23
+ .map(&:item_list_element)
24
24
  end
25
25
  end
26
26
 
@@ -3,16 +3,20 @@ require "action_view"
3
3
  module GovukPublishingComponents
4
4
  module Presenters
5
5
  class ButtonHelper
6
- attr_reader :href, :text, :title, :info_text, :rel, :data_attributes,
7
- :margin_bottom, :inline_layout, :target, :type, :start,
8
- :secondary, :secondary_quiet, :destructive, :name, :value,
9
- :classes, :aria_label
6
+ attr_reader :href, :text, :title, :info_text, :info_text_classes,
7
+ :rel, :data_attributes, :margin_bottom, :inline_layout,
8
+ :target, :type, :start, :secondary, :secondary_quiet,
9
+ :destructive, :name, :value, :classes, :aria_label
10
10
 
11
11
  def initialize(local_assigns)
12
12
  @href = local_assigns[:href]
13
13
  @text = local_assigns[:text]
14
14
  @title = local_assigns[:title]
15
15
  @info_text = local_assigns[:info_text]
16
+ @info_text_classes = %w[gem-c-button__info-text]
17
+ if local_assigns[:margin_bottom]
18
+ @info_text_classes << "gem-c-button__info-text--bottom-margin"
19
+ end
16
20
  @rel = local_assigns[:rel]
17
21
  @data_attributes = local_assigns[:data_attributes]
18
22
  @margin_bottom = local_assigns[:margin_bottom]
@@ -59,12 +63,12 @@ module GovukPublishingComponents
59
63
  private
60
64
 
61
65
  def css_classes
62
- css_classes = %w(gem-c-button govuk-button)
66
+ css_classes = %w[gem-c-button govuk-button]
63
67
  css_classes << "govuk-button--start" if start
64
68
  css_classes << "gem-c-button--secondary" if secondary
65
69
  css_classes << "gem-c-button--secondary-quiet" if secondary_quiet
66
70
  css_classes << "govuk-button--warning" if destructive
67
- css_classes << "gem-c-button--bottom-margin" if margin_bottom
71
+ css_classes << "gem-c-button--bottom-margin" if margin_bottom && !info_text
68
72
  css_classes << "gem-c-button--inline" if inline_layout
69
73
  css_classes << classes if classes
70
74
  css_classes.join(" ")
@@ -10,12 +10,12 @@ module GovukPublishingComponents
10
10
  def initialize(options)
11
11
  @items = options[:items] || []
12
12
  @name = options[:name]
13
- @css_classes = %w(gem-c-checkboxes govuk-form-group)
13
+ @css_classes = %w[gem-c-checkboxes govuk-form-group]
14
14
  @css_classes << "govuk-form-group--error" if options[:error]
15
15
  @css_classes << "govuk-checkboxes--small" if options[:small]
16
16
  @error = true if options[:error]
17
17
 
18
- @list_classes = %w(govuk-checkboxes gem-c-checkboxes__list)
18
+ @list_classes = %w[govuk-checkboxes gem-c-checkboxes__list]
19
19
 
20
20
  # check if any item is set as being conditional
21
21
  @has_conditional = options[:items].any? { |item| item.is_a?(Hash) && item[:conditional] }
@@ -24,7 +24,7 @@ module GovukPublishingComponents
24
24
  @id = options[:id] || "checkboxes-#{SecureRandom.hex(4)}"
25
25
  @heading = options[:heading] || nil
26
26
  @heading_size = options[:heading_size]
27
- @heading_size = "m" unless %w(s m l xl).include?(@heading_size)
27
+ @heading_size = "m" unless %w[s m l xl].include?(@heading_size)
28
28
  @heading_caption = options[:heading_caption] || nil
29
29
  @is_page_heading = options[:is_page_heading]
30
30
  @description = options[:description] || nil
@@ -41,7 +41,7 @@ module GovukPublishingComponents
41
41
 
42
42
  def fieldset_describedby
43
43
  unless @no_hint_text
44
- text = %w()
44
+ text = %w[]
45
45
  text << "#{id}-hint" if @hint_text
46
46
  text << "#{id}-error" if @error
47
47
  text
@@ -60,7 +60,7 @@ module GovukPublishingComponents
60
60
  concat content_tag(:h1, @heading, class: "gem-c-title__text")
61
61
  end
62
62
  else
63
- classes = %w(govuk-fieldset__legend)
63
+ classes = %w[govuk-fieldset__legend]
64
64
  classes << "govuk-fieldset__legend--#{@heading_size}"
65
65
  classes << "gem-c-checkboxes__legend--hidden" if @visually_hide_heading
66
66
 
@@ -12,7 +12,7 @@ module GovukPublishingComponents
12
12
  @nested = !!@contents.find { |c| c[:items] && c[:items].any? }
13
13
  @format_numbers = options[:format_numbers]
14
14
 
15
- @classes = %w(gem-c-contents-list)
15
+ @classes = %w[gem-c-contents-list]
16
16
  @classes << " gem-c-contents-list--no-underline" unless options[:underline_links]
17
17
  end
18
18
 
@@ -26,7 +26,7 @@ module GovukPublishingComponents
26
26
  end
27
27
 
28
28
  def wrap_numbers_with_spans(content_item_link)
29
- content_item_text = strip_tags(content_item_link) #just the text of the link
29
+ content_item_text = strip_tags(content_item_link) # just the text of the link
30
30
 
31
31
  # Must start with a number
32
32
  # Number must be between 1 and 999 (ie not 2014)
@@ -36,7 +36,7 @@ module GovukPublishingComponents
36
36
  number = /^\d{1,3}(\.?|\.\d{1,2})(?=\s)/.match(content_item_text)
37
37
 
38
38
  if number
39
- words = content_item_text.sub(number.to_s, "").strip #remove the number from the text
39
+ words = content_item_text.sub(number.to_s, "").strip # remove the number from the text
40
40
  content_item_link.sub(content_item_text, "<span class=\"gem-c-contents-list__number\">#{number} </span><span class=\"gem-c-contents-list__numbered-text\">#{words}</span>").squish.html_safe
41
41
  else
42
42
  content_item_link
@@ -44,7 +44,7 @@ module GovukPublishingComponents
44
44
  end
45
45
 
46
46
  def search_description
47
- I18n.t(:scoped_search_description, scope: %i(components article_schema), title: page.title)
47
+ I18n.t(:scoped_search_description, scope: %i[components article_schema], title: page.title)
48
48
  end
49
49
  end
50
50
  end
@@ -44,7 +44,7 @@ module GovukPublishingComponents
44
44
  end
45
45
 
46
46
  def ministers_with_grouped_roles
47
- ministers.reduce({}) do |grouped, minister|
47
+ ministers.each_with_object({}) do |minister, grouped|
48
48
  person_schema = person_schema_for_minister(minister)
49
49
 
50
50
  if grouped.has_key? person_schema
@@ -52,7 +52,6 @@ module GovukPublishingComponents
52
52
  else
53
53
  grouped[person_schema] = [role_for_minister(minister)]
54
54
  end
55
- grouped
56
55
  end
57
56
  end
58
57
 
@@ -129,7 +128,7 @@ module GovukPublishingComponents
129
128
  end
130
129
 
131
130
  def search_description
132
- I18n.t(:all_content_search_description, scope: %i(components organisation_schema), organisation: page.title)
131
+ I18n.t(:all_content_search_description, scope: %i[components organisation_schema], organisation: page.title)
133
132
  end
134
133
 
135
134
  def organisation_facet_params
@@ -84,7 +84,7 @@ module GovukPublishingComponents
84
84
  slug_without_theme = base_path[%r{/[^/]+/(.+)}, 1]
85
85
  # Return the slug without the theme, or in the special case of a root taxon,
86
86
  # just return the full slug (because it doesn't have a slug beneath the theme)
87
- slug_without_theme || base_path.sub(%r(^/), "")
87
+ slug_without_theme || base_path.sub(%r{^/}, "")
88
88
  end
89
89
  taxon_ids = taxons.map { |taxon| taxon[:content_id] }
90
90
 
@@ -123,7 +123,7 @@ module GovukPublishingComponents
123
123
  parent_taxons = links[:parent_taxons] || links[:taxons] unless links.nil?
124
124
 
125
125
  if parent_taxons.blank?
126
- root_taxon_set << content_item[:base_path].sub(%r(^/), "") if content_item[:document_type] == "taxon"
126
+ root_taxon_set << content_item[:base_path].sub(%r{^/}, "") if content_item[:document_type] == "taxon"
127
127
  else
128
128
  parent_taxons.each do |parent_taxon|
129
129
  root_taxon_set += root_taxon_slugs(parent_taxon)
@@ -4,14 +4,14 @@ module GovukPublishingComponents
4
4
  # Only used by the related_navigation component
5
5
  class RelatedNavigationHelper
6
6
  MAX_SECTION_LENGTH = 5
7
- DEFINED_SECTIONS = %w(
7
+ DEFINED_SECTIONS = %w[
8
8
  related_guides
9
9
  topics
10
10
  collections
11
11
  topical_events
12
12
  world_locations
13
13
  statistical_data_sets
14
- ).freeze
14
+ ].freeze
15
15
  WORLD_LOCATION_SPECIAL_CASES = {
16
16
  "UK Mission to the European Union" => "uk-mission-to-the-eu",
17
17
  }.freeze
@@ -22,7 +22,7 @@ module GovukPublishingComponents
22
22
  end
23
23
 
24
24
  def classes
25
- classes = %w(gem-c-translation-nav)
25
+ classes = %w[gem-c-translation-nav]
26
26
  classes << inverse_class if @inverse
27
27
  classes << margin_class if @no_margin_top
28
28
  classes.join(" ")
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "21.42.0".freeze
2
+ VERSION = "21.43.0".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: 21.42.0
4
+ version: 21.43.0
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: 2020-04-24 00:00:00.000000000 Z
11
+ date: 2020-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gds-api-adapters