govuk-components 3.0.4 → 3.0.5
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.
- checksums.yaml +4 -4
- data/README.md +1 -0
- 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 +12 -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 +3 -3
- 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/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/traits/custom_classes.rb +0 -24
- data/app/components/govuk_component/warning_text_component.rb +5 -5
- data/app/helpers/govuk_components_helper.rb +1 -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 +33 -5
- data/app/components/govuk_component/table_component/cell_component.html.erb +0 -1
@@ -2,10 +2,10 @@ class GovukComponent::PhaseBannerComponent < GovukComponent::Base
|
|
2
2
|
attr_reader :text, :phase_tag
|
3
3
|
|
4
4
|
def initialize(tag: nil, text: nil, classes: [], html_attributes: {})
|
5
|
-
super(classes: classes, html_attributes: html_attributes)
|
6
|
-
|
7
5
|
@phase_tag = tag
|
8
6
|
@text = text
|
7
|
+
|
8
|
+
super(classes: classes, html_attributes: html_attributes)
|
9
9
|
end
|
10
10
|
|
11
11
|
def phase_tag_component
|
@@ -14,7 +14,7 @@ class GovukComponent::PhaseBannerComponent < GovukComponent::Base
|
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
|
-
def
|
18
|
-
%w(govuk-phase-banner)
|
17
|
+
def default_attributes
|
18
|
+
{ class: %w(govuk-phase-banner) }
|
19
19
|
end
|
20
20
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class GovukComponent::SectionBreakComponent < GovukComponent::Base
|
2
|
+
SIZES = %w(m l xl).freeze
|
3
|
+
|
4
|
+
def initialize(visible: false, size: nil, classes: [], html_attributes: {})
|
5
|
+
@visible = visible
|
6
|
+
@size = size
|
7
|
+
|
8
|
+
super(classes: classes, html_attributes: html_attributes)
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
tag.hr(**html_attributes)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
attr_reader :size, :visible
|
18
|
+
|
19
|
+
def default_attributes
|
20
|
+
{ class: default_classes }
|
21
|
+
end
|
22
|
+
|
23
|
+
def default_classes
|
24
|
+
class_names(
|
25
|
+
"govuk-section-break",
|
26
|
+
size_class,
|
27
|
+
"govuk-section-break--visible" => visible?
|
28
|
+
).split
|
29
|
+
end
|
30
|
+
|
31
|
+
def size_class
|
32
|
+
if size.blank?
|
33
|
+
""
|
34
|
+
elsif size.in?(SIZES)
|
35
|
+
"govuk-section-break--#{size}"
|
36
|
+
else
|
37
|
+
raise ArgumentError, "invalid size #{size}, supported sizes are #{SIZES.to_sentence}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def visible?
|
42
|
+
visible
|
43
|
+
end
|
44
|
+
end
|
@@ -1,15 +1,21 @@
|
|
1
1
|
class GovukComponent::StartButtonComponent < GovukComponent::Base
|
2
|
+
BUTTON_ATTRIBUTES = {
|
3
|
+
role: 'button',
|
4
|
+
draggable: 'false',
|
5
|
+
data: { module: 'govuk-button' }
|
6
|
+
}.freeze
|
7
|
+
|
2
8
|
attr_reader :text, :href
|
3
9
|
|
4
10
|
def initialize(text:, href:, classes: [], html_attributes: {})
|
5
|
-
super(classes: classes, html_attributes: html_attributes)
|
6
|
-
|
7
11
|
@text = text
|
8
12
|
@href = href
|
13
|
+
|
14
|
+
super(classes: classes, html_attributes: html_attributes)
|
9
15
|
end
|
10
16
|
|
11
17
|
def call
|
12
|
-
link_to(href, **
|
18
|
+
link_to(href, **html_attributes) do
|
13
19
|
safe_join([text, icon])
|
14
20
|
end
|
15
21
|
end
|
@@ -17,20 +23,17 @@ class GovukComponent::StartButtonComponent < GovukComponent::Base
|
|
17
23
|
private
|
18
24
|
|
19
25
|
def default_attributes
|
20
|
-
{
|
21
|
-
role: 'button',
|
22
|
-
draggable: 'false',
|
23
|
-
class: classes,
|
24
|
-
data: { module: 'govuk-button' }
|
25
|
-
}
|
26
|
+
BUTTON_ATTRIBUTES.merge({ class: %w(govuk-button govuk-button--start) })
|
26
27
|
end
|
27
28
|
|
28
|
-
def
|
29
|
-
|
29
|
+
def icon
|
30
|
+
tag.svg(**svg_attributes) do
|
31
|
+
tag.path(fill: "currentColor", d: "M0 0h13l20 20-20 20H0l20-20z")
|
32
|
+
end
|
30
33
|
end
|
31
34
|
|
32
|
-
def
|
33
|
-
|
35
|
+
def svg_attributes
|
36
|
+
{
|
34
37
|
class: "govuk-button__start-icon",
|
35
38
|
xmlns: "http://www.w3.org/2000/svg",
|
36
39
|
width: "17.5",
|
@@ -39,9 +42,5 @@ private
|
|
39
42
|
focusable: "false",
|
40
43
|
aria: { hidden: "true" }
|
41
44
|
}
|
42
|
-
|
43
|
-
tag.svg(**svg_attributes) do
|
44
|
-
tag.path(fill: "currentColor", d: "M0 0h13l20 20-20 20H0l20-20z")
|
45
|
-
end
|
46
45
|
end
|
47
46
|
end
|
@@ -14,15 +14,19 @@ class GovukComponent::SummaryListComponent::ActionComponent < GovukComponent::Ba
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def call
|
17
|
-
|
18
|
-
|
19
|
-
link_to(href, class: link_classes, **html_attributes) do
|
17
|
+
link_to(href, **html_attributes) do
|
20
18
|
safe_join([action_text, visually_hidden_span].compact, " ")
|
21
19
|
end
|
22
20
|
end
|
23
21
|
|
24
22
|
private
|
25
23
|
|
24
|
+
def default_attributes
|
25
|
+
link_classes = govuk_link_classes.append(classes).flatten
|
26
|
+
|
27
|
+
{ class: link_classes }
|
28
|
+
end
|
29
|
+
|
26
30
|
def action_text
|
27
31
|
content || text || fail(ArgumentError, "no text or content")
|
28
32
|
end
|
@@ -2,19 +2,19 @@ class GovukComponent::SummaryListComponent::KeyComponent < GovukComponent::Base
|
|
2
2
|
attr_reader :text
|
3
3
|
|
4
4
|
def initialize(text: nil, classes: [], html_attributes: {})
|
5
|
-
super(classes: classes, html_attributes: html_attributes)
|
6
|
-
|
7
5
|
@text = text
|
6
|
+
|
7
|
+
super(classes: classes, html_attributes: html_attributes)
|
8
8
|
end
|
9
9
|
|
10
10
|
def call
|
11
|
-
tag.dt(key_content,
|
11
|
+
tag.dt(key_content, **html_attributes)
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
def
|
17
|
-
%w(govuk-summary-list__key)
|
16
|
+
def default_attributes
|
17
|
+
{ class: %w(govuk-summary-list__key) }
|
18
18
|
end
|
19
19
|
|
20
20
|
def key_content
|
@@ -6,17 +6,23 @@ class GovukComponent::SummaryListComponent::RowComponent < GovukComponent::Base
|
|
6
6
|
renders_many :actions, GovukComponent::SummaryListComponent::ActionComponent
|
7
7
|
|
8
8
|
def initialize(show_actions_column: nil, classes: [], html_attributes: {})
|
9
|
-
super(classes: classes, html_attributes: html_attributes)
|
10
|
-
|
11
9
|
@show_actions_column = show_actions_column
|
10
|
+
|
11
|
+
super(classes: classes, html_attributes: html_attributes)
|
12
12
|
end
|
13
13
|
|
14
14
|
def call
|
15
|
-
tag.div(
|
15
|
+
tag.div(**html_attributes) do
|
16
16
|
safe_join([key, value, actions_content])
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
def before_render
|
21
|
+
if show_actions_column && actions.none?
|
22
|
+
html_attributes[:class] << no_actions_class
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
20
26
|
private
|
21
27
|
|
22
28
|
def actions_content
|
@@ -37,13 +43,15 @@ private
|
|
37
43
|
end
|
38
44
|
end
|
39
45
|
|
40
|
-
def
|
41
|
-
%w(govuk-summary-list__row)
|
42
|
-
c << "govuk-summary-list__row--no-actions" if show_actions_column && actions.none?
|
43
|
-
end
|
46
|
+
def default_attributes
|
47
|
+
{ class: %w(govuk-summary-list__row) }
|
44
48
|
end
|
45
49
|
|
46
50
|
def actions_class
|
47
51
|
"govuk-summary-list__actions"
|
48
52
|
end
|
53
|
+
|
54
|
+
def no_actions_class
|
55
|
+
"govuk-summary-list__row--no-actions"
|
56
|
+
end
|
49
57
|
end
|
@@ -8,13 +8,13 @@ class GovukComponent::SummaryListComponent::ValueComponent < GovukComponent::Bas
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def call
|
11
|
-
tag.dd(value_content,
|
11
|
+
tag.dd(value_content, **html_attributes)
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
def
|
17
|
-
%w(govuk-summary-list__value)
|
16
|
+
def default_attributes
|
17
|
+
{ class: %w(govuk-summary-list__value) }
|
18
18
|
end
|
19
19
|
|
20
20
|
def value_content
|
@@ -12,28 +12,24 @@ module GovukComponent
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def initialize(rows: nil, actions: true, borders: true, classes: [], html_attributes: {})
|
15
|
-
super(classes: classes, html_attributes: html_attributes)
|
16
|
-
|
17
15
|
@borders = borders
|
18
16
|
@show_actions_column = actions
|
19
17
|
|
18
|
+
super(classes: classes, html_attributes: html_attributes)
|
19
|
+
|
20
20
|
return unless rows.presence
|
21
21
|
|
22
22
|
build(rows)
|
23
23
|
end
|
24
24
|
|
25
|
-
def classes
|
26
|
-
super.append(borders_class).compact
|
27
|
-
end
|
28
|
-
|
29
25
|
private
|
30
26
|
|
31
27
|
def borders_class
|
32
28
|
%(govuk-summary-list--no-border) unless borders
|
33
29
|
end
|
34
30
|
|
35
|
-
def
|
36
|
-
|
31
|
+
def default_attributes
|
32
|
+
{ class: ["govuk-summary-list", borders_class].compact }
|
37
33
|
end
|
38
34
|
|
39
35
|
def build(rows)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= tag.div(
|
1
|
+
<%= tag.div(**html_attributes) do %>
|
2
2
|
<%= tag.h2(title, class: "govuk-tabs__title") %>
|
3
3
|
<ul class="govuk-tabs__list">
|
4
4
|
<% tabs.each.with_index do |tab, i| %>
|
@@ -6,6 +6,6 @@
|
|
6
6
|
<% end %>
|
7
7
|
</ul>
|
8
8
|
<% tabs.each.with_index do |tab, i| %>
|
9
|
-
<%= tag.div(tab,
|
9
|
+
<%= tag.div(tab, **tab.combined_attributes(i)) %>
|
10
10
|
<% end %>
|
11
11
|
<% end %>
|
@@ -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
|
@@ -1,28 +1,4 @@
|
|
1
1
|
module GovukComponent
|
2
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
3
|
end
|
28
4
|
end
|
@@ -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
|
@@ -11,6 +11,7 @@ module GovukComponentsHelper
|
|
11
11
|
govuk_notification_banner: 'GovukComponent::NotificationBannerComponent',
|
12
12
|
govuk_panel: 'GovukComponent::PanelComponent',
|
13
13
|
govuk_phase_banner: 'GovukComponent::PhaseBannerComponent',
|
14
|
+
govuk_section_break: 'GovukComponent::SectionBreakComponent',
|
14
15
|
govuk_start_button: 'GovukComponent::StartButtonComponent',
|
15
16
|
govuk_summary_list: 'GovukComponent::SummaryListComponent',
|
16
17
|
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