govuk-components 3.0.4 → 3.0.5
Sign up to get free protection for your applications and to get access to all the features.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d5cf5d99c77bcfbd24e77252b855265660bc80e2496b75adda9cf10362c9ee1
|
4
|
+
data.tar.gz: c54839796cf802ebe85dddf875a269b67a423856d36c87cdc7e16a4f90ee830d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 246a31f6ea734ae757f88bf92e0d2bf1ea15daa741fb87318f257b9d79926b189b8cf9312b492d6f82a9180608dec25344f7328f98c74f49d4ffd81fdda3540f
|
7
|
+
data.tar.gz: 61d94fc80d6e125d198eb388afd056b3edd612b6463adb06a17fb9fbfe8e37862b93f99ce45603a21cdf8c32a8a1cfe28edbd463b952ea73c08e003948d4175c
|
data/README.md
CHANGED
@@ -31,6 +31,7 @@ The provided components are:
|
|
31
31
|
* [Notification banner](https://govuk-components.netlify.app/components/notification-banner)
|
32
32
|
* [Panel](https://govuk-components.netlify.app/components/panel)
|
33
33
|
* [Phase banner](https://govuk-components.netlify.app/components/phase-banner)
|
34
|
+
* [Section break](https://govuk-components.netlify.app/components/section-break)
|
34
35
|
* [Start button](https://govuk-components.netlify.app/components/start-button)
|
35
36
|
* [Summary list](https://govuk-components.netlify.app/components/summary-list)
|
36
37
|
* [Tabs](https://govuk-components.netlify.app/components/tabs)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= tag.div(id: id(suffix: 'section'),
|
1
|
+
<%= tag.div(id: id(suffix: 'section'), **html_attributes) do %>
|
2
2
|
<div class="govuk-accordion__section-header">
|
3
3
|
<%= content_tag(heading_level, class: "govuk-accordion__section-heading") do %>
|
4
4
|
<%= tag.span(heading_content, id: id, class: "govuk-accordion__section-button", aria: { expanded: expanded?, controls: id(suffix: 'content') }) %>
|
@@ -7,12 +7,12 @@ class GovukComponent::AccordionComponent::SectionComponent < GovukComponent::Bas
|
|
7
7
|
alias_method :expanded?, :expanded
|
8
8
|
|
9
9
|
def initialize(heading_text:, summary_text:, expanded:, heading_level:, classes: [], html_attributes: {})
|
10
|
-
super(classes: classes, html_attributes: html_attributes)
|
11
|
-
|
12
10
|
@heading_text = heading_text
|
13
11
|
@summary_text = summary_text
|
14
12
|
@expanded = expanded
|
15
13
|
@heading_level = heading_level
|
14
|
+
|
15
|
+
super(classes: classes, html_attributes: html_attributes)
|
16
16
|
end
|
17
17
|
|
18
18
|
def id(suffix: nil)
|
@@ -33,7 +33,7 @@ class GovukComponent::AccordionComponent::SectionComponent < GovukComponent::Bas
|
|
33
33
|
|
34
34
|
private
|
35
35
|
|
36
|
-
def
|
37
|
-
class_names("govuk-accordion__section", "govuk-accordion__section--expanded" => expanded?).split
|
36
|
+
def default_attributes
|
37
|
+
{ class: class_names("govuk-accordion__section", "govuk-accordion__section--expanded" => expanded?).split }
|
38
38
|
end
|
39
39
|
end
|
@@ -13,17 +13,16 @@ class GovukComponent::AccordionComponent < GovukComponent::Base
|
|
13
13
|
|
14
14
|
attr_reader :id, :heading_level
|
15
15
|
|
16
|
-
def initialize(
|
17
|
-
super(classes: classes, html_attributes: html_attributes)
|
18
|
-
|
19
|
-
@id = id
|
16
|
+
def initialize(heading_level: 2, classes: [], html_attributes: {})
|
20
17
|
@heading_level = heading_tag(heading_level)
|
18
|
+
|
19
|
+
super(classes: classes, html_attributes: html_attributes)
|
21
20
|
end
|
22
21
|
|
23
22
|
private
|
24
23
|
|
25
|
-
def
|
26
|
-
%w(govuk-accordion)
|
24
|
+
def default_attributes
|
25
|
+
{ class: %w(govuk-accordion), data: { module: 'govuk-accordion' } }
|
27
26
|
end
|
28
27
|
|
29
28
|
def heading_tag(level)
|
@@ -1,15 +1,15 @@
|
|
1
1
|
class GovukComponent::BackLinkComponent < GovukComponent::Base
|
2
2
|
attr_reader :text, :href
|
3
3
|
|
4
|
-
def initialize(href:, text: 'Back', classes:
|
5
|
-
super(classes: classes, html_attributes: html_attributes)
|
6
|
-
|
4
|
+
def initialize(href:, text: 'Back', classes: [], html_attributes: {})
|
7
5
|
@text = text
|
8
6
|
@href = href
|
7
|
+
|
8
|
+
super(classes: classes, html_attributes: html_attributes)
|
9
9
|
end
|
10
10
|
|
11
11
|
def call
|
12
|
-
link_to(link_content, href,
|
12
|
+
link_to(link_content, href, **html_attributes)
|
13
13
|
end
|
14
14
|
|
15
15
|
private
|
@@ -18,7 +18,7 @@ private
|
|
18
18
|
content || text || fail(ArgumentError, "no text or content")
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
%w(govuk-back-link)
|
21
|
+
def default_attributes
|
22
|
+
{ class: %w(govuk-back-link) }
|
23
23
|
end
|
24
24
|
end
|
@@ -1,19 +1,21 @@
|
|
1
1
|
class GovukComponent::Base < ViewComponent::Base
|
2
|
-
|
3
|
-
|
4
|
-
include GovukComponent::Traits::CustomClasses
|
5
|
-
include GovukComponent::Traits::CustomHtmlAttributes
|
2
|
+
using HTMLAttributesUtils
|
6
3
|
|
7
4
|
attr_reader :html_attributes
|
8
5
|
|
9
6
|
def initialize(classes:, html_attributes:)
|
10
|
-
|
11
|
-
|
7
|
+
# FIXME: remove first merge when we deprecate classes
|
8
|
+
#
|
9
|
+
# This step only needs to be here while we still accept classes:, now
|
10
|
+
# we're using html_attributes_utils we can start to move towards
|
11
|
+
# supporting html_attributes: { class: 'xyz' } over taking them
|
12
|
+
# separately
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
@html_attributes = default_attributes
|
15
|
+
.deep_merge_html_attributes({ class: classes })
|
16
|
+
.deep_merge_html_attributes(html_attributes)
|
17
|
+
.deep_tidy_html_attributes
|
15
18
|
|
16
|
-
|
17
|
-
[]
|
19
|
+
super
|
18
20
|
end
|
19
21
|
end
|
@@ -2,21 +2,23 @@ class GovukComponent::BreadcrumbsComponent < GovukComponent::Base
|
|
2
2
|
attr_reader :breadcrumbs, :hide_in_print, :collapse_on_mobile
|
3
3
|
|
4
4
|
def initialize(breadcrumbs:, hide_in_print: false, collapse_on_mobile: false, classes: [], html_attributes: {})
|
5
|
-
super(classes: classes, html_attributes: html_attributes)
|
6
|
-
|
7
5
|
@breadcrumbs = build_list(breadcrumbs)
|
8
6
|
@hide_in_print = hide_in_print
|
9
7
|
@collapse_on_mobile = collapse_on_mobile
|
8
|
+
|
9
|
+
super(classes: classes, html_attributes: html_attributes)
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
13
13
|
|
14
|
-
def
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
def default_attributes
|
15
|
+
{
|
16
|
+
class: class_names(
|
17
|
+
"govuk-breadcrumbs",
|
18
|
+
"govuk-!-display-none-print" => hide_in_print,
|
19
|
+
"govuk-breadcrumbs--collapse-on-mobile" => collapse_on_mobile
|
20
|
+
).split
|
21
|
+
}
|
20
22
|
end
|
21
23
|
|
22
24
|
def build_list(breadcrumbs)
|
@@ -5,16 +5,16 @@ class GovukComponent::CookieBannerComponent::MessageComponent < GovukComponent::
|
|
5
5
|
renders_one :heading_html
|
6
6
|
|
7
7
|
def initialize(heading_text: nil, text: nil, hidden: false, role: nil, classes: [], html_attributes: {})
|
8
|
-
super(classes: classes, html_attributes: html_attributes)
|
9
|
-
|
10
8
|
@heading_text = heading_text
|
11
9
|
@text = text
|
12
10
|
@hidden = hidden
|
13
11
|
@role = role
|
12
|
+
|
13
|
+
super(classes: classes, html_attributes: html_attributes)
|
14
14
|
end
|
15
15
|
|
16
16
|
def call
|
17
|
-
tag.div(
|
17
|
+
tag.div(role: role, hidden: hidden, **html_attributes) do
|
18
18
|
safe_join([
|
19
19
|
tag.div(class: "govuk-grid-row") do
|
20
20
|
tag.div(class: "govuk-grid-column-two-thirds") { safe_join([heading_element, message_element]) }
|
@@ -26,8 +26,8 @@ class GovukComponent::CookieBannerComponent::MessageComponent < GovukComponent::
|
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
|
-
def
|
30
|
-
%w(govuk-cookie-banner__message govuk-width-container)
|
29
|
+
def default_attributes
|
30
|
+
{ class: %w(govuk-cookie-banner__message govuk-width-container) }
|
31
31
|
end
|
32
32
|
|
33
33
|
def heading_element
|
@@ -5,23 +5,25 @@ module GovukComponent
|
|
5
5
|
attr_accessor :aria_label, :hidden, :hide_in_print
|
6
6
|
|
7
7
|
def initialize(aria_label: "Cookie banner", hidden: false, hide_in_print: true, classes: [], html_attributes: {})
|
8
|
-
super(classes: classes, html_attributes: html_attributes)
|
9
|
-
|
10
8
|
@aria_label = aria_label
|
11
9
|
@hidden = hidden
|
12
10
|
@hide_in_print = hide_in_print
|
11
|
+
|
12
|
+
super(classes: classes, html_attributes: html_attributes)
|
13
13
|
end
|
14
14
|
|
15
15
|
def call
|
16
|
-
tag.div(
|
16
|
+
tag.div(role: "region", aria: { label: aria_label }, data: { nosnippet: true }, hidden: hidden, **html_attributes) do
|
17
17
|
safe_join(messages)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
-
def
|
24
|
-
|
23
|
+
def default_attributes
|
24
|
+
{
|
25
|
+
class: class_names("govuk-cookie-banner", "govuk-!-display-none-print" => hide_in_print).split
|
26
|
+
}
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
@@ -4,16 +4,16 @@ class GovukComponent::DetailsComponent < GovukComponent::Base
|
|
4
4
|
renders_one :summary_html
|
5
5
|
|
6
6
|
def initialize(summary_text: nil, text: nil, classes: [], id: nil, open: nil, html_attributes: {})
|
7
|
-
super(classes: classes, html_attributes: html_attributes)
|
8
|
-
|
9
7
|
@summary_text = summary_text
|
10
8
|
@text = text
|
11
9
|
@id = id
|
12
10
|
@open = open
|
11
|
+
|
12
|
+
super(classes: classes, html_attributes: html_attributes)
|
13
13
|
end
|
14
14
|
|
15
15
|
def call
|
16
|
-
tag.details(
|
16
|
+
tag.details(data: { module: "govuk-details" }, id: id, open: open, **html_attributes) do
|
17
17
|
safe_join([summary, description])
|
18
18
|
end
|
19
19
|
end
|
@@ -36,7 +36,7 @@ private
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
40
|
-
%w(govuk-details)
|
39
|
+
def default_attributes
|
40
|
+
{ class: %w(govuk-details) }
|
41
41
|
end
|
42
42
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<%= tag.footer(
|
2
|
-
<%= tag.div(
|
1
|
+
<%= tag.footer(role: 'contentinfo', **html_attributes) do %>
|
2
|
+
<%= tag.div(**container_html_attributes) do %>
|
3
3
|
<% if navigation.present? %>
|
4
4
|
<div class="govuk-footer__navigation">
|
5
5
|
<%= navigation %>
|
@@ -1,4 +1,6 @@
|
|
1
1
|
class GovukComponent::FooterComponent < GovukComponent::Base
|
2
|
+
using HTMLAttributesUtils
|
3
|
+
|
2
4
|
renders_one :meta_html
|
3
5
|
renders_one :meta
|
4
6
|
renders_one :navigation
|
@@ -19,8 +21,6 @@ class GovukComponent::FooterComponent < GovukComponent::Base
|
|
19
21
|
meta_classes: [],
|
20
22
|
meta_html_attributes: {}
|
21
23
|
)
|
22
|
-
super(classes: classes, html_attributes: html_attributes)
|
23
|
-
|
24
24
|
@meta_text = meta_text
|
25
25
|
@meta_items = build_meta_links(meta_items)
|
26
26
|
@meta_items_title = meta_items_title
|
@@ -30,16 +30,14 @@ class GovukComponent::FooterComponent < GovukComponent::Base
|
|
30
30
|
@copyright = build_copyright(copyright_text, copyright_url)
|
31
31
|
@custom_container_classes = container_classes
|
32
32
|
@custom_container_html_attributes = container_html_attributes
|
33
|
+
|
34
|
+
super(classes: classes, html_attributes: html_attributes)
|
33
35
|
end
|
34
36
|
|
35
37
|
private
|
36
38
|
|
37
|
-
def
|
38
|
-
%w(govuk-footer)
|
39
|
-
end
|
40
|
-
|
41
|
-
def container_classes
|
42
|
-
combine_classes(%w(govuk-width-container), custom_container_classes)
|
39
|
+
def default_attributes
|
40
|
+
{ class: %w(govuk-footer) }
|
43
41
|
end
|
44
42
|
|
45
43
|
def meta_content
|
@@ -55,7 +53,13 @@ private
|
|
55
53
|
end
|
56
54
|
|
57
55
|
def container_html_attributes
|
58
|
-
|
56
|
+
# FIXME: remove when we deprecate classes
|
57
|
+
#
|
58
|
+
# Once we drop classes this extra merging can be dropped along with the
|
59
|
+
# container_classes and meta_classes args
|
60
|
+
{ class: %w(govuk-width-container) }.deep_merge_html_attributes(
|
61
|
+
@custom_container_html_attributes.merge(class: custom_container_classes)
|
62
|
+
)
|
59
63
|
end
|
60
64
|
|
61
65
|
def build_meta_links(links)
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<%= tag.header(
|
2
|
-
<%= tag.div(
|
1
|
+
<%= tag.header(role: 'banner', data: { module: 'govuk-header' }, **html_attributes) do %>
|
2
|
+
<%= tag.div(**container_html_attributes) do %>
|
3
3
|
<div class="govuk-header__logo">
|
4
4
|
<%= link_to(homepage_url, class: %w(govuk-header__link govuk-header__link--homepage)) do %>
|
5
5
|
<span class="govuk-header__logotype">
|
@@ -36,7 +36,7 @@
|
|
36
36
|
<% end %>
|
37
37
|
|
38
38
|
<% if navigation_items.any? %>
|
39
|
-
<%= tag.nav(
|
39
|
+
<%= tag.nav(**navigation_html_attributes) do %>
|
40
40
|
<%= tag.button("Menu", type: "button", class: %w(govuk-header__menu-button govuk-js-header-toggle), aria: { controls: "navigation", label: menu_button_label }) %>
|
41
41
|
<ul id="navigation" class="govuk-header__navigation-list">
|
42
42
|
<% navigation_items.each do |item| %>
|
@@ -27,8 +27,6 @@ class GovukComponent::HeaderComponent < GovukComponent::Base
|
|
27
27
|
service_url: '/',
|
28
28
|
container_classes: nil)
|
29
29
|
|
30
|
-
super(classes: classes, html_attributes: html_attributes)
|
31
|
-
|
32
30
|
@logotype = logotype
|
33
31
|
@crown = crown
|
34
32
|
@crown_fallback_image_path = crown_fallback_image_path
|
@@ -39,20 +37,24 @@ class GovukComponent::HeaderComponent < GovukComponent::Base
|
|
39
37
|
@custom_navigation_classes = navigation_classes
|
40
38
|
@navigation_label = navigation_label
|
41
39
|
@custom_container_classes = container_classes
|
40
|
+
|
41
|
+
super(classes: classes, html_attributes: html_attributes)
|
42
42
|
end
|
43
43
|
|
44
44
|
private
|
45
45
|
|
46
|
-
def
|
47
|
-
%w(govuk-header)
|
46
|
+
def default_attributes
|
47
|
+
{ class: %w(govuk-header) }
|
48
48
|
end
|
49
49
|
|
50
|
-
def
|
51
|
-
|
50
|
+
def navigation_html_attributes
|
51
|
+
nc = %w(govuk-header__navigation).append(custom_navigation_classes).compact
|
52
|
+
|
53
|
+
{ class: nc, aria: { label: navigation_label } }
|
52
54
|
end
|
53
55
|
|
54
|
-
def
|
55
|
-
|
56
|
+
def container_html_attributes
|
57
|
+
{ class: %w(govuk-header__container govuk-width-container).append(custom_container_classes).compact }
|
56
58
|
end
|
57
59
|
|
58
60
|
def crown_fallback_image_attributes
|
@@ -67,21 +69,22 @@ private
|
|
67
69
|
attr_reader :text, :href, :options, :active
|
68
70
|
|
69
71
|
def initialize(text:, href: nil, options: {}, active: nil, classes: [], html_attributes: {})
|
70
|
-
|
71
|
-
|
72
|
-
@
|
73
|
-
@href = href
|
74
|
-
@options = options
|
75
|
-
|
72
|
+
@text = text
|
73
|
+
@href = href
|
74
|
+
@options = options
|
76
75
|
@active_override = active
|
76
|
+
|
77
|
+
super(classes: classes, html_attributes: html_attributes)
|
77
78
|
end
|
78
79
|
|
79
80
|
def before_render
|
80
|
-
|
81
|
+
if active?
|
82
|
+
html_attributes[:class] << active_class
|
83
|
+
end
|
81
84
|
end
|
82
85
|
|
83
86
|
def active_class
|
84
|
-
%w(govuk-header__navigation-item--active) if
|
87
|
+
%w(govuk-header__navigation-item--active) if active?
|
85
88
|
end
|
86
89
|
|
87
90
|
def link?
|
@@ -89,9 +92,9 @@ private
|
|
89
92
|
end
|
90
93
|
|
91
94
|
def call
|
92
|
-
tag.li(
|
95
|
+
tag.li(**html_attributes) do
|
93
96
|
if link?
|
94
|
-
link_to(text, href,
|
97
|
+
link_to(text, href, class: "govuk-header__link", **options)
|
95
98
|
else
|
96
99
|
text
|
97
100
|
end
|
@@ -100,14 +103,14 @@ private
|
|
100
103
|
|
101
104
|
private
|
102
105
|
|
103
|
-
def active?
|
104
|
-
return
|
106
|
+
def active?
|
107
|
+
return @active_override unless @active_override.nil?
|
105
108
|
|
106
|
-
|
109
|
+
current_page?(href)
|
107
110
|
end
|
108
111
|
|
109
|
-
def
|
110
|
-
%w(govuk-header__navigation-item)
|
112
|
+
def default_attributes
|
113
|
+
{ class: %w(govuk-header__navigation-item) }
|
111
114
|
end
|
112
115
|
end
|
113
116
|
|
@@ -115,9 +118,9 @@ private
|
|
115
118
|
attr_reader :name
|
116
119
|
|
117
120
|
def initialize(name: nil, html_attributes: {}, classes: [])
|
118
|
-
super(classes: classes, html_attributes: html_attributes)
|
119
|
-
|
120
121
|
@name = name
|
122
|
+
|
123
|
+
super(classes: classes, html_attributes: html_attributes)
|
121
124
|
end
|
122
125
|
|
123
126
|
def render?
|
@@ -126,16 +129,16 @@ private
|
|
126
129
|
|
127
130
|
def call
|
128
131
|
if content.present?
|
129
|
-
tag.div(content,
|
132
|
+
tag.div(content, **html_attributes)
|
130
133
|
else
|
131
|
-
tag.span(name,
|
134
|
+
tag.span(name, **html_attributes)
|
132
135
|
end
|
133
136
|
end
|
134
137
|
|
135
138
|
private
|
136
139
|
|
137
|
-
def
|
138
|
-
%w(govuk-header__product-name)
|
140
|
+
def default_attributes
|
141
|
+
{ class: %w(govuk-header__product-name) }
|
139
142
|
end
|
140
143
|
end
|
141
144
|
end
|
@@ -2,14 +2,14 @@ class GovukComponent::InsetTextComponent < GovukComponent::Base
|
|
2
2
|
attr_reader :text, :id
|
3
3
|
|
4
4
|
def initialize(text: nil, id: nil, classes: [], html_attributes: {})
|
5
|
-
super(classes: classes, html_attributes: html_attributes)
|
6
|
-
|
7
5
|
@text = text
|
8
6
|
@id = id
|
7
|
+
|
8
|
+
super(classes: classes, html_attributes: html_attributes)
|
9
9
|
end
|
10
10
|
|
11
11
|
def call
|
12
|
-
tag.div(
|
12
|
+
tag.div(id: id, **html_attributes) { inset_text_content }
|
13
13
|
end
|
14
14
|
|
15
15
|
def render?
|
@@ -22,7 +22,7 @@ private
|
|
22
22
|
content.presence || text
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
%w(govuk-inset-text)
|
25
|
+
def default_attributes
|
26
|
+
{ class: %w(govuk-inset-text) }
|
27
27
|
end
|
28
28
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= tag.div(
|
1
|
+
<%= tag.div(**html_attributes) do %>
|
2
2
|
<div class="govuk-notification-banner__header">
|
3
3
|
<%= content_tag(title_tag, class: "govuk-notification-banner__title", id: title_id) do %>
|
4
4
|
<%= title_content %>
|
@@ -5,8 +5,6 @@ class GovukComponent::NotificationBannerComponent < GovukComponent::Base
|
|
5
5
|
renders_many :headings, "Heading"
|
6
6
|
|
7
7
|
def initialize(title_text: nil, text: nil, role: nil, success: false, title_heading_level: 2, title_id: "govuk-notification-banner-title", disable_auto_focus: nil, classes: [], html_attributes: {})
|
8
|
-
super(classes: classes, html_attributes: html_attributes)
|
9
|
-
|
10
8
|
@title_text = title_text
|
11
9
|
@title_id = title_id
|
12
10
|
@text = text
|
@@ -14,6 +12,8 @@ class GovukComponent::NotificationBannerComponent < GovukComponent::Base
|
|
14
12
|
@role = role || default_role
|
15
13
|
@title_heading_level = title_heading_level
|
16
14
|
@disable_auto_focus = disable_auto_focus
|
15
|
+
|
16
|
+
super(classes: classes, html_attributes: html_attributes)
|
17
17
|
end
|
18
18
|
|
19
19
|
def render?
|
@@ -24,15 +24,15 @@ class GovukComponent::NotificationBannerComponent < GovukComponent::Base
|
|
24
24
|
attr_reader :text, :link_href, :link_text
|
25
25
|
|
26
26
|
def initialize(text: nil, link_text: nil, link_href: nil, classes: [], html_attributes: {})
|
27
|
-
super(classes: classes, html_attributes: html_attributes)
|
28
|
-
|
29
27
|
@text = text
|
30
28
|
@link_text = link_text
|
31
29
|
@link_href = link_href
|
30
|
+
|
31
|
+
super(classes: classes, html_attributes: html_attributes)
|
32
32
|
end
|
33
33
|
|
34
34
|
def call
|
35
|
-
tag.div(
|
35
|
+
tag.div(**html_attributes) do
|
36
36
|
if text.present?
|
37
37
|
safe_join([text, link].compact, " ")
|
38
38
|
else
|
@@ -45,27 +45,26 @@ class GovukComponent::NotificationBannerComponent < GovukComponent::Base
|
|
45
45
|
link_to(link_text, link_href, class: 'govuk-notification-banner__link') if link_text.present? && link_href.present?
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
49
|
-
%w(govuk-notification-banner__heading)
|
48
|
+
def default_attributes
|
49
|
+
{ class: %w(govuk-notification-banner__heading) }
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
private
|
54
54
|
|
55
|
-
def
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
%(govuk-notification-banner--success) if success
|
55
|
+
def default_attributes
|
56
|
+
{
|
57
|
+
class: class_names(
|
58
|
+
"govuk-notification-banner",
|
59
|
+
"govuk-notification-banner--success" => success
|
60
|
+
),
|
61
|
+
data: {
|
62
|
+
"module" => "govuk-notification-banner",
|
63
|
+
"disable-auto-focus" => disable_auto_focus
|
64
|
+
},
|
65
|
+
role: role,
|
66
|
+
aria: { labelledby: title_id },
|
67
|
+
}
|
69
68
|
end
|
70
69
|
|
71
70
|
def title_content
|
@@ -4,24 +4,24 @@ class GovukComponent::PanelComponent < GovukComponent::Base
|
|
4
4
|
renders_one :title_html
|
5
5
|
|
6
6
|
def initialize(title_text: nil, text: nil, heading_level: 1, id: nil, classes: [], html_attributes: {})
|
7
|
-
super(classes: classes, html_attributes: html_attributes)
|
8
|
-
|
9
7
|
@heading_level = heading_level
|
10
8
|
@title_text = title_text
|
11
9
|
@text = text
|
12
10
|
@id = id
|
11
|
+
|
12
|
+
super(classes: classes, html_attributes: html_attributes)
|
13
13
|
end
|
14
14
|
|
15
15
|
def call
|
16
|
-
tag.div(id: id,
|
16
|
+
tag.div(id: id, **html_attributes) do
|
17
17
|
safe_join([panel_title, panel_body].compact)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
-
def
|
24
|
-
%w(govuk-panel govuk-panel--confirmation)
|
23
|
+
def default_attributes
|
24
|
+
{ class: %w(govuk-panel govuk-panel--confirmation) }
|
25
25
|
end
|
26
26
|
|
27
27
|
def heading_tag
|