govuk-components 4.1.0 → 4.1.1

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 (55) hide show
  1. checksums.yaml +4 -4
  2. data/app/components/govuk_component/accordion_component/section_component.html.erb +5 -5
  3. data/app/components/govuk_component/accordion_component/section_component.rb +1 -1
  4. data/app/components/govuk_component/accordion_component.rb +1 -1
  5. data/app/components/govuk_component/back_link_component.rb +2 -2
  6. data/app/components/govuk_component/base.rb +4 -0
  7. data/app/components/govuk_component/breadcrumbs_component.html.erb +1 -1
  8. data/app/components/govuk_component/breadcrumbs_component.rb +6 -6
  9. data/app/components/govuk_component/cookie_banner_component/message_component.rb +7 -7
  10. data/app/components/govuk_component/cookie_banner_component.rb +1 -1
  11. data/app/components/govuk_component/details_component.rb +5 -5
  12. data/app/components/govuk_component/exit_this_page_component.rb +3 -3
  13. data/app/components/govuk_component/footer_component.html.erb +11 -11
  14. data/app/components/govuk_component/footer_component.rb +7 -7
  15. data/app/components/govuk_component/header_component.html.erb +10 -10
  16. data/app/components/govuk_component/header_component.rb +8 -8
  17. data/app/components/govuk_component/inset_text_component.rb +1 -1
  18. data/app/components/govuk_component/notification_banner_component.html.erb +3 -3
  19. data/app/components/govuk_component/notification_banner_component.rb +5 -5
  20. data/app/components/govuk_component/pagination_component/adjacent_page.rb +6 -6
  21. data/app/components/govuk_component/pagination_component/item.rb +4 -4
  22. data/app/components/govuk_component/pagination_component/next_page.rb +1 -1
  23. data/app/components/govuk_component/pagination_component/previous_page.rb +1 -1
  24. data/app/components/govuk_component/pagination_component.rb +4 -4
  25. data/app/components/govuk_component/panel_component.rb +3 -3
  26. data/app/components/govuk_component/phase_banner_component.html.erb +2 -2
  27. data/app/components/govuk_component/phase_banner_component.rb +2 -2
  28. data/app/components/govuk_component/section_break_component.rb +3 -3
  29. data/app/components/govuk_component/start_button_component.rb +8 -10
  30. data/app/components/govuk_component/summary_list_component/action_component.rb +1 -1
  31. data/app/components/govuk_component/summary_list_component/card_component.html.erb +5 -5
  32. data/app/components/govuk_component/summary_list_component/card_component.rb +1 -1
  33. data/app/components/govuk_component/summary_list_component/key_component.rb +1 -1
  34. data/app/components/govuk_component/summary_list_component/row_component.rb +5 -5
  35. data/app/components/govuk_component/summary_list_component/value_component.rb +1 -1
  36. data/app/components/govuk_component/summary_list_component.rb +2 -2
  37. data/app/components/govuk_component/tab_component.html.erb +2 -2
  38. data/app/components/govuk_component/tab_component.rb +5 -5
  39. data/app/components/govuk_component/table_component/body_component.rb +1 -1
  40. data/app/components/govuk_component/table_component/caption_component.rb +2 -2
  41. data/app/components/govuk_component/table_component/cell_component.rb +12 -10
  42. data/app/components/govuk_component/table_component/foot_component.rb +1 -1
  43. data/app/components/govuk_component/table_component/head_component.rb +1 -1
  44. data/app/components/govuk_component/table_component/row_component.rb +1 -1
  45. data/app/components/govuk_component/table_component.rb +1 -1
  46. data/app/components/govuk_component/tag_component.rb +2 -2
  47. data/app/components/govuk_component/warning_text_component.rb +4 -4
  48. data/app/helpers/govuk_back_to_top_link_helper.rb +7 -1
  49. data/app/helpers/govuk_exit_this_page_link_helper.rb +8 -2
  50. data/app/helpers/govuk_link_helper.rb +38 -27
  51. data/app/helpers/govuk_skip_link_helper.rb +2 -2
  52. data/app/helpers/title_with_error_prefix_helper.rb +7 -0
  53. data/lib/govuk/components/engine.rb +4 -2
  54. data/lib/govuk/components/version.rb +1 -1
  55. metadata +15 -8
@@ -21,7 +21,7 @@ class GovukComponent::PanelComponent < GovukComponent::Base
21
21
  private
22
22
 
23
23
  def default_attributes
24
- { class: %w(govuk-panel govuk-panel--confirmation) }
24
+ { class: "#{brand}-panel #{brand}-panel--confirmation" }
25
25
  end
26
26
 
27
27
  def heading_tag
@@ -39,13 +39,13 @@ private
39
39
  def panel_title
40
40
  return if title.blank?
41
41
 
42
- content_tag(heading_tag, title, class: "govuk-panel__title")
42
+ content_tag(heading_tag, title, class: "#{brand}-panel__title")
43
43
  end
44
44
 
45
45
  def panel_body
46
46
  return if panel_content.blank?
47
47
 
48
- tag.div(class: "govuk-panel__body") do
48
+ tag.div(class: "#{brand}-panel__body") do
49
49
  panel_content
50
50
  end
51
51
  end
@@ -1,6 +1,6 @@
1
1
  <%= tag.div(**html_attributes) do %>
2
- <p class="govuk-phase-banner__content">
2
+ <p class="<%= brand %>-phase-banner__content">
3
3
  <%= render(phase_tag_component) %>
4
- <%= tag.span((content.presence || @text), class: "govuk-phase-banner__text") %>
4
+ <%= tag.span((content.presence || @text), class: "#{brand}-phase-banner__text") %>
5
5
  </p>
6
6
  <% end %>
@@ -14,12 +14,12 @@ class GovukComponent::PhaseBannerComponent < GovukComponent::Base
14
14
  end
15
15
 
16
16
  def phase_tag_component
17
- GovukComponent::TagComponent.new(**phase_tag.deep_merge(classes: "govuk-phase-banner__content__tag"))
17
+ GovukComponent::TagComponent.new(**phase_tag.deep_merge(classes: "#{brand}-phase-banner__content__tag"))
18
18
  end
19
19
 
20
20
  private
21
21
 
22
22
  def default_attributes
23
- { class: %w(govuk-phase-banner) }
23
+ { class: "#{brand}-phase-banner" }
24
24
  end
25
25
  end
@@ -27,9 +27,9 @@ private
27
27
 
28
28
  def default_classes
29
29
  class_names(
30
- "govuk-section-break",
30
+ "#{brand}-section-break",
31
31
  size_class,
32
- "govuk-section-break--visible" => visible?
32
+ "#{brand}-section-break--visible" => visible?
33
33
  ).split
34
34
  end
35
35
 
@@ -37,7 +37,7 @@ private
37
37
  if size.blank?
38
38
  ""
39
39
  elsif size.in?(SIZES)
40
- "govuk-section-break--#{size}"
40
+ "#{brand}-section-break--#{size}"
41
41
  else
42
42
  raise ArgumentError, "invalid size #{size}, supported sizes are #{SIZES.to_sentence}"
43
43
  end
@@ -1,11 +1,4 @@
1
1
  class GovukComponent::StartButtonComponent < GovukComponent::Base
2
- BUTTON_ATTRIBUTES = {
3
- draggable: 'false',
4
- data: { module: 'govuk-button' }
5
- }.freeze
6
-
7
- LINK_ATTRIBUTES = BUTTON_ATTRIBUTES.merge({ role: 'button' }).freeze
8
-
9
2
  attr_reader :text, :href, :as_button
10
3
 
11
4
  def initialize(text:, href:, as_button: config.default_start_button_as_button, classes: [], html_attributes: {})
@@ -31,8 +24,13 @@ class GovukComponent::StartButtonComponent < GovukComponent::Base
31
24
  private
32
25
 
33
26
  def default_attributes
34
- (as_button ? BUTTON_ATTRIBUTES : LINK_ATTRIBUTES)
35
- .merge({ class: %w(govuk-button govuk-button--start) })
27
+ attrs = {
28
+ class: ["#{brand}-button", "#{brand}-button--start"],
29
+ data: { module: "#{brand}-button" },
30
+ draggable: 'false',
31
+ }
32
+ attrs.merge!(role: 'button') unless as_button
33
+ attrs
36
34
  end
37
35
 
38
36
  def icon
@@ -43,7 +41,7 @@ private
43
41
 
44
42
  def svg_attributes
45
43
  {
46
- class: "govuk-button__start-icon",
44
+ class: "#{brand}-button__start-icon",
47
45
  xmlns: "http://www.w3.org/2000/svg",
48
46
  width: "17.5",
49
47
  height: "19",
@@ -37,6 +37,6 @@ private
37
37
  end
38
38
 
39
39
  def visually_hidden_span
40
- tag.span(%( #{visually_hidden_text}), class: "govuk-visually-hidden") if visually_hidden_text.present?
40
+ tag.span(%( #{visually_hidden_text}), class: "#{brand}-visually-hidden") if visually_hidden_text.present?
41
41
  end
42
42
  end
@@ -1,16 +1,16 @@
1
1
  <%= tag.div(**html_attributes) do %>
2
- <div class="govuk-summary-card__title-wrapper">
3
- <%= tag.h2(title, class: "govuk-summary-card__title") %>
2
+ <div class="<%= brand %>-summary-card__title-wrapper">
3
+ <%= tag.h2(title, class: "#{brand}-summary-card__title") %>
4
4
 
5
5
  <% if actions.any? %>
6
- <ul class="govuk-summary-card__actions">
6
+ <ul class="<%= brand %>-summary-card__actions">
7
7
  <% actions.each do |action| %>
8
- <%= tag.li(action, class: "govuk-summary-card__action") %>
8
+ <%= tag.li(action, class: "#{brand}-summary-card__action") %>
9
9
  <% end %>
10
10
  </ul>
11
11
  <% end %>
12
12
  </div>
13
- <div class="govuk-summary-card__content">
13
+ <div class="<%= brand %>-summary-card__content">
14
14
  <%= summary_list || content %>
15
15
  </div>
16
16
  <% end %>
@@ -14,6 +14,6 @@ class GovukComponent::SummaryListComponent::CardComponent < GovukComponent::Base
14
14
  private
15
15
 
16
16
  def default_attributes
17
- { class: %w(govuk-summary-card) }
17
+ { class: "#{brand}-summary-card" }
18
18
  end
19
19
  end
@@ -14,7 +14,7 @@ class GovukComponent::SummaryListComponent::KeyComponent < GovukComponent::Base
14
14
  private
15
15
 
16
16
  def default_attributes
17
- { class: %w(govuk-summary-list__key) }
17
+ { class: "#{brand}-summary-list__key" }
18
18
  end
19
19
 
20
20
  def key_content
@@ -37,21 +37,21 @@ private
37
37
 
38
38
  def actions_list
39
39
  tag.dd(class: actions_class) do
40
- tag.ul(class: "govuk-summary-list__actions-list") do
41
- safe_join(actions.map { |action| tag.li(action, class: "govuk-summary-list__actions-list-item") })
40
+ tag.ul(class: "#{brand}-summary-list__actions-list") do
41
+ safe_join(actions.map { |action| tag.li(action, class: "#{brand}-summary-list__actions-list-item") })
42
42
  end
43
43
  end
44
44
  end
45
45
 
46
46
  def default_attributes
47
- { class: %w(govuk-summary-list__row) }
47
+ { class: "#{brand}-summary-list__row" }
48
48
  end
49
49
 
50
50
  def actions_class
51
- "govuk-summary-list__actions"
51
+ "#{brand}-summary-list__actions"
52
52
  end
53
53
 
54
54
  def no_actions_class
55
- "govuk-summary-list__row--no-actions"
55
+ "#{brand}-summary-list__row--no-actions"
56
56
  end
57
57
  end
@@ -14,7 +14,7 @@ class GovukComponent::SummaryListComponent::ValueComponent < GovukComponent::Bas
14
14
  private
15
15
 
16
16
  def default_attributes
17
- { class: %w(govuk-summary-list__value) }
17
+ { class: "#{brand}-summary-list__value" }
18
18
  end
19
19
 
20
20
  def value_content
@@ -39,11 +39,11 @@ module GovukComponent
39
39
  end
40
40
 
41
41
  def borders_class
42
- %(govuk-summary-list--no-border) unless borders
42
+ "#{brand}-summary-list--no-border" unless borders
43
43
  end
44
44
 
45
45
  def default_attributes
46
- { class: ["govuk-summary-list", borders_class].compact }
46
+ { class: ["#{brand}-summary-list", borders_class].compact }
47
47
  end
48
48
 
49
49
  def build(rows)
@@ -1,6 +1,6 @@
1
1
  <%= tag.div(**html_attributes) do %>
2
- <%= tag.h2(title, class: "govuk-tabs__title") %>
3
- <ul class="govuk-tabs__list">
2
+ <%= tag.h2(title, class: "#{brand}-tabs__title") %>
3
+ <ul class="<%= brand %>-tabs__list">
4
4
  <% tabs.each.with_index do |tab, i| %>
5
5
  <%= tag.li(tab.li_link, class: tab.li_classes(i)) %>
6
6
  <% end %>
@@ -15,7 +15,7 @@ class GovukComponent::TabComponent < GovukComponent::Base
15
15
  private
16
16
 
17
17
  def default_attributes
18
- { id: id, class: %w(govuk-tabs), data: { module: 'govuk-tabs' } }
18
+ { id: id, class: "#{brand}-tabs", data: { module: "#{brand}-tabs" } }
19
19
  end
20
20
 
21
21
  class Tab < GovukComponent::Base
@@ -35,19 +35,19 @@ private
35
35
  def hidden_class(i = nil)
36
36
  return [] if i&.zero?
37
37
 
38
- %w(govuk-tabs__panel--hidden)
38
+ ["#{brand}-tabs__panel--hidden"]
39
39
  end
40
40
 
41
41
  def li_classes(i = nil)
42
- class_names("govuk-tabs__list-item", "govuk-tabs__list-item--selected" => i&.zero?).split
42
+ class_names("#{brand}-tabs__list-item", "#{brand}-tabs__list-item--selected" => i&.zero?).split
43
43
  end
44
44
 
45
45
  def li_link
46
- link_to(label, id(prefix: '#'), class: "govuk-tabs__tab")
46
+ link_to(label, id(prefix: '#'), class: "#{brand}-tabs__tab")
47
47
  end
48
48
 
49
49
  def default_attributes
50
- { id: id, class: %w(govuk-tabs__panel) }
50
+ { id: id, class: "#{brand}-tabs__panel" }
51
51
  end
52
52
 
53
53
  def combined_attributes(i)
@@ -28,6 +28,6 @@ private
28
28
  end
29
29
 
30
30
  def default_attributes
31
- { class: %w(govuk-table__body) }
31
+ { class: "#{brand}-table__body" }
32
32
  end
33
33
  end
@@ -26,12 +26,12 @@ private
26
26
  end
27
27
 
28
28
  def default_attributes
29
- { class: class_names("govuk-table__caption", caption_size_class => size).split }
29
+ { class: class_names("#{brand}-table__caption", caption_size_class => size).split }
30
30
  end
31
31
 
32
32
  def caption_size_class
33
33
  fail(ArgumentError, "bad size #{size}, must be in #{SIZES}") unless size.in?(SIZES)
34
34
 
35
- %(govuk-table__caption--#{size})
35
+ "#{brand}-table__caption--#{size}"
36
36
  end
37
37
  end
@@ -4,14 +4,16 @@ class GovukComponent::TableComponent::CellComponent < GovukComponent::Base
4
4
  alias_method :numeric?, :numeric
5
5
  alias_method :header?, :header
6
6
 
7
- WIDTHS = {
8
- "full" => "govuk-!-width-full",
9
- "three-quarters" => "govuk-!-width-three-quarters",
10
- "two-thirds" => "govuk-!-width-two-thirds",
11
- "one-half" => "govuk-!-width-one-half",
12
- "one-third" => "govuk-!-width-one-third",
13
- "one-quarter" => "govuk-!-width-one-quarter",
14
- }.freeze
7
+ def self.widths
8
+ {
9
+ "full" => "#{brand}-!-width-full",
10
+ "three-quarters" => "#{brand}-!-width-three-quarters",
11
+ "two-thirds" => "#{brand}-!-width-two-thirds",
12
+ "one-half" => "#{brand}-!-width-one-half",
13
+ "one-third" => "#{brand}-!-width-one-third",
14
+ "one-quarter" => "#{brand}-!-width-one-quarter",
15
+ }.freeze
16
+ end
15
17
 
16
18
  def initialize(scope: nil, header: nil, numeric: false, text: nil, width: nil, parent: nil, rowspan: nil, colspan: nil, classes: [], html_attributes: {})
17
19
  @text = text
@@ -71,8 +73,8 @@ private
71
73
 
72
74
  def default_classes
73
75
  class_names(
74
- "govuk-table__#{class_suffix}",
75
- "govuk-table__#{class_suffix}--numeric" => numeric?,
76
+ "#{brand}-table__#{class_suffix}",
77
+ "#{brand}-table__#{class_suffix}--numeric" => numeric?,
76
78
  width => width?,
77
79
  )
78
80
  end
@@ -39,6 +39,6 @@ private
39
39
  end
40
40
 
41
41
  def default_attributes
42
- { class: %w(govuk-table__foot) }
42
+ { class: "#{brand}-table__foot" }
43
43
  end
44
44
  end
@@ -29,6 +29,6 @@ private
29
29
  end
30
30
 
31
31
  def default_attributes
32
- { class: %w(govuk-table__head) }
32
+ { class: "#{brand}-table__head" }
33
33
  end
34
34
  end
@@ -68,7 +68,7 @@ private
68
68
  end
69
69
 
70
70
  def default_attributes
71
- { class: %w(govuk-table__row) }
71
+ { class: "#{brand}-table__row" }
72
72
  end
73
73
 
74
74
  def in_thead?
@@ -37,7 +37,7 @@ module GovukComponent
37
37
  end
38
38
 
39
39
  def default_attributes
40
- { id: id, class: %w(govuk-table) }
40
+ { id: id, class: "#{brand}-table" }
41
41
  end
42
42
  end
43
43
  end
@@ -22,7 +22,7 @@ private
22
22
 
23
23
  def default_attributes
24
24
  {
25
- class: ["govuk-tag", colour_class]
25
+ class: ["#{brand}-tag", colour_class]
26
26
  }
27
27
  end
28
28
 
@@ -31,7 +31,7 @@ private
31
31
 
32
32
  fail(ArgumentError, colour_error_message) unless valid_colour?
33
33
 
34
- %(govuk-tag--#{colour})
34
+ "#{brand}-tag--#{colour}"
35
35
  end
36
36
 
37
37
  def valid_colour?
@@ -18,20 +18,20 @@ class GovukComponent::WarningTextComponent < GovukComponent::Base
18
18
  private
19
19
 
20
20
  def icon_element
21
- tag.span(icon, class: 'govuk-warning-text__icon', aria: { hidden: true })
21
+ tag.span(icon, class: "#{brand}-warning-text__icon", aria: { hidden: true })
22
22
  end
23
23
 
24
24
  def warning_text
25
- tag.strong(class: 'govuk-warning-text__text') do
25
+ tag.strong(class: "#{brand}-warning-text__text") do
26
26
  safe_join([assistive, (content || text)])
27
27
  end
28
28
  end
29
29
 
30
30
  def assistive
31
- tag.span(icon_fallback_text, class: 'govuk-warning-text__assistive')
31
+ tag.span(icon_fallback_text, class: "#{brand}-warning-text__assistive")
32
32
  end
33
33
 
34
34
  def default_attributes
35
- { class: %w(govuk-warning-text) }
35
+ { class: "#{brand}-warning-text" }
36
36
  end
37
37
  end
@@ -1,6 +1,6 @@
1
1
  module GovukBackToTopLinkHelper
2
2
  def govuk_back_to_top_link(target = '#top')
3
- link_to(target, class: 'govuk-link govuk-link--no-visited-state') do
3
+ link_to(target, class: "#{brand}-link #{brand}-link--no-visited-state") do
4
4
  <<-HTML.squish.html_safe
5
5
  <svg class="app-back-to-top__icon" xmlns="http://www.w3.org/2000/svg" width="13" height="17" viewBox="0 0 13 17">
6
6
  <path fill="currentColor" d="M6.5 0L0 6.5 1.4 8l4-4v12.7h2V4l4.3 4L13 6.4z"></path>
@@ -9,6 +9,12 @@ module GovukBackToTopLinkHelper
9
9
  HTML
10
10
  end
11
11
  end
12
+
13
+ private
14
+
15
+ def brand
16
+ Govuk::Components.brand
17
+ end
12
18
  end
13
19
 
14
20
  ActiveSupport.on_load(:action_view) { include GovukBackToTopLinkHelper }
@@ -6,12 +6,18 @@ module GovukExitThisPageLinkHelper
6
6
  **html_attributes,
7
7
  &block
8
8
  )
9
- link_classes = Array.wrap(classes).append(%w(govuk-skip-link govuk-js-exit-this-page-skiplink))
9
+ link_classes = Array.wrap(classes).append(["#{brand}-skip-link", "#{brand}-js-exit-this-page-skiplink"])
10
10
 
11
- html_attributes_with_data_module = { data: { module: "govuk-skip-link" } }.deep_merge(html_attributes)
11
+ html_attributes_with_data_module = { data: { module: "#{brand}-skip-link" } }.deep_merge(html_attributes)
12
12
 
13
13
  link_to(text, href, class: link_classes, **html_attributes_with_data_module, &block)
14
14
  end
15
+
16
+ private
17
+
18
+ def brand
19
+ Govuk::Components.brand
20
+ end
15
21
  end
16
22
 
17
23
  ActiveSupport.on_load(:action_view) { include GovukExitThisPageLinkHelper }
@@ -3,35 +3,20 @@ require "html_attributes_utils"
3
3
  module GovukLinkHelper
4
4
  using HTMLAttributesUtils
5
5
 
6
- LINK_STYLES = {
7
- inverse: "govuk-link--inverse",
8
- muted: "govuk-link--muted",
9
- no_underline: "govuk-link--no-underline",
10
- no_visited_state: "govuk-link--no-visited-state",
11
- text_colour: "govuk-link--text-colour",
12
- }.freeze
13
-
14
- BUTTON_STYLES = {
15
- disabled: "govuk-button--disabled",
16
- secondary: "govuk-button--secondary",
17
- warning: "govuk-button--warning",
18
- inverse: "govuk-button--inverse",
19
- }.freeze
20
-
21
- def govuk_link_classes(*styles, default_class: 'govuk-link')
22
- if (invalid_styles = (styles - LINK_STYLES.keys)) && invalid_styles.any?
23
- fail(ArgumentError, "invalid styles #{invalid_styles.to_sentence}. Valid styles are #{LINK_STYLES.keys.to_sentence}")
6
+ def govuk_link_classes(*styles, default_class: "#{brand}-link")
7
+ if (invalid_styles = (styles - link_styles.keys)) && invalid_styles.any?
8
+ fail(ArgumentError, "invalid styles #{invalid_styles.to_sentence}. Valid styles are #{link_styles.keys.to_sentence}")
24
9
  end
25
10
 
26
- [default_class] + LINK_STYLES.values_at(*styles).compact
11
+ [default_class] + link_styles.values_at(*styles).compact
27
12
  end
28
13
 
29
- def govuk_button_classes(*styles, default_class: 'govuk-button')
30
- if (invalid_styles = (styles - BUTTON_STYLES.keys)) && invalid_styles.any?
31
- fail(ArgumentError, "invalid styles #{invalid_styles.to_sentence}. Valid styles are #{BUTTON_STYLES.keys.to_sentence}")
14
+ def govuk_button_classes(*styles, default_class: "#{brand}-button")
15
+ if (invalid_styles = (styles - button_styles.keys)) && invalid_styles.any?
16
+ fail(ArgumentError, "invalid styles #{invalid_styles.to_sentence}. Valid styles are #{button_styles.keys.to_sentence}")
32
17
  end
33
18
 
34
- [default_class] + BUTTON_STYLES.values_at(*styles).compact
19
+ [default_class] + button_styles.values_at(*styles).compact
35
20
  end
36
21
 
37
22
  def govuk_link_to(name = nil, options = nil, extra_options = {}, &block)
@@ -69,8 +54,11 @@ module GovukLinkHelper
69
54
 
70
55
  def govuk_button_link_to(name = nil, options = nil, extra_options = {}, &block)
71
56
  extra_options = options if block_given?
72
- html_options = GovukComponent::StartButtonComponent::LINK_ATTRIBUTES
73
- .merge build_html_options(extra_options, style: :button)
57
+ html_options = {
58
+ data: { module: "#{brand}-button" },
59
+ draggable: 'false',
60
+ role: 'button',
61
+ }.merge build_html_options(extra_options, style: :button)
74
62
 
75
63
  if block_given?
76
64
  link_to(name, html_options, &block)
@@ -92,8 +80,31 @@ module GovukLinkHelper
92
80
 
93
81
  private
94
82
 
83
+ def brand
84
+ Govuk::Components.brand
85
+ end
86
+
87
+ def link_styles
88
+ {
89
+ inverse: "#{brand}-link--inverse",
90
+ muted: "#{brand}-link--muted",
91
+ no_underline: "#{brand}-link--no-underline",
92
+ no_visited_state: "#{brand}-link--no-visited-state",
93
+ text_colour: "#{brand}-link--text-colour",
94
+ }
95
+ end
96
+
97
+ def button_styles
98
+ {
99
+ disabled: "#{brand}-button--disabled",
100
+ secondary: "#{brand}-button--secondary",
101
+ warning: "#{brand}-button--warning",
102
+ inverse: "#{brand}-button--inverse",
103
+ }
104
+ end
105
+
95
106
  def build_html_options(provided_options, style: :link)
96
- element_styles = { link: LINK_STYLES, button: BUTTON_STYLES }.fetch(style, {})
107
+ element_styles = { link: link_styles, button: button_styles }.fetch(style, {})
97
108
 
98
109
  # we need to take a couple of extra steps here because we don't want the style
99
110
  # params (inverse, muted, etc) to end up as extra attributes on the link.
@@ -111,7 +122,7 @@ private
111
122
  case style
112
123
  when :link then govuk_link_classes(*keys)
113
124
  when :button then govuk_button_classes(*keys)
114
- when :breadcrumb then %w(govuk-breadcrumbs__link)
125
+ when :breadcrumb then "#{brand}-breadcrumbs__link"
115
126
  end
116
127
  end
117
128
 
@@ -1,8 +1,8 @@
1
1
  module GovukSkipLinkHelper
2
2
  def govuk_skip_link(text: 'Skip to main content', href: '#main-content', classes: [], **html_attributes, &block)
3
- link_classes = Array.wrap(classes).append('govuk-skip-link')
3
+ link_classes = Array.wrap(classes).append("#{brand}-skip-link")
4
4
 
5
- html_attributes_with_data_module = { data: { module: "govuk-skip-link" } }.deep_merge(html_attributes)
5
+ html_attributes_with_data_module = { data: { module: "#{brand}-skip-link" } }.deep_merge(html_attributes)
6
6
 
7
7
  return link_to(href, class: link_classes, **html_attributes_with_data_module, &block) if block_given?
8
8
 
@@ -0,0 +1,7 @@
1
+ module TitleWithErrorPrefixHelper
2
+ def title_with_error_prefix(title, error:, error_prefix: Govuk::Components.config.default_error_prefix)
3
+ "#{error_prefix if error}#{title}"
4
+ end
5
+ end
6
+
7
+ ActiveSupport.on_load(:action_view) { include TitleWithErrorPrefixHelper }
@@ -32,11 +32,13 @@ module Govuk
32
32
  #
33
33
  # Default components configuration
34
34
  #
35
+ # +:brand+ sets the value used to prefix all classes, used to allow the components to be branded for alternative (similar) design systems
35
36
  # +:default_back_link_text+ Default text for the back link, defaults to +Back+
36
37
  # +:default_breadcrumbs_collapse_on_mobile+ false
37
38
  # +:default_breadcrumbs_hide_in_print+ false
38
39
  # +:default_cookie_banner_aria_label+ "Cookie banner"
39
40
  # +:default_cookie_banner_hide_in_print+ true
41
+ # +:default_error_prefix+ Text to use at the start of the page title tag when there is an error on the page. Default is 'Error: '
40
42
  # +:default_exit_this_page_redirect_url+ The URL that the exit this page component links to by default. Defaults to https://www.bbc.co.uk/weather
41
43
  # +:default_exit_this_page_text+ The default text that forms the link. Defaults to 'Exit this page'
42
44
  # +:default_exit_this_page_activated_text+ Text announced by screen readers when Exit this Page has been activated via the keyboard shortcut. Default in govuk-frontend is 'Exiting page.' Defaults to nil so govuk-frontend value is used unless overridden.
@@ -72,11 +74,13 @@ module Govuk
72
74
  # +:require_summary_list_action_visually_hidden_text+ when true forces visually hidden text to be set for every action. It can still be explicitly skipped by passing in +nil+. Defaults to +false+
73
75
  # +:enable_auto_table_scopes+ automatically adds a scope of 'col' to th elements in thead and 'row' to th elements in tbody.
74
76
  DEFAULTS = {
77
+ brand: 'govuk',
75
78
  default_back_link_text: 'Back',
76
79
  default_breadcrumbs_collapse_on_mobile: false,
77
80
  default_breadcrumbs_hide_in_print: false,
78
81
  default_cookie_banner_aria_label: "Cookie banner",
79
82
  default_cookie_banner_hide_in_print: true,
83
+ default_error_prefix: "Error: ",
80
84
  default_exit_this_page_redirect_url: "https://www.bbc.co.uk/weather",
81
85
  default_exit_this_page_text: "Exit this page",
82
86
  default_exit_this_page_activated_text: nil,
@@ -108,9 +112,7 @@ module Govuk
108
112
  default_notification_title_success: false,
109
113
  default_warning_text_icon_fallback_text: "Warning",
110
114
  default_warning_text_icon: "!",
111
-
112
115
  default_link_new_tab_text: "(opens in new tab)",
113
-
114
116
  require_summary_list_action_visually_hidden_text: false,
115
117
  enable_auto_table_scopes: true,
116
118
  }.freeze
@@ -1,5 +1,5 @@
1
1
  module Govuk
2
2
  module Components
3
- VERSION = '4.1.0'.freeze
3
+ VERSION = '4.1.1'.freeze
4
4
  end
5
5
  end