crown_marketplace_utils 0.1.0.beta.5 → 0.1.0.beta.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +10 -10
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/accordion.rb +91 -89
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/back_link.rb +24 -22
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/breadcrumbs.rb +56 -54
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/button.rb +109 -107
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/details.rb +33 -31
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/error_message.rb +49 -47
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/character_count.rb +144 -142
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/checkboxes.rb +176 -174
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/date_input.rb +126 -124
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/file_upload.rb +75 -73
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/input.rb +137 -135
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/radios.rb +176 -174
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/select.rb +111 -109
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field/textarea.rb +86 -84
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/field.rb +181 -179
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/fieldset.rb +56 -54
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/form_group.rb +37 -35
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/header.rb +142 -140
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/hint.rb +25 -23
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/label.rb +69 -67
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/notification_banner.rb +121 -119
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/pagination.rb +290 -288
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/step_by_step_navigation.rb +187 -185
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/tag.rb +29 -27
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper/warning_text.rb +39 -37
- data/lib/crown_marketplace_utils/helpers/gov_uk_helper.rb +31 -29
- data/lib/crown_marketplace_utils/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab401ec177fe7672eec50c0bd05a41663ac0bd1b163f27ffd1112ac077d70af1
|
4
|
+
data.tar.gz: ddfdfaa105ff9c5680255d15bf9e2ce7924585c990cbcbd5fba6402c9539a9a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
4
|
+
crown_marketplace_utils (0.1.0.beta.7)
|
5
5
|
actionview (>= 6.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -118,7 +118,7 @@ GEM
|
|
118
118
|
nokogiri (1.13.9-x86_64-linux)
|
119
119
|
racc (~> 1.4)
|
120
120
|
parallel (1.22.1)
|
121
|
-
parser (3.
|
121
|
+
parser (3.2.0.0)
|
122
122
|
ast (~> 2.4.1)
|
123
123
|
public_suffix (5.0.0)
|
124
124
|
racc (1.6.0)
|
@@ -168,32 +168,32 @@ GEM
|
|
168
168
|
diff-lcs (>= 1.2.0, < 2.0)
|
169
169
|
rspec-support (~> 3.12.0)
|
170
170
|
rspec-support (3.12.0)
|
171
|
-
rubocop (1.
|
171
|
+
rubocop (1.43.0)
|
172
172
|
json (~> 2.3)
|
173
173
|
parallel (~> 1.10)
|
174
|
-
parser (>= 3.
|
174
|
+
parser (>= 3.2.0.0)
|
175
175
|
rainbow (>= 2.2.2, < 4.0)
|
176
176
|
regexp_parser (>= 1.8, < 3.0)
|
177
177
|
rexml (>= 3.2.5, < 4.0)
|
178
|
-
rubocop-ast (>= 1.
|
178
|
+
rubocop-ast (>= 1.24.1, < 2.0)
|
179
179
|
ruby-progressbar (~> 1.7)
|
180
|
-
unicode-display_width (>=
|
181
|
-
rubocop-ast (1.24.
|
180
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
181
|
+
rubocop-ast (1.24.1)
|
182
182
|
parser (>= 3.1.1.0)
|
183
|
-
rubocop-rails (2.17.
|
183
|
+
rubocop-rails (2.17.4)
|
184
184
|
activesupport (>= 4.2.0)
|
185
185
|
rack (>= 1.1)
|
186
186
|
rubocop (>= 1.33.0, < 2.0)
|
187
187
|
rubocop-rake (0.6.0)
|
188
188
|
rubocop (~> 1.0)
|
189
|
-
rubocop-rspec (2.
|
189
|
+
rubocop-rspec (2.16.0)
|
190
190
|
rubocop (~> 1.33)
|
191
191
|
ruby-progressbar (1.11.0)
|
192
192
|
thor (1.2.1)
|
193
193
|
timeout (0.3.0)
|
194
194
|
tzinfo (2.0.5)
|
195
195
|
concurrent-ruby (~> 1.0)
|
196
|
-
unicode-display_width (2.
|
196
|
+
unicode-display_width (2.4.2)
|
197
197
|
webrick (1.7.0)
|
198
198
|
websocket-driver (0.7.5)
|
199
199
|
websocket-extensions (>= 0.1.0)
|
@@ -2,112 +2,114 @@
|
|
2
2
|
|
3
3
|
require 'action_view'
|
4
4
|
|
5
|
-
module CrownMarketplaceUtils
|
6
|
-
module
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
module Accordion
|
14
|
+
include ActionView::Context
|
15
|
+
include ActionView::Helpers::TagHelper
|
16
|
+
include ActionView::Helpers::TextHelper
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
49
|
+
private
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
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
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
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
|
6
|
-
module
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
13
|
-
|
13
|
+
module BackLink
|
14
|
+
include ActionView::Helpers::UrlHelper
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
28
|
-
|
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
|
-
|
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
|
6
|
-
module
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
46
|
+
private
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
-
|
60
|
-
|
60
|
+
def govuk_breadcrumb_link(govuk_breadcrumb_item)
|
61
|
+
govuk_breadcrumb_item[:attributes] ||= {}
|
61
62
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
-
|
70
|
-
|
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
|