govuk_publishing_components 21.57.1 → 21.60.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +31 -6
  3. data/app/assets/javascripts/component_guide/accessibility-test.js +21 -21
  4. data/app/assets/javascripts/component_guide/filter-components.js +19 -19
  5. data/app/assets/javascripts/component_guide/visual-regression.js +38 -37
  6. data/app/assets/javascripts/govuk_publishing_components/components/checkboxes.js +2 -2
  7. data/app/assets/javascripts/govuk_publishing_components/components/details.js +6 -4
  8. data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +4 -4
  9. data/app/assets/javascripts/govuk_publishing_components/lib/auto-track-event.js +31 -0
  10. data/app/assets/javascripts/govuk_publishing_components/lib/cookie-functions.js +24 -24
  11. data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js +17 -17
  12. data/app/assets/stylesheets/component_guide/application.scss +15 -15
  13. data/app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss +0 -8
  14. data/app/assets/stylesheets/govuk_publishing_components/components/_breadcrumbs.scss +1 -1
  15. data/app/assets/stylesheets/govuk_publishing_components/components/_checkboxes.scss +4 -0
  16. data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +1 -8
  17. data/app/assets/stylesheets/govuk_publishing_components/components/_feedback.scss +0 -1
  18. data/app/assets/stylesheets/govuk_publishing_components/components/_govspeak-html-publication.scss +4 -5
  19. data/app/assets/stylesheets/govuk_publishing_components/components/_heading.scss +3 -8
  20. data/app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss +1 -1
  21. data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +1 -1
  22. data/app/assets/stylesheets/govuk_publishing_components/components/_inverse-header.scss +5 -8
  23. data/app/assets/stylesheets/govuk_publishing_components/components/_list.scss +1 -0
  24. data/app/assets/stylesheets/govuk_publishing_components/components/_radio.scss +4 -0
  25. data/app/assets/stylesheets/govuk_publishing_components/components/_related-navigation.scss +2 -2
  26. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +7 -3
  27. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-header.scss +0 -5
  28. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-related.scss +1 -4
  29. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss +8 -12
  30. data/app/assets/stylesheets/govuk_publishing_components/components/_table.scss +21 -24
  31. data/app/assets/stylesheets/govuk_publishing_components/components/_tabs.scss +4 -8
  32. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_attachment.scss +2 -0
  33. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_button.scss +1 -4
  34. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_charts.scss +6 -6
  35. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_contact.scss +2 -0
  36. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_footnotes.scss +2 -0
  37. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_highlight-answer.scss +2 -0
  38. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_place.scss +1 -1
  39. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_typography.scss +2 -0
  40. data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss +1 -1
  41. data/app/assets/stylesheets/govuk_publishing_components/components/print/_govspeak.scss +2 -0
  42. data/app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav-header.scss +0 -4
  43. data/app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav.scss +2 -10
  44. data/app/controllers/govuk_publishing_components/audit_controller.rb +52 -0
  45. data/app/controllers/govuk_publishing_components/component_guide_controller.rb +2 -1
  46. data/app/models/govuk_publishing_components/audit_applications.rb +117 -0
  47. data/app/models/govuk_publishing_components/audit_comparer.rb +198 -0
  48. data/app/models/govuk_publishing_components/audit_components.rb +158 -0
  49. data/app/views/govuk_publishing_components/audit/show.html.erb +258 -0
  50. data/app/views/govuk_publishing_components/component_guide/index.html.erb +9 -4
  51. data/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +1 -1
  52. data/app/views/govuk_publishing_components/components/_image_card.html.erb +1 -1
  53. data/app/views/govuk_publishing_components/components/_list.html.erb +26 -0
  54. data/app/views/govuk_publishing_components/components/_machine_readable_metadata.html.erb +1 -1
  55. data/app/views/govuk_publishing_components/components/_radio.html.erb +13 -5
  56. data/app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb +2 -2
  57. data/app/views/govuk_publishing_components/components/docs/checkboxes.yml +4 -0
  58. data/app/views/govuk_publishing_components/components/docs/govspeak.yml +45 -0
  59. data/app/views/govuk_publishing_components/components/docs/heading.yml +6 -3
  60. data/app/views/govuk_publishing_components/components/docs/image_card.yml +13 -1
  61. data/app/views/govuk_publishing_components/components/docs/list.yml +64 -0
  62. data/app/views/govuk_publishing_components/components/docs/radio.yml +4 -0
  63. data/config/routes.rb +1 -0
  64. data/lib/govuk_publishing_components/presenters/checkboxes_helper.rb +15 -7
  65. data/lib/govuk_publishing_components/presenters/heading_helper.rb +21 -1
  66. data/lib/govuk_publishing_components/presenters/image_card_helper.rb +2 -1
  67. data/lib/govuk_publishing_components/version.rb +1 -1
  68. data/node_modules/axe-core/package.json +145 -220
  69. data/node_modules/govuk-frontend/govuk/all.js +160 -57
  70. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +16 -8
  71. data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +6 -0
  72. data/node_modules/govuk-frontend/govuk/components/character-count/template.njk +1 -0
  73. data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +6 -5
  74. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +68 -21
  75. data/node_modules/govuk-frontend/govuk/components/date-input/macro-options.json +1 -1
  76. data/node_modules/govuk-frontend/govuk/components/file-upload/_index.scss +0 -27
  77. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +0 -3
  78. data/node_modules/govuk-frontend/govuk/components/footer/template.njk +1 -1
  79. data/node_modules/govuk-frontend/govuk/components/header/template.njk +1 -1
  80. data/node_modules/govuk-frontend/govuk/components/hint/_index.scss +2 -2
  81. data/node_modules/govuk-frontend/govuk/components/hint/template.njk +2 -2
  82. data/node_modules/govuk-frontend/govuk/components/input/_index.scss +0 -3
  83. data/node_modules/govuk-frontend/govuk/components/input/macro-options.json +6 -0
  84. data/node_modules/govuk-frontend/govuk/components/input/template.njk +1 -0
  85. data/node_modules/govuk-frontend/govuk/components/radios/radios.js +76 -28
  86. data/node_modules/govuk-frontend/govuk/components/select/_index.scss +0 -3
  87. data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +1 -0
  88. data/node_modules/govuk-frontend/govuk/components/textarea/_index.scss +0 -3
  89. data/node_modules/govuk-frontend/govuk/components/textarea/macro-options.json +6 -0
  90. data/node_modules/govuk-frontend/govuk/components/textarea/template.njk +1 -0
  91. data/node_modules/govuk-frontend/govuk/components/warning-text/_index.scss +4 -2
  92. data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +1 -1
  93. data/node_modules/govuk-frontend/govuk/settings/_colours-applied.scss +2 -2
  94. data/node_modules/govuk-frontend/govuk/settings/_colours-palette.scss +1 -1
  95. data/node_modules/govuk-frontend/govuk/settings/_measurements.scss +4 -1
  96. data/node_modules/govuk-frontend/package.json +14 -81
  97. data/node_modules/jquery/package.json +44 -116
  98. metadata +46 -66
  99. data/Rakefile +0 -32
@@ -2,12 +2,13 @@
2
2
 
3
3
  <div class="component-markdown">
4
4
  <p>Components are packages of template, style, behaviour and documentation that live in your application.</p>
5
- <p>A component must:</p>
5
+ <p>See the <a href="https://github.com/alphagov/govuk_publishing_components">govuk_publishing_components gem</a> for further details, or <a href="https://docs.publishing.service.gov.uk/manual/components.html#component-guides">a list of all component guides</a>.</p>
6
6
  <ul>
7
- <li><a href="https://github.com/alphagov/govuk_publishing_components/blob/master/docs/component_principles.md">meet the component principles</a></li>
8
- <li><a href="https://github.com/alphagov/govuk_publishing_components/blob/master/docs/component_conventions.md">follow component conventions</a></li>
7
+ <li>Read about how to <a href="https://github.com/alphagov/govuk_publishing_components/blob/master/docs/publishing-to-rubygems.md">release a new version of the gem</a></li>
8
+ <% if ENV["MAIN_COMPONENT_GUIDE"] %>
9
+ <li><a href="/component-guide/audit">View component audits</a></li>
10
+ <% end %>
9
11
  </ul>
10
- <p>See the <a href="https://github.com/alphagov/govuk_publishing_components">govuk_publishing_components gem</a> for further details, or <a href="https://docs.publishing.service.gov.uk/manual/components.html#component-guides">a list of all component guides</a>.</p>
11
12
  </div>
12
13
 
13
14
  <form role="search" data-module="filter-components" class="component-search">
@@ -86,3 +87,7 @@
86
87
  </li>
87
88
  <% end %>
88
89
  </ul>
90
+
91
+ <div class="component-markdown">
92
+ <p class="govuk-body">If you cannot find a suitable component consider extending an existing component or <a href="https://github.com/alphagov/govuk_publishing_components/blob/master/docs/develop-component.md">creating a new one</a>.</p>
93
+ </div>
@@ -10,7 +10,7 @@
10
10
  %>
11
11
 
12
12
  <script type="application/ld+json">
13
- <%= raw breadcrumb_presenter.structured_data.to_json %>
13
+ <%= raw JSON.pretty_generate(breadcrumb_presenter.structured_data) %>
14
14
  </script>
15
15
 
16
16
  <div class="<%= classes %>" data-module="track-click">
@@ -7,7 +7,7 @@
7
7
  <% if card_helper.href || card_helper.extra_links.any? %>
8
8
  <div class="gem-c-image-card <%= "gem-c-image-card--large" if card_helper.large %> <%= brand_helper.brand_class %>"
9
9
  <%= "data-module=track-click" if card_helper.is_tracking? %>
10
- >
10
+ <%= "lang=#{card_helper.lang}" if card_helper.lang %>>
11
11
  <%= card_helper.image %>
12
12
 
13
13
  <div class="gem-c-image-card__text-wrapper">
@@ -0,0 +1,26 @@
1
+ <%
2
+ id ||= nil
3
+ extra_spacing ||= nil
4
+ list_type ||= "unordered"
5
+ visible_counters ||= nil
6
+ items ||= []
7
+ aria_label ||= nil
8
+
9
+ classes = %w(gem-c-list govuk-list)
10
+ classes << "govuk-list--bullet" if visible_counters && list_type === "unordered"
11
+ classes << "govuk-list--number" if visible_counters && list_type === "number"
12
+ classes << "govuk-list--spaced" if extra_spacing
13
+
14
+ # Default list type is unordered list.
15
+ list_tag = "ul"
16
+
17
+ # Set to ordered list to override default.
18
+ list_tag = "ol" if list_type === "number"
19
+ %>
20
+ <% if items.any? %>
21
+ <%= content_tag list_tag, class: classes, id: id, "aria-label": aria_label do %>
22
+ <% items.each do |item| %>
23
+ <li><%= sanitize(item) %></li>
24
+ <% end %>
25
+ <% end %>
26
+ <% end %>
@@ -9,7 +9,7 @@
9
9
  <% structured_data = GovukPublishingComponents::Presenters::SchemaOrg.new(page).structured_data %>
10
10
 
11
11
  <script type="application/ld+json">
12
- <%= raw structured_data.to_json %>
12
+ <%= raw JSON.pretty_generate(structured_data) %>
13
13
  </script>
14
14
 
15
15
  <link rel="canonical" href="<%= page.canonical_url %>" />
@@ -6,10 +6,18 @@
6
6
  label ||= nil
7
7
  heading ||= nil
8
8
  heading_caption ||= nil
9
+ heading_size ||= nil
9
10
  small ||= false
10
11
  inline ||= false
11
12
  is_page_heading ||= false
12
- heading_size = 'm' unless ['s', 'm', 'l', 'xl'].include?(heading_size)
13
+
14
+ if ['s', 'm', 'l', 'xl'].include?(heading_size)
15
+ size = heading_size
16
+ elsif is_page_heading
17
+ size = 'xl'
18
+ else
19
+ size = 'm'
20
+ end
13
21
 
14
22
  description ||= nil
15
23
  hint ||= nil
@@ -28,7 +36,7 @@
28
36
  radio_classes << "govuk-radios--inline" if inline
29
37
 
30
38
  legend_classes = %w(govuk-fieldset__legend)
31
- legend_classes << "govuk-fieldset__legend--#{heading_size}"
39
+ legend_classes << "govuk-fieldset__legend--#{size}"
32
40
 
33
41
  aria = "#{hint_id} #{"#{error_id}" if has_error}".strip if hint or has_error
34
42
 
@@ -40,9 +48,9 @@
40
48
 
41
49
  <% if heading.present? %>
42
50
  <% if is_page_heading %>
43
- <%= tag.legend class: "govuk-fieldset__legend govuk-fieldset__legend--xl gem-c-title" do %>
44
- <%= tag.span(heading_caption, class: "govuk-caption-xl") if heading_caption.present? %>
45
- <%= tag.h1 heading, class: "gem-c-title__text" %>
51
+ <%= tag.legend class: legend_classes do %>
52
+ <%= tag.span(heading_caption, class: "govuk-caption-#{size}") if heading_caption.present? %>
53
+ <%= tag.h1 heading, class: "gem-c-radio__heading-text govuk-fieldset__heading" %>
46
54
  <% end %>
47
55
  <% else %>
48
56
  <%= tag.legend heading, class: legend_classes %>
@@ -25,14 +25,14 @@
25
25
  %>
26
26
  <% if title %>
27
27
  <script type="application/ld+json">
28
- <%= raw breadcrumb_presenter.structured_data.to_json %>
28
+ <%= raw JSON.pretty_generate(breadcrumb_presenter.structured_data) %>
29
29
  </script>
30
30
 
31
31
  <div class="<%= classes %>" data-module="track-click">
32
32
  <span class="gem-c-step-nav-header__part-of">Part of</span>
33
33
  <% if path %>
34
34
  <a href="<%= path %>"
35
- class="gem-c-step-nav-header__title"
35
+ class="gem-c-step-nav-header__title govuk-link"
36
36
  data-track-category="<%= tracking_category %>"
37
37
  data-track-action="<%= tracking_action %>"
38
38
  data-track-label="<%= tracking_label %>"
@@ -184,6 +184,10 @@ examples:
184
184
  - label: "Blue"
185
185
  value: "blue"
186
186
  with_custom_heading_size:
187
+ description: |
188
+ This allows the size of the legend to be changed. Valid options are s, m, l, xl, defaulting to m if no option is passed.
189
+
190
+ If the is_page_heading option is true and heading_size is not set, the text size will be xl.
187
191
  data:
188
192
  name: "favourite_colour"
189
193
  heading: "What is your favourite colour?"
@@ -190,6 +190,51 @@ examples:
190
190
  </tr>
191
191
  </tbody>
192
192
  </table>
193
+ chart_with_colours:
194
+ data:
195
+ block: |
196
+ <table class="js-barchart-table mc-auto-outdent">
197
+ <thead>
198
+ <tr>
199
+ <th scope="col">Number position</th>
200
+ <th scope="col">Apples</th>
201
+ <th scope="col">Oranges</th>
202
+ <th scope="col">Bananas</th>
203
+ <th scope="col">Pears</th>
204
+ <th scope="col">Grapes</th>
205
+ <th scope="col">Strawberries</th>
206
+ <th scope="col">Plums</th>
207
+ <th scope="col">Apricots</th>
208
+ <th scope="col">Pineapples</th>
209
+ </tr>
210
+ </thead>
211
+ <tbody>
212
+ <tr>
213
+ <td>Numbers inside bar</td>
214
+ <td>16</td>
215
+ <td>48</td>
216
+ <td>39</td>
217
+ <td>50</td>
218
+ <td>24</td>
219
+ <td>10</td>
220
+ <td>62</td>
221
+ <td>29</td>
222
+ <td>81</td>
223
+ </tr>
224
+ <tr>
225
+ <td>Numbers outside bar</td>
226
+ <td>2</td>
227
+ <td>1</td>
228
+ <td>2</td>
229
+ <td>1</td>
230
+ <td>1</td>
231
+ <td>3</td>
232
+ <td>3</td>
233
+ <td>1</td>
234
+ <td>2</td>
235
+ </tr>
236
+ </tbody>
237
+ </table>
193
238
  address:
194
239
  data:
195
240
  block: |
@@ -24,10 +24,13 @@ examples:
24
24
  text: 'Original consultation'
25
25
  heading_level: 3
26
26
  different_font_sizes:
27
- description: Choose a different font size. Valid options are 24 (24px) and 19 (19px), with the component defaulting to 27px, appropriate for a H1. This option is not tied to the heading_level option in order to give flexibility.
27
+ description: |
28
+ Set a different font size for the heading. Uses the [GOV.UK Frontend heading sizes](https://design-system.service.gov.uk/styles/typography/#headings) but defaults to 27px for legacy reasons. Valid options are `xl`, `l`, `m` and `s`.
29
+
30
+ This option is not tied to the heading_level option in order to give flexibility.
28
31
  data:
29
- text: 'Heading 3'
30
- font_size: 19
32
+ text: 'One big heading'
33
+ font_size: "xl"
31
34
  with_id_attribute:
32
35
  data:
33
36
  text: 'Detail of outcome'
@@ -9,6 +9,7 @@ accessibility_criteria: |
9
9
 
10
10
  - include alt text for images when present
11
11
  - not have duplicate links for the image and the text
12
+ - if the contents of the component are in a different language than the rest of the document, include an appropriate `lang` attribute to correctly identify the language used in the component
12
13
  shared_accessibility_criteria:
13
14
  - link
14
15
  examples:
@@ -191,7 +192,7 @@ examples:
191
192
  description: Can be used for links to people pages to indicate payment type
192
193
  data:
193
194
  href: "/government/people/"
194
- image_src: "http://placekitten.com/215/140"
195
+ image_src: "https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/62756/s300_courts-of-justice.JPG"
195
196
  image_alt: "some meaningful alt text please"
196
197
  context:
197
198
  text: "The Rt Hon"
@@ -204,3 +205,14 @@ examples:
204
205
  }
205
206
  ]
206
207
  extra_links_no_indent: true
208
+ with_lang:
209
+ description: |
210
+ Pass through an appropriate `lang` to set a HTML lang attribute for the component.
211
+
212
+ The `lang` attribute **must** be set to a [valid BCP47 string](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang#Language_tag_syntax). A valid code can be the two or three letter language code - for example, English is `en` or `eng`, Korean is `ko` or `kor` - but if in doubt please check.
213
+ data:
214
+ href: "/not-a-page"
215
+ image_src: "https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/62756/s300_courts-of-justice.JPG"
216
+ image_alt: "some meaningful alt text please"
217
+ heading_text: Yr hyn rydym ni'n ei wneud
218
+ lang: cy
@@ -0,0 +1,64 @@
1
+ name: List
2
+ description: A list - unordered or ordered, with or without counters / bullet points.
3
+ body: |
4
+ This is an ordered or unordered list, with or without visible bullets / numbers.
5
+
6
+ The `items` parameter can include HTML to display - such as links or another
7
+ list. This HTML can either be directly coded or come from another component.
8
+ accessibility_criteria: |
9
+ The list must:
10
+
11
+ - inform the user how many items are in the list
12
+ - convey the content structure
13
+ - indicate the current page when contents span different pages, and not link to itself
14
+
15
+ The list may:
16
+
17
+ - include an `aria-label` to contextualise the list if helpful
18
+ govuk_frontend_components:
19
+ - list
20
+ examples:
21
+ default:
22
+ description: "The default is an unordered list with no bullet points or numbers."
23
+ data: &default-example-data
24
+ items:
25
+ - "Tony&rsquo;s Chocolonely"
26
+ - '<a href="https://en.wikipedia.org/wiki/Cherry_Ripe_(chocolate_bar)" rel="noopener" class="govuk-link">Cherry Ripe</a>'
27
+ - "Snickers"
28
+ - "Chomp"
29
+ - "Penguin"
30
+ - "Boost"
31
+ unordered_list_with_aria-label:
32
+ description: "A list with an aria-label"
33
+ data:
34
+ aria_label: "A list of delicious chocolate bars."
35
+ <<: *default-example-data
36
+ unordered_list_with_bullet_points:
37
+ description: "An unordered list with visible bullet points."
38
+ data:
39
+ visible_counters: true
40
+ <<: *default-example-data
41
+ ordered_list_without_numbers:
42
+ description: "This is an ordered list where the numbers aren't visible."
43
+ data:
44
+ list_type: "number"
45
+ <<: *default-example-data
46
+ ordered_list_with_numbers:
47
+ description: |
48
+ This is an ordered list with the numbers visible.
49
+ data:
50
+ list_type: "number"
51
+ visible_counters: true
52
+ <<: *default-example-data
53
+ with_extra_spacing:
54
+ description: |
55
+ Increases the amount of spacing between the list items.
56
+ data:
57
+ extra_spacing: true
58
+ <<: *default-example-data
59
+ with_id_attribute:
60
+ description: |
61
+ Sets the `id` on the `ul` or `ol` element.
62
+ data:
63
+ id: 'super-fantastic-chocolate-list'
64
+ <<: *default-example-data
@@ -183,6 +183,10 @@ examples:
183
183
  - value: "blue"
184
184
  text: "Blue"
185
185
  with_custom_heading_size:
186
+ description: |
187
+ This allows the size of the legend to be changed. Valid options are s, m, l, xl, defaulting to m if no option is passed.
188
+
189
+ If the is_page_heading option is true and heading_size is not set, the text size will be xl.
186
190
  data:
187
191
  name: "radio-group-description"
188
192
  heading: "What is your favourite colour?"
@@ -1,4 +1,5 @@
1
1
  GovukPublishingComponents::Engine.routes.draw do
2
+ get "/audit" => "audit#show", as: :audit
2
3
  root to: "component_guide#index", as: :component_guide
3
4
  get ":component/preview" => "component_guide#preview", as: :component_preview_all
4
5
  get ":component/:example/preview" => "component_guide#preview", as: :component_preview
@@ -14,7 +14,6 @@ module GovukPublishingComponents
14
14
  :id,
15
15
  :hint_text,
16
16
  :description,
17
- :heading_size,
18
17
  :heading_caption,
19
18
  :has_exclusive
20
19
 
@@ -35,9 +34,8 @@ module GovukPublishingComponents
35
34
 
36
35
  @id = options[:id] || "checkboxes-#{SecureRandom.hex(4)}"
37
36
  @heading = options[:heading] || nil
38
- @heading_size = options[:heading_size]
39
- @heading_size = "m" unless %w[s m l xl].include?(@heading_size)
40
37
  @heading_caption = options[:heading_caption] || nil
38
+ @heading_size = options[:heading_size] || nil
41
39
  @is_page_heading = options[:is_page_heading]
42
40
  @description = options[:description] || nil
43
41
  @no_hint_text = options[:no_hint_text]
@@ -60,20 +58,30 @@ module GovukPublishingComponents
60
58
  end
61
59
  end
62
60
 
61
+ def size
62
+ if %w[s m l xl].include?(@heading_size)
63
+ @heading_size
64
+ elsif @is_page_heading
65
+ "xl"
66
+ else
67
+ "m"
68
+ end
69
+ end
70
+
63
71
  def heading_markup
64
72
  return unless @heading.present?
65
73
 
66
74
  if @is_page_heading
67
75
  content_tag(
68
76
  :legend,
69
- class: "govuk-fieldset__legend govuk-fieldset__legend--xl gem-c-title",
77
+ class: "govuk-fieldset__legend govuk-fieldset__legend--#{size}",
70
78
  ) do
71
- concat content_tag(:span, heading_caption, class: "govuk-caption-xl") if heading_caption.present?
72
- concat content_tag(:h1, @heading, class: "gem-c-title__text")
79
+ concat content_tag(:span, heading_caption, class: "govuk-caption-#{size}") if heading_caption.present?
80
+ concat content_tag(:h1, @heading, class: "gem-c-checkboxes__heading-text govuk-fieldset__heading")
73
81
  end
74
82
  else
75
83
  classes = %w[govuk-fieldset__legend]
76
- classes << "govuk-fieldset__legend--#{@heading_size}"
84
+ classes << "govuk-fieldset__legend--#{size}"
77
85
  classes << "gem-c-checkboxes__legend--hidden" if @visually_hide_heading
78
86
 
79
87
  content_tag(:legend, @heading, class: classes)
@@ -7,12 +7,32 @@ module GovukPublishingComponents
7
7
  @id = options[:id]
8
8
 
9
9
  @classes = ""
10
- @classes << " gem-c-heading--font-size-#{options[:font_size]}" if [24, 19].include? options[:font_size]
10
+ @classes << heading_size(options[:font_size])
11
11
  @classes << " gem-c-heading--mobile-top-margin" if options[:mobile_top_margin]
12
12
  @classes << " gem-c-heading--padding" if options[:padding]
13
13
  @classes << " gem-c-heading--border-top-#{options[:border_top]}" if [1, 2, 5].include? options[:border_top]
14
14
  @classes << " gem-c-heading--inverse" if options[:inverse]
15
15
  end
16
+
17
+ private
18
+
19
+ def heading_size(option)
20
+ gem_class = "gem-c-heading--font-size-"
21
+ govuk_class = "govuk-heading-"
22
+
23
+ case option
24
+ when "xl"
25
+ "#{govuk_class}xl"
26
+ when "l"
27
+ "#{govuk_class}l"
28
+ when 24, "m"
29
+ "#{govuk_class}m"
30
+ when 19, "s"
31
+ "#{govuk_class}s"
32
+ else
33
+ "#{gem_class}27"
34
+ end
35
+ end
16
36
  end
17
37
  end
18
38
  end
@@ -4,7 +4,7 @@ module GovukPublishingComponents
4
4
  include ActionView::Helpers
5
5
  include ActionView::Context
6
6
 
7
- attr_reader :href, :href_data_attributes, :extra_links, :large, :extra_links_no_indent, :heading_text, :metadata
7
+ attr_reader :href, :href_data_attributes, :extra_links, :large, :extra_links_no_indent, :heading_text, :metadata, :lang
8
8
 
9
9
  def initialize(local_assigns)
10
10
  @href = local_assigns[:href]
@@ -18,6 +18,7 @@ module GovukPublishingComponents
18
18
  @heading_text = local_assigns[:heading_text]
19
19
  @extra_links_no_indent = local_assigns[:extra_links_no_indent]
20
20
  @metadata = local_assigns[:metadata]
21
+ @lang = local_assigns[:lang]
21
22
  end
22
23
 
23
24
  def is_tracking?
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "21.57.1".freeze
2
+ VERSION = "21.60.2".freeze
3
3
  end