crown_marketplace_utils 0.1.0.beta.6 → 0.1.0.beta.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/accordion.rb +91 -89
  4. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/back_link.rb +24 -22
  5. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/breadcrumbs.rb +56 -54
  6. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/button.rb +109 -107
  7. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/details.rb +33 -31
  8. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/error_message.rb +49 -47
  9. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/character_count.rb +144 -142
  10. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/checkboxes.rb +176 -174
  11. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/date_input.rb +126 -124
  12. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/file_upload.rb +75 -73
  13. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/input.rb +137 -135
  14. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/radios.rb +176 -174
  15. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/select.rb +111 -109
  16. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/textarea.rb +86 -84
  17. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field.rb +181 -179
  18. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/fieldset.rb +56 -54
  19. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/form_group.rb +37 -35
  20. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/header.rb +142 -140
  21. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/hint.rb +25 -23
  22. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/label.rb +69 -67
  23. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/notification_banner.rb +121 -119
  24. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/pagination.rb +290 -288
  25. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/step_by_step_navigation.rb +187 -185
  26. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/tag.rb +29 -27
  27. data/lib/crown_marketplace_utils/helpers/gov_uk_helper/warning_text.rb +39 -37
  28. data/lib/crown_marketplace_utils/helpers/gov_uk_helper.rb +31 -29
  29. data/lib/crown_marketplace_utils/version.rb +1 -1
  30. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e73452d7763d7859ed777fcf3fcb1b1c94f29d1b7847296a103cac6b75cb5be4
4
- data.tar.gz: 9e68caffdbdaa5c2bd3c9b35cf867f59e2928945e74b0c537864bfe0441cd74b
3
+ metadata.gz: ab401ec177fe7672eec50c0bd05a41663ac0bd1b163f27ffd1112ac077d70af1
4
+ data.tar.gz: ddfdfaa105ff9c5680255d15bf9e2ce7924585c990cbcbd5fba6402c9539a9a9
5
5
  SHA512:
6
- metadata.gz: 972d9d7bf8c15f1408500948595155932dc99d24ed43565762ce3e0d0f3b695328834f1685aff46c90d21afa8fe6a298551d1e00162d05cc21a91971600065ff
7
- data.tar.gz: 16c588d4814694d494093134ff77098b0f1bf1a37ce019efeabef0780848cc17ea00bc6f356fa3206b668da507bf18038677152e21aad3d3c95dfd7eef775077
6
+ metadata.gz: 168c70a445d81be6119155c65715c522de6af4a6ef4e04cd8965f43db7bcb03fa4960ca8144c2d3d6edafe73273c680c99c205a07b1760b67e24d9d367091ed9
7
+ data.tar.gz: 8d070853427625e6e191d449cf4165d69573785b66580d29fa7dada93f1c85a49b1431853c3ab7d8a36b72d1f2fd919b208a5ecc9004978114ea694034d745f1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- crown_marketplace_utils (0.1.0.beta.6)
4
+ crown_marketplace_utils (0.1.0.beta.7)
5
5
  actionview (>= 6.0)
6
6
 
7
7
  GEM
@@ -2,112 +2,114 @@
2
2
 
3
3
  require 'action_view'
4
4
 
5
- module CrownMarketplaceUtils::Helpers
6
- module GovUkHelper
7
- # = GOV.UK Accordion
8
- #
9
- # This helper is used for generating the accordion component from the
10
- # {https://design-system.service.gov.uk/accordion/back-link GDS - Components - Accordion}
5
+ module CrownMarketplaceUtils
6
+ module Helpers
7
+ module GovUkHelper
8
+ # = GOV.UK Accordion
9
+ #
10
+ # This helper is used for generating the accordion component from the
11
+ # {https://design-system.service.gov.uk/accordion/back-link GDS - Components - Accordion}
11
12
 
12
- module Accordion
13
- include ActionView::Context
14
- include ActionView::Helpers::TagHelper
15
- include ActionView::Helpers::TextHelper
13
+ module Accordion
14
+ include ActionView::Context
15
+ include ActionView::Helpers::TagHelper
16
+ include ActionView::Helpers::TextHelper
16
17
 
17
- # Generates the HTML for the GOV.UK accordion component
18
- #
19
- # @param accordion_id [String] used as an id in the HTML for the accordion as a whole,
20
- # and also as a prefix for the ids of the section contents
21
- # and the buttons that open them
22
- # @param accordion_items [Array<Hash>] an array of accordion items.
23
- # See {#govuk_accordion_section} for details of the items in the array.
24
- # @param govuk_accordion_options [Hash] options that will be used in customising the HTML
25
- #
26
- # @option govuk_accordion_options [String] :classes additional CSS classes for the accordion HTML
27
- # @option govuk_accordion_options [Integer] :heading_level (2) heading level, from 1 to 6
28
- # @option govuk_accordion_options [Hash] :attributes ({ data: { module: 'govuk-accordion' } }) any additional
29
- # attributes that will added as part of the HTML
30
- #
31
- # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Accordion
32
- # which can then be rendered on the page
18
+ # Generates the HTML for the GOV.UK accordion component
19
+ #
20
+ # @param accordion_id [String] used as an id in the HTML for the accordion as a whole,
21
+ # and also as a prefix for the ids of the section contents
22
+ # and the buttons that open them
23
+ # @param accordion_items [Array<Hash>] an array of accordion items.
24
+ # See {#govuk_accordion_section} for details of the items in the array.
25
+ # @param govuk_accordion_options [Hash] options that will be used in customising the HTML
26
+ #
27
+ # @option govuk_accordion_options [String] :classes additional CSS classes for the accordion HTML
28
+ # @option govuk_accordion_options [Integer] :heading_level (2) heading level, from 1 to 6
29
+ # @option govuk_accordion_options [Hash] :attributes ({ data: { module: 'govuk-accordion' } }) any additional
30
+ # attributes that will added as part of the HTML
31
+ #
32
+ # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Accordion
33
+ # which can then be rendered on the page
33
34
 
34
- def govuk_accordion(accordion_id, accordion_items, **govuk_accordion_options)
35
- (govuk_accordion_options[:attributes] ||= {})[:data] ||= {}
36
- govuk_accordion_options[:attributes][:class] = "govuk-accordion #{govuk_accordion_options[:classes]}".rstrip
37
- govuk_accordion_options[:attributes][:id] = accordion_id
38
- govuk_accordion_options[:attributes][:data][:module] = 'govuk-accordion'
39
- govuk_accordion_options[:heading_level] ||= 2
35
+ def govuk_accordion(accordion_id, accordion_items, **govuk_accordion_options)
36
+ (govuk_accordion_options[:attributes] ||= {})[:data] ||= {}
37
+ govuk_accordion_options[:attributes][:class] = "govuk-accordion #{govuk_accordion_options[:classes]}".rstrip
38
+ govuk_accordion_options[:attributes][:id] = accordion_id
39
+ govuk_accordion_options[:attributes][:data][:module] = 'govuk-accordion'
40
+ govuk_accordion_options[:heading_level] ||= 2
40
41
 
41
- tag.div(**govuk_accordion_options[:attributes]) do
42
- capture do
43
- accordion_items.each.with_index(1) { |accordion_item, index| concat(govuk_accordion_section(accordion_id, accordion_item, index, govuk_accordion_options[:heading_level])) }
42
+ tag.div(**govuk_accordion_options[:attributes]) do
43
+ capture do
44
+ accordion_items.each.with_index(1) { |accordion_item, index| concat(govuk_accordion_section(accordion_id, accordion_item, index, govuk_accordion_options[:heading_level])) }
45
+ end
44
46
  end
45
47
  end
46
- end
47
48
 
48
- private
49
+ private
49
50
 
50
- # Generates the HTML for an accordion section, used by {govuk_accordion}
51
- #
52
- # @param accordion_id [String] used as an id in the HTML for the accordion
53
- # @param index [Integer] the index of the accordion item
54
- # @param heading_level [Integer] heading level, from 1 to 6
55
- #
56
- # @option accordion_item [Boolean] :expanded sets whether the section should be expanded
57
- # when the page loads for the first time.
58
- # @option accordion_item [String] :heading_level (2) Heading level, from 1 to 6
59
- # @option accordion_item [String] :heading the heading text for the accordion
60
- # @option accordion_item [String] :summary (nil) optional summary text for the accordion header
61
- # @option accordion_item [String, ActiveSupport::SafeBuffer] the content within the accordion section
62
- #
63
- # @return [ActiveSupport::SafeBuffer] the HTML for an accordion section
64
- # which is used in {govuk_accordion}
51
+ # Generates the HTML for an accordion section, used by {govuk_accordion}
52
+ #
53
+ # @param accordion_id [String] used as an id in the HTML for the accordion
54
+ # @param index [Integer] the index of the accordion item
55
+ # @param heading_level [Integer] heading level, from 1 to 6
56
+ #
57
+ # @option accordion_item [Boolean] :expanded sets whether the section should be expanded
58
+ # when the page loads for the first time.
59
+ # @option accordion_item [String] :heading_level (2) Heading level, from 1 to 6
60
+ # @option accordion_item [String] :heading the heading text for the accordion
61
+ # @option accordion_item [String] :summary (nil) optional summary text for the accordion header
62
+ # @option accordion_item [String, ActiveSupport::SafeBuffer] the content within the accordion section
63
+ #
64
+ # @return [ActiveSupport::SafeBuffer] the HTML for an accordion section
65
+ # which is used in {govuk_accordion}
65
66
 
66
- def govuk_accordion_section(accordion_id, accordion_item, index, heading_level)
67
- tag.div(class: "govuk-accordion__section #{'govuk-accordion__section--expanded' if accordion_item[:expanded]}".rstrip) do
68
- capture do
69
- concat(govuk_accordion_section_header(accordion_id, accordion_item, index, heading_level))
70
- concat(govuk_accordion_section_content(accordion_id, accordion_item, index))
67
+ def govuk_accordion_section(accordion_id, accordion_item, index, heading_level)
68
+ tag.div(class: "govuk-accordion__section #{'govuk-accordion__section--expanded' if accordion_item[:expanded]}".rstrip) do
69
+ capture do
70
+ concat(govuk_accordion_section_header(accordion_id, accordion_item, index, heading_level))
71
+ concat(govuk_accordion_section_content(accordion_id, accordion_item, index))
72
+ end
71
73
  end
72
74
  end
73
- end
74
75
 
75
- # Generates the HTML for an accordion section heading, used by {govuk_accordion_section}
76
- #
77
- # @param (see govuk_accordion_section)
78
- #
79
- # @option (see govuk_accordion_section)
80
- #
81
- # @return [ActiveSupport::SafeBuffer] the HTML for an accordion section heading
82
- # which is used in {govuk_accordion_section}
76
+ # Generates the HTML for an accordion section heading, used by {govuk_accordion_section}
77
+ #
78
+ # @param (see govuk_accordion_section)
79
+ #
80
+ # @option (see govuk_accordion_section)
81
+ #
82
+ # @return [ActiveSupport::SafeBuffer] the HTML for an accordion section heading
83
+ # which is used in {govuk_accordion_section}
83
84
 
84
- def govuk_accordion_section_header(accordion_id, accordion_item, index, heading_level)
85
- tag.div(class: 'govuk-accordion__section-header') do
86
- capture do
87
- concat(tag.send("h#{heading_level}", class: 'govuk-accordion__section-heading') do
88
- tag.span(accordion_item[:heading], class: 'govuk-accordion__section-button', id: "#{accordion_id}-heading-#{index}")
89
- end)
90
- concat(tag.div(accordion_item[:summary], class: 'govuk-accordion__section-summary govuk-body', id: "#{accordion_id}-summary-#{index}")) if accordion_item[:summary]
85
+ def govuk_accordion_section_header(accordion_id, accordion_item, index, heading_level)
86
+ tag.div(class: 'govuk-accordion__section-header') do
87
+ capture do
88
+ concat(tag.send("h#{heading_level}", class: 'govuk-accordion__section-heading') do
89
+ tag.span(accordion_item[:heading], class: 'govuk-accordion__section-button', id: "#{accordion_id}-heading-#{index}")
90
+ end)
91
+ concat(tag.div(accordion_item[:summary], class: 'govuk-accordion__section-summary govuk-body', id: "#{accordion_id}-summary-#{index}")) if accordion_item[:summary]
92
+ end
91
93
  end
92
94
  end
93
- end
94
95
 
95
- # Generates the HTML for an accordion sections content, used by {govuk_accordion_section}
96
- #
97
- # @param accordion_id [String] used as an id in the HTML for the accordion
98
- # @param index [Integer] the index of the accordion item
99
- #
100
- # @option (see govuk_accordion_section)
101
- #
102
- # @return [ActiveSupport::SafeBuffer] the HTML for an accordion sections content
103
- # which is used in {govuk_accordion_section}
96
+ # Generates the HTML for an accordion sections content, used by {govuk_accordion_section}
97
+ #
98
+ # @param accordion_id [String] used as an id in the HTML for the accordion
99
+ # @param index [Integer] the index of the accordion item
100
+ #
101
+ # @option (see govuk_accordion_section)
102
+ #
103
+ # @return [ActiveSupport::SafeBuffer] the HTML for an accordion sections content
104
+ # which is used in {govuk_accordion_section}
104
105
 
105
- def govuk_accordion_section_content(accordion_id, accordion_item, index)
106
- tag.div(class: 'govuk-accordion__section-content', id: "#{accordion_id}-content-#{index}", aria: { labelledby: "#{accordion_id}-heading-#{index}" }) do
107
- if accordion_item[:content].is_a? ActiveSupport::SafeBuffer
108
- accordion_item[:content]
109
- else
110
- tag.p(accordion_item[:content], class: 'govuk-body')
106
+ def govuk_accordion_section_content(accordion_id, accordion_item, index)
107
+ tag.div(class: 'govuk-accordion__section-content', id: "#{accordion_id}-content-#{index}", aria: { labelledby: "#{accordion_id}-heading-#{index}" }) do
108
+ if accordion_item[:content].is_a? ActiveSupport::SafeBuffer
109
+ accordion_item[:content]
110
+ else
111
+ tag.p(accordion_item[:content], class: 'govuk-body')
112
+ end
111
113
  end
112
114
  end
113
115
  end
@@ -2,32 +2,34 @@
2
2
 
3
3
  require 'action_view'
4
4
 
5
- module CrownMarketplaceUtils::Helpers
6
- module GovUkHelper
7
- # = GOV.UK Back Link
8
- #
9
- # This helper is used for generating the back link component from the
10
- # {https://design-system.service.gov.uk/components/back-link GDS - Components - Back link}
5
+ module CrownMarketplaceUtils
6
+ module Helpers
7
+ module GovUkHelper
8
+ # = GOV.UK Back Link
9
+ #
10
+ # This helper is used for generating the back link component from the
11
+ # {https://design-system.service.gov.uk/components/back-link GDS - Components - Back link}
11
12
 
12
- module BackLink
13
- include ActionView::Helpers::UrlHelper
13
+ module BackLink
14
+ include ActionView::Helpers::UrlHelper
14
15
 
15
- # Generates the HTML for the GOV.UK Back link component
16
- #
17
- # @param text [String] the text for the back link
18
- # @param href [String] the href for the back link
19
- # @param govuk_back_link_options [Hash] options that will be used in customising the HTML
20
- #
21
- # @option govuk_back_link_options [String] :classes additional CSS classes for the tag HTML
22
- # @option govuk_back_link_options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
23
- #
24
- # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Back link
25
- # which can then be rendered on the page
16
+ # Generates the HTML for the GOV.UK Back link component
17
+ #
18
+ # @param text [String] the text for the back link
19
+ # @param href [String] the href for the back link
20
+ # @param govuk_back_link_options [Hash] options that will be used in customising the HTML
21
+ #
22
+ # @option govuk_back_link_options [String] :classes additional CSS classes for the tag HTML
23
+ # @option govuk_back_link_options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
24
+ #
25
+ # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Back link
26
+ # which can then be rendered on the page
26
27
 
27
- def govuk_back_link(text, href, **govuk_back_link_options)
28
- govuk_back_link_options[:class] = "govuk-back-link #{govuk_back_link_options[:classes]}".rstrip
28
+ def govuk_back_link(text, href, **govuk_back_link_options)
29
+ govuk_back_link_options[:class] = "govuk-back-link #{govuk_back_link_options[:classes]}".rstrip
29
30
 
30
- link_to(text, href, class: govuk_back_link_options[:class], **(govuk_back_link_options[:attributes] || {}))
31
+ link_to(text, href, class: govuk_back_link_options[:class], **(govuk_back_link_options[:attributes] || {}))
32
+ end
31
33
  end
32
34
  end
33
35
  end
@@ -2,72 +2,74 @@
2
2
 
3
3
  require 'action_view'
4
4
 
5
- module CrownMarketplaceUtils::Helpers
6
- module GovUkHelper
7
- # = GOV.UK Breadcrumbs
8
- #
9
- # This helper is used for generating the breadcrumbs component from the
10
- # {https://design-system.service.gov.uk/components/breadcrumbs GDS - Components - Breadcrumbs}
5
+ module CrownMarketplaceUtils
6
+ module Helpers
7
+ module GovUkHelper
8
+ # = GOV.UK Breadcrumbs
9
+ #
10
+ # This helper is used for generating the breadcrumbs component from the
11
+ # {https://design-system.service.gov.uk/components/breadcrumbs GDS - Components - Breadcrumbs}
11
12
 
12
- module Breadcrumbs
13
- include ActionView::Context
14
- include ActionView::Helpers::TagHelper
15
- include ActionView::Helpers::TextHelper
16
- include ActionView::Helpers::UrlHelper
13
+ module Breadcrumbs
14
+ include ActionView::Context
15
+ include ActionView::Helpers::TagHelper
16
+ include ActionView::Helpers::TextHelper
17
+ include ActionView::Helpers::UrlHelper
17
18
 
18
- # Generates the HTML for the GOV.UK breadcrumbs component
19
- #
20
- # @param govuk_breadcrumb_items [Array<Hash>] An array of links for the breadcrumbs list. See {#govuk_breadcrumb_link} for details of the items in the array.
21
- # @param govuk_breadcrumbs_options [Hash] options that will be used in customising the HTML
22
- #
23
- # @option govuk_breadcrumbs_options [String] :classes additional CSS classes for the breadcrumbs HTML
24
- # @option govuk_breadcrumbs_options [Boolean] :collapse_on_mobile indicates if it is to colapse breadcrumbs on mobile
25
- # @option govuk_breadcrumbs_options [Hash] :attributes any additional attributes that will added as part of the HTML
26
- #
27
- # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Breadcrumbs
28
- # which can then be rendered on the page
19
+ # Generates the HTML for the GOV.UK breadcrumbs component
20
+ #
21
+ # @param govuk_breadcrumb_items [Array<Hash>] An array of links for the breadcrumbs list. See {#govuk_breadcrumb_link} for details of the items in the array.
22
+ # @param govuk_breadcrumbs_options [Hash] options that will be used in customising the HTML
23
+ #
24
+ # @option govuk_breadcrumbs_options [String] :classes additional CSS classes for the breadcrumbs HTML
25
+ # @option govuk_breadcrumbs_options [Boolean] :collapse_on_mobile indicates if it is to colapse breadcrumbs on mobile
26
+ # @option govuk_breadcrumbs_options [Hash] :attributes any additional attributes that will added as part of the HTML
27
+ #
28
+ # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Breadcrumbs
29
+ # which can then be rendered on the page
29
30
 
30
- def govuk_breadcrumbs(govuk_breadcrumb_items, **govuk_breadcrumbs_options)
31
- govuk_breadcrumbs_classes = ['govuk-breadcrumbs']
32
- govuk_breadcrumbs_classes << govuk_breadcrumbs_options[:classes]
33
- govuk_breadcrumbs_classes << 'govuk-breadcrumbs--collapse-on-mobile' if govuk_breadcrumbs_options[:collapse_on_mobile]
34
- govuk_breadcrumbs_options[:attributes] ||= {}
31
+ def govuk_breadcrumbs(govuk_breadcrumb_items, **govuk_breadcrumbs_options)
32
+ govuk_breadcrumbs_classes = ['govuk-breadcrumbs']
33
+ govuk_breadcrumbs_classes << govuk_breadcrumbs_options[:classes]
34
+ govuk_breadcrumbs_classes << 'govuk-breadcrumbs--collapse-on-mobile' if govuk_breadcrumbs_options[:collapse_on_mobile]
35
+ govuk_breadcrumbs_options[:attributes] ||= {}
35
36
 
36
- tag.div(class: govuk_breadcrumbs_classes, **govuk_breadcrumbs_options[:attributes]) do
37
- tag.ol(class: 'govuk-breadcrumbs__list') do
38
- capture do
39
- govuk_breadcrumb_items.each { |govuk_breadcrumb_item| concat(govuk_breadcrumb_link(govuk_breadcrumb_item)) }
37
+ tag.div(class: govuk_breadcrumbs_classes, **govuk_breadcrumbs_options[:attributes]) do
38
+ tag.ol(class: 'govuk-breadcrumbs__list') do
39
+ capture do
40
+ govuk_breadcrumb_items.each { |govuk_breadcrumb_item| concat(govuk_breadcrumb_link(govuk_breadcrumb_item)) }
41
+ end
40
42
  end
41
43
  end
42
44
  end
43
- end
44
45
 
45
- private
46
+ private
46
47
 
47
- # Generates the HTML for each link in the breadcrumbs.
48
- # It is called by {#govuk_breadcrumbs} which will pass in the breadcrum item.
49
- #
50
- # @param govuk_breadcrumb_item [Hash] a hash containg options for the breadcrumb item
51
- #
52
- # @option govuk_breadcrumb_item [String] :text the text for the link
53
- # @option govuk_breadcrumb_item [String] :href the URI for the link. If blank it is assumed that this item relates to current page
54
- # @option govuk_breadcrumb_item [Hash] :attributes any additional attributes that will added as part of the HTML.
55
- # If the link is blank then it defaults to +{ aria: { current: 'page' } }+
56
- #
57
- # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Breadcrumb list item
48
+ # Generates the HTML for each link in the breadcrumbs.
49
+ # It is called by {#govuk_breadcrumbs} which will pass in the breadcrum item.
50
+ #
51
+ # @param govuk_breadcrumb_item [Hash] a hash containg options for the breadcrumb item
52
+ #
53
+ # @option govuk_breadcrumb_item [String] :text the text for the link
54
+ # @option govuk_breadcrumb_item [String] :href the URI for the link. If blank it is assumed that this item relates to current page
55
+ # @option govuk_breadcrumb_item [Hash] :attributes any additional attributes that will added as part of the HTML.
56
+ # If the link is blank then it defaults to +{ aria: { current: 'page' } }+
57
+ #
58
+ # @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Breadcrumb list item
58
59
 
59
- def govuk_breadcrumb_link(govuk_breadcrumb_item)
60
- govuk_breadcrumb_item[:attributes] ||= {}
60
+ def govuk_breadcrumb_link(govuk_breadcrumb_item)
61
+ govuk_breadcrumb_item[:attributes] ||= {}
61
62
 
62
- if govuk_breadcrumb_item[:href].present?
63
- tag.li(class: 'govuk-breadcrumbs__list-item', **govuk_breadcrumb_item[:attributes]) do
64
- link_to govuk_breadcrumb_item[:text], govuk_breadcrumb_item[:href], class: 'govuk-breadcrumbs__link'
65
- end
66
- else
67
- (govuk_breadcrumb_item[:attributes][:aria] ||= {}).merge!({ current: 'page' })
63
+ if govuk_breadcrumb_item[:href].present?
64
+ tag.li(class: 'govuk-breadcrumbs__list-item', **govuk_breadcrumb_item[:attributes]) do
65
+ link_to govuk_breadcrumb_item[:text], govuk_breadcrumb_item[:href], class: 'govuk-breadcrumbs__link'
66
+ end
67
+ else
68
+ (govuk_breadcrumb_item[:attributes][:aria] ||= {}).merge!({ current: 'page' })
68
69
 
69
- tag.li(class: 'govuk-breadcrumbs__list-item', **govuk_breadcrumb_item[:attributes]) do
70
- govuk_breadcrumb_item[:text]
70
+ tag.li(class: 'govuk-breadcrumbs__list-item', **govuk_breadcrumb_item[:attributes]) do
71
+ govuk_breadcrumb_item[:text]
72
+ end
71
73
  end
72
74
  end
73
75
  end