govuk-components 3.0.4 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/app/components/govuk_component/accordion_component/section_component.html.erb +1 -1
- data/app/components/govuk_component/accordion_component/section_component.rb +4 -4
- data/app/components/govuk_component/accordion_component.html.erb +1 -1
- data/app/components/govuk_component/accordion_component.rb +5 -6
- data/app/components/govuk_component/back_link_component.rb +6 -6
- data/app/components/govuk_component/base.rb +17 -10
- data/app/components/govuk_component/breadcrumbs_component.html.erb +1 -1
- data/app/components/govuk_component/breadcrumbs_component.rb +10 -8
- data/app/components/govuk_component/cookie_banner_component/message_component.rb +5 -5
- data/app/components/govuk_component/cookie_banner_component.rb +7 -5
- data/app/components/govuk_component/details_component.rb +5 -5
- data/app/components/govuk_component/footer_component.html.erb +2 -2
- data/app/components/govuk_component/footer_component.rb +13 -9
- data/app/components/govuk_component/header_component.html.erb +4 -4
- data/app/components/govuk_component/header_component.rb +32 -29
- data/app/components/govuk_component/inset_text_component.rb +5 -5
- data/app/components/govuk_component/notification_banner_component.html.erb +1 -1
- data/app/components/govuk_component/notification_banner_component.rb +20 -21
- data/app/components/govuk_component/pagination_component/adjacent_page.rb +60 -0
- data/app/components/govuk_component/pagination_component/item.rb +77 -0
- data/app/components/govuk_component/pagination_component/next_page.rb +32 -0
- data/app/components/govuk_component/pagination_component/previous_page.rb +26 -0
- data/app/components/govuk_component/pagination_component.rb +121 -0
- data/app/components/govuk_component/panel_component.rb +5 -5
- data/app/components/govuk_component/phase_banner_component.html.erb +1 -1
- data/app/components/govuk_component/phase_banner_component.rb +4 -4
- data/app/components/govuk_component/section_break_component.rb +44 -0
- data/app/components/govuk_component/start_button_component.rb +16 -17
- data/app/components/govuk_component/summary_list_component/action_component.rb +7 -3
- data/app/components/govuk_component/summary_list_component/key_component.rb +5 -5
- data/app/components/govuk_component/summary_list_component/row_component.rb +15 -7
- data/app/components/govuk_component/summary_list_component/value_component.rb +3 -3
- data/app/components/govuk_component/summary_list_component.html.erb +1 -1
- data/app/components/govuk_component/summary_list_component.rb +4 -8
- data/app/components/govuk_component/tab_component.html.erb +2 -2
- data/app/components/govuk_component/tab_component.rb +17 -9
- data/app/components/govuk_component/table_component/body_component.html.erb +1 -1
- data/app/components/govuk_component/table_component/body_component.rb +2 -2
- data/app/components/govuk_component/table_component/caption_component.rb +5 -5
- data/app/components/govuk_component/table_component/cell_component.rb +10 -2
- data/app/components/govuk_component/table_component/head_component.html.erb +1 -1
- data/app/components/govuk_component/table_component/head_component.rb +2 -2
- data/app/components/govuk_component/table_component/row_component.html.erb +1 -1
- data/app/components/govuk_component/table_component/row_component.rb +4 -4
- data/app/components/govuk_component/table_component.html.erb +1 -1
- data/app/components/govuk_component/table_component.rb +4 -4
- data/app/components/govuk_component/tag_component.rb +7 -5
- data/app/components/govuk_component/warning_text_component.rb +5 -5
- data/app/helpers/govuk_components_helper.rb +2 -0
- data/app/helpers/govuk_link_helper.rb +2 -1
- data/lib/govuk/components/version.rb +1 -1
- data/lib/govuk/components.rb +1 -0
- metadata +74 -8
- data/app/components/govuk_component/table_component/cell_component.html.erb +0 -1
- data/app/components/govuk_component/traits/custom_classes.rb +0 -28
@@ -1,29 +1,31 @@
|
|
1
1
|
class GovukComponent::TabComponent < GovukComponent::Base
|
2
|
+
using HTMLAttributesUtils
|
3
|
+
|
2
4
|
renders_many :tabs, "Tab"
|
3
5
|
|
4
6
|
attr_reader :title, :id
|
5
7
|
|
6
8
|
def initialize(title:, id: nil, classes: [], html_attributes: {})
|
7
|
-
super(classes: classes, html_attributes: html_attributes)
|
8
|
-
|
9
9
|
@title = title
|
10
10
|
@id = id
|
11
|
+
|
12
|
+
super(classes: classes, html_attributes: html_attributes)
|
11
13
|
end
|
12
14
|
|
13
15
|
private
|
14
16
|
|
15
|
-
def
|
16
|
-
%w(govuk-tabs)
|
17
|
+
def default_attributes
|
18
|
+
{ id: id, class: %w(govuk-tabs), data: { module: 'govuk-tabs' } }
|
17
19
|
end
|
18
20
|
|
19
21
|
class Tab < GovukComponent::Base
|
20
22
|
attr_reader :label, :text
|
21
23
|
|
22
24
|
def initialize(label:, text: nil, classes: [], html_attributes: {})
|
23
|
-
super(classes: classes, html_attributes: html_attributes)
|
24
|
-
|
25
25
|
@label = label
|
26
26
|
@text = text
|
27
|
+
|
28
|
+
super(classes: classes, html_attributes: html_attributes)
|
27
29
|
end
|
28
30
|
|
29
31
|
def id(prefix: nil)
|
@@ -31,7 +33,9 @@ private
|
|
31
33
|
end
|
32
34
|
|
33
35
|
def hidden_class(i = nil)
|
34
|
-
|
36
|
+
return [] if i&.zero?
|
37
|
+
|
38
|
+
%w(govuk-tabs__panel--hidden)
|
35
39
|
end
|
36
40
|
|
37
41
|
def li_classes(i = nil)
|
@@ -42,8 +46,12 @@ private
|
|
42
46
|
link_to(label, id(prefix: '#'), class: "govuk-tabs__tab")
|
43
47
|
end
|
44
48
|
|
45
|
-
def
|
46
|
-
%w(govuk-tabs__panel)
|
49
|
+
def default_attributes
|
50
|
+
{ id: id, class: %w(govuk-tabs__panel) }
|
51
|
+
end
|
52
|
+
|
53
|
+
def combined_attributes(i)
|
54
|
+
html_attributes.deep_merge_html_attributes({ class: hidden_class(i) }).deep_tidy_html_attributes
|
47
55
|
end
|
48
56
|
|
49
57
|
def call
|
@@ -4,15 +4,15 @@ class GovukComponent::TableComponent::CaptionComponent < GovukComponent::Base
|
|
4
4
|
SIZES = %w(s m l xl).freeze
|
5
5
|
|
6
6
|
def initialize(text: nil, id: nil, size: 'm', classes: [], html_attributes: {})
|
7
|
-
super(classes: classes, html_attributes: html_attributes)
|
8
|
-
|
9
7
|
@id = id
|
10
8
|
@text = text
|
11
9
|
@size = size
|
10
|
+
|
11
|
+
super(classes: classes, html_attributes: html_attributes)
|
12
12
|
end
|
13
13
|
|
14
14
|
def call
|
15
|
-
tag.caption(caption_content,
|
15
|
+
tag.caption(caption_content, **html_attributes)
|
16
16
|
end
|
17
17
|
|
18
18
|
def render?
|
@@ -25,8 +25,8 @@ private
|
|
25
25
|
@caption_content ||= (content || text)
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
29
|
-
class_names("govuk-table__caption", caption_size_class => size).split
|
28
|
+
def default_attributes
|
29
|
+
{ class: class_names("govuk-table__caption", caption_size_class => size).split }
|
30
30
|
end
|
31
31
|
|
32
32
|
def caption_size_class
|
@@ -13,12 +13,16 @@ class GovukComponent::TableComponent::CellComponent < GovukComponent::Base
|
|
13
13
|
}.freeze
|
14
14
|
|
15
15
|
def initialize(header: false, text: nil, numeric: false, width: nil, classes: [], html_attributes: {})
|
16
|
-
super(classes: classes, html_attributes: html_attributes)
|
17
|
-
|
18
16
|
@header = header
|
19
17
|
@text = text
|
20
18
|
@numeric = numeric
|
21
19
|
@width = width
|
20
|
+
|
21
|
+
super(classes: classes, html_attributes: html_attributes)
|
22
|
+
end
|
23
|
+
|
24
|
+
def call
|
25
|
+
content_tag(cell_element, cell_content, **html_attributes)
|
22
26
|
end
|
23
27
|
|
24
28
|
private
|
@@ -35,6 +39,10 @@ private
|
|
35
39
|
header ? :th : :td
|
36
40
|
end
|
37
41
|
|
42
|
+
def default_attributes
|
43
|
+
{ class: default_classes }
|
44
|
+
end
|
45
|
+
|
38
46
|
def default_classes
|
39
47
|
if header
|
40
48
|
class_names("govuk-table__header", "govuk-table__header--numeric" => numeric?, width_class => width?).split
|
@@ -4,11 +4,11 @@ class GovukComponent::TableComponent::RowComponent < GovukComponent::Base
|
|
4
4
|
attr_reader :header, :first_cell_is_header
|
5
5
|
|
6
6
|
def initialize(cell_data: nil, first_cell_is_header: false, header: false, classes: [], html_attributes: {})
|
7
|
-
super(classes: classes, html_attributes: html_attributes)
|
8
|
-
|
9
7
|
@header = header
|
10
8
|
@first_cell_is_header = first_cell_is_header
|
11
9
|
|
10
|
+
super(classes: classes, html_attributes: html_attributes)
|
11
|
+
|
12
12
|
build_cells_from_cell_data(cell_data)
|
13
13
|
end
|
14
14
|
|
@@ -24,7 +24,7 @@ private
|
|
24
24
|
header || (first_cell_is_header && count.zero?)
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
28
|
-
%w(govuk-table__row)
|
27
|
+
def default_attributes
|
28
|
+
{ class: %w(govuk-table__row) }
|
29
29
|
end
|
30
30
|
end
|
@@ -7,12 +7,12 @@ module GovukComponent
|
|
7
7
|
attr_accessor :id, :first_cell_is_header, :caption_text
|
8
8
|
|
9
9
|
def initialize(id: nil, rows: nil, head: nil, caption: nil, first_cell_is_header: false, classes: [], html_attributes: {})
|
10
|
-
super(classes: classes, html_attributes: html_attributes)
|
11
|
-
|
12
10
|
@id = id
|
13
11
|
@first_cell_is_header = first_cell_is_header
|
14
12
|
@caption_text = caption
|
15
13
|
|
14
|
+
super(classes: classes, html_attributes: html_attributes)
|
15
|
+
|
16
16
|
# when no rows are passed in it's likely we're taking the slot approach
|
17
17
|
return unless rows.presence
|
18
18
|
|
@@ -28,8 +28,8 @@ module GovukComponent
|
|
28
28
|
body(rows: body_data, first_cell_is_header: first_cell_is_header)
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
%w(govuk-table)
|
31
|
+
def default_attributes
|
32
|
+
{ id: id, class: %w(govuk-table) }
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -4,14 +4,14 @@ class GovukComponent::TagComponent < GovukComponent::Base
|
|
4
4
|
COLOURS = %w(grey green turquoise blue red purple pink orange yellow).freeze
|
5
5
|
|
6
6
|
def initialize(text: nil, colour: nil, classes: [], html_attributes: {})
|
7
|
-
super(classes: classes, html_attributes: html_attributes)
|
8
|
-
|
9
7
|
@text = text
|
10
8
|
@colour = colour
|
9
|
+
|
10
|
+
super(classes: classes, html_attributes: html_attributes)
|
11
11
|
end
|
12
12
|
|
13
13
|
def call
|
14
|
-
tag.strong(tag_content,
|
14
|
+
tag.strong(tag_content, **html_attributes)
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
@@ -20,8 +20,10 @@ private
|
|
20
20
|
@text || content || fail(ArgumentError, "no text or content")
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
24
|
-
|
23
|
+
def default_attributes
|
24
|
+
{
|
25
|
+
class: ["govuk-tag", colour_class]
|
26
|
+
}
|
25
27
|
end
|
26
28
|
|
27
29
|
def colour_class
|
@@ -4,14 +4,14 @@ class GovukComponent::WarningTextComponent < GovukComponent::Base
|
|
4
4
|
ICON = '!'.freeze
|
5
5
|
|
6
6
|
def initialize(text: nil, icon_fallback_text: 'Warning', classes: [], html_attributes: {})
|
7
|
-
super(classes: classes, html_attributes: html_attributes)
|
8
|
-
|
9
7
|
@text = text
|
10
8
|
@icon_fallback_text = icon_fallback_text
|
9
|
+
|
10
|
+
super(classes: classes, html_attributes: html_attributes)
|
11
11
|
end
|
12
12
|
|
13
13
|
def call
|
14
|
-
tag.div(
|
14
|
+
tag.div(**html_attributes) do
|
15
15
|
safe_join([icon, warning_text])
|
16
16
|
end
|
17
17
|
end
|
@@ -32,7 +32,7 @@ private
|
|
32
32
|
tag.span(icon_fallback_text, class: 'govuk-warning-text__assistive')
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
36
|
-
%w(govuk-warning-text)
|
35
|
+
def default_attributes
|
36
|
+
{ class: %w(govuk-warning-text) }
|
37
37
|
end
|
38
38
|
end
|
@@ -9,8 +9,10 @@ module GovukComponentsHelper
|
|
9
9
|
govuk_header: 'GovukComponent::HeaderComponent',
|
10
10
|
govuk_inset_text: 'GovukComponent::InsetTextComponent',
|
11
11
|
govuk_notification_banner: 'GovukComponent::NotificationBannerComponent',
|
12
|
+
govuk_pagination: 'GovukComponent::PaginationComponent',
|
12
13
|
govuk_panel: 'GovukComponent::PanelComponent',
|
13
14
|
govuk_phase_banner: 'GovukComponent::PhaseBannerComponent',
|
15
|
+
govuk_section_break: 'GovukComponent::SectionBreakComponent',
|
14
16
|
govuk_start_button: 'GovukComponent::StartButtonComponent',
|
15
17
|
govuk_summary_list: 'GovukComponent::SummaryListComponent',
|
16
18
|
govuk_table: 'GovukComponent::TableComponent',
|
@@ -68,7 +68,8 @@ module GovukLinkHelper
|
|
68
68
|
|
69
69
|
def govuk_button_link_to(name = nil, options = nil, extra_options = {}, &block)
|
70
70
|
extra_options = options if block_given?
|
71
|
-
html_options =
|
71
|
+
html_options = GovukComponent::StartButtonComponent::BUTTON_ATTRIBUTES
|
72
|
+
.merge build_html_options(extra_options, style: :button)
|
72
73
|
|
73
74
|
if block_given?
|
74
75
|
link_to(name, html_options, &block)
|
data/lib/govuk/components.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk-components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DfE developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: actionpack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '6.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '6.1'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: activemodel
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,20 +52,54 @@ dependencies:
|
|
38
52
|
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '6.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: html-attributes-utils
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.9'
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 0.9.2
|
65
|
+
type: :runtime
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0.9'
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.9.2
|
41
75
|
- !ruby/object:Gem::Dependency
|
42
76
|
name: view_component
|
43
77
|
requirement: !ruby/object:Gem::Requirement
|
44
78
|
requirements:
|
45
79
|
- - "~>"
|
46
80
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.
|
81
|
+
version: 2.56.2
|
48
82
|
type: :runtime
|
49
83
|
prerelease: false
|
50
84
|
version_requirements: !ruby/object:Gem::Requirement
|
51
85
|
requirements:
|
52
86
|
- - "~>"
|
53
87
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
88
|
+
version: 2.56.2
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: deep_merge
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
55
103
|
- !ruby/object:Gem::Dependency
|
56
104
|
name: pry-byebug
|
57
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,6 +226,20 @@ dependencies:
|
|
178
226
|
- - "~>"
|
179
227
|
- !ruby/object:Gem::Version
|
180
228
|
version: '4.11'
|
229
|
+
- !ruby/object:Gem::Dependency
|
230
|
+
name: pagy
|
231
|
+
requirement: !ruby/object:Gem::Requirement
|
232
|
+
requirements:
|
233
|
+
- - "~>"
|
234
|
+
- !ruby/object:Gem::Version
|
235
|
+
version: 5.10.1
|
236
|
+
type: :development
|
237
|
+
prerelease: false
|
238
|
+
version_requirements: !ruby/object:Gem::Requirement
|
239
|
+
requirements:
|
240
|
+
- - "~>"
|
241
|
+
- !ruby/object:Gem::Version
|
242
|
+
version: 5.10.1
|
181
243
|
- !ruby/object:Gem::Dependency
|
182
244
|
name: redcarpet
|
183
245
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,14 +260,14 @@ dependencies:
|
|
198
260
|
requirements:
|
199
261
|
- - "~>"
|
200
262
|
- !ruby/object:Gem::Version
|
201
|
-
version: 3.
|
263
|
+
version: 3.29.0
|
202
264
|
type: :development
|
203
265
|
prerelease: false
|
204
266
|
version_requirements: !ruby/object:Gem::Requirement
|
205
267
|
requirements:
|
206
268
|
- - "~>"
|
207
269
|
- !ruby/object:Gem::Version
|
208
|
-
version: 3.
|
270
|
+
version: 3.29.0
|
209
271
|
- !ruby/object:Gem::Dependency
|
210
272
|
name: rubypants
|
211
273
|
requirement: !ruby/object:Gem::Requirement
|
@@ -320,9 +382,15 @@ files:
|
|
320
382
|
- app/components/govuk_component/inset_text_component.rb
|
321
383
|
- app/components/govuk_component/notification_banner_component.html.erb
|
322
384
|
- app/components/govuk_component/notification_banner_component.rb
|
385
|
+
- app/components/govuk_component/pagination_component.rb
|
386
|
+
- app/components/govuk_component/pagination_component/adjacent_page.rb
|
387
|
+
- app/components/govuk_component/pagination_component/item.rb
|
388
|
+
- app/components/govuk_component/pagination_component/next_page.rb
|
389
|
+
- app/components/govuk_component/pagination_component/previous_page.rb
|
323
390
|
- app/components/govuk_component/panel_component.rb
|
324
391
|
- app/components/govuk_component/phase_banner_component.html.erb
|
325
392
|
- app/components/govuk_component/phase_banner_component.rb
|
393
|
+
- app/components/govuk_component/section_break_component.rb
|
326
394
|
- app/components/govuk_component/start_button_component.rb
|
327
395
|
- app/components/govuk_component/summary_list_component.html.erb
|
328
396
|
- app/components/govuk_component/summary_list_component.rb
|
@@ -337,7 +405,6 @@ files:
|
|
337
405
|
- app/components/govuk_component/table_component/body_component.html.erb
|
338
406
|
- app/components/govuk_component/table_component/body_component.rb
|
339
407
|
- app/components/govuk_component/table_component/caption_component.rb
|
340
|
-
- app/components/govuk_component/table_component/cell_component.html.erb
|
341
408
|
- app/components/govuk_component/table_component/cell_component.rb
|
342
409
|
- app/components/govuk_component/table_component/head_component.html.erb
|
343
410
|
- app/components/govuk_component/table_component/head_component.rb
|
@@ -345,7 +412,6 @@ files:
|
|
345
412
|
- app/components/govuk_component/table_component/row_component.rb
|
346
413
|
- app/components/govuk_component/tag_component.rb
|
347
414
|
- app/components/govuk_component/traits.rb
|
348
|
-
- app/components/govuk_component/traits/custom_classes.rb
|
349
415
|
- app/components/govuk_component/traits/custom_html_attributes.rb
|
350
416
|
- app/components/govuk_component/warning_text_component.rb
|
351
417
|
- app/helpers/govuk_back_to_top_link_helper.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= content_tag(cell_element, cell_content, class: classes, **html_attributes) %>
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module GovukComponent
|
2
|
-
module Traits
|
3
|
-
module CustomClasses
|
4
|
-
def classes
|
5
|
-
default_classes.concat(Array.wrap(@classes))
|
6
|
-
end
|
7
|
-
|
8
|
-
def default_classes
|
9
|
-
Rails.logger.warn(%(#default_classes hasn't been defined in #{self.class}))
|
10
|
-
|
11
|
-
[]
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def parse_classes(classes)
|
17
|
-
return [] if classes.blank?
|
18
|
-
|
19
|
-
case classes
|
20
|
-
when Array
|
21
|
-
classes
|
22
|
-
when String
|
23
|
-
classes.split
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|