ccs-frontend_helpers 0.1.0.rc.2 → 0.1.0.rc.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/Gemfile.lock +1 -1
- data/lib/ccs/components/ccs/dashboard_section/panel.rb +43 -41
- data/lib/ccs/components/ccs/dashboard_section.rb +50 -48
- data/lib/ccs/components/ccs/footer/link.rb +41 -39
- data/lib/ccs/components/ccs/footer/meta.rb +49 -48
- data/lib/ccs/components/ccs/footer/navigation.rb +51 -50
- data/lib/ccs/components/ccs/footer.rb +69 -67
- data/lib/ccs/components/ccs/header/link.rb +47 -45
- data/lib/ccs/components/ccs/header/navigation.rb +85 -84
- data/lib/ccs/components/ccs/header/service_authentication.rb +35 -34
- data/lib/ccs/components/ccs/header.rb +87 -85
- data/lib/ccs/components/ccs/logo.rb +36 -34
- data/lib/ccs/components/govuk/accordion/section/content.rb +42 -42
- data/lib/ccs/components/govuk/accordion/section/header.rb +48 -48
- data/lib/ccs/components/govuk/accordion/section.rb +49 -48
- data/lib/ccs/components/govuk/accordion.rb +43 -41
- data/lib/ccs/components/govuk/back_link.rb +39 -37
- data/lib/ccs/components/govuk/breadcrumbs/link.rb +42 -40
- data/lib/ccs/components/govuk/breadcrumbs.rb +40 -38
- data/lib/ccs/components/govuk/button.rb +83 -81
- data/lib/ccs/components/govuk/cookie_banner/action.rb +45 -43
- data/lib/ccs/components/govuk/cookie_banner/message.rb +57 -55
- data/lib/ccs/components/govuk/cookie_banner.rb +40 -38
- data/lib/ccs/components/govuk/details.rb +38 -36
- data/lib/ccs/components/govuk/error_message.rb +46 -44
- data/lib/ccs/components/govuk/error_summary/item.rb +41 -39
- data/lib/ccs/components/govuk/error_summary.rb +49 -47
- data/lib/ccs/components/govuk/field/input/character_count.rb +101 -99
- data/lib/ccs/components/govuk/field/input/file_upload.rb +29 -27
- data/lib/ccs/components/govuk/field/input/select.rb +61 -59
- data/lib/ccs/components/govuk/field/input/text_input/fix.rb +39 -37
- data/lib/ccs/components/govuk/field/input/text_input.rb +75 -73
- data/lib/ccs/components/govuk/field/input/textarea.rb +43 -41
- data/lib/ccs/components/govuk/field/input.rb +46 -44
- data/lib/ccs/components/govuk/field/inputs/checkboxes.rb +43 -41
- data/lib/ccs/components/govuk/field/inputs/date_input/item.rb +48 -46
- data/lib/ccs/components/govuk/field/inputs/date_input.rb +68 -66
- data/lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb +29 -27
- data/lib/ccs/components/govuk/field/inputs/item/checkbox/tag.rb +26 -24
- data/lib/ccs/components/govuk/field/inputs/item/checkbox.rb +32 -30
- data/lib/ccs/components/govuk/field/inputs/item/divider.rb +39 -37
- data/lib/ccs/components/govuk/field/inputs/item/radio/form.rb +27 -25
- data/lib/ccs/components/govuk/field/inputs/item/radio/tag.rb +26 -24
- data/lib/ccs/components/govuk/field/inputs/item/radio.rb +32 -30
- data/lib/ccs/components/govuk/field/inputs/item.rb +100 -98
- data/lib/ccs/components/govuk/field/inputs/radios.rb +43 -41
- data/lib/ccs/components/govuk/field/inputs.rb +42 -40
- data/lib/ccs/components/govuk/field.rb +90 -88
- data/lib/ccs/components/govuk/fieldset/legend.rb +50 -48
- data/lib/ccs/components/govuk/fieldset.rb +40 -38
- data/lib/ccs/components/govuk/footer/link.rb +41 -39
- data/lib/ccs/components/govuk/footer/meta.rb +49 -48
- data/lib/ccs/components/govuk/footer/navigation.rb +51 -50
- data/lib/ccs/components/govuk/footer.rb +105 -103
- data/lib/ccs/components/govuk/form_group.rb +45 -43
- data/lib/ccs/components/govuk/header/link.rb +41 -39
- data/lib/ccs/components/govuk/header/navigation.rb +54 -53
- data/lib/ccs/components/govuk/header.rb +84 -82
- data/lib/ccs/components/govuk/hint.rb +33 -31
- data/lib/ccs/components/govuk/inset_text.rb +39 -37
- data/lib/ccs/components/govuk/label.rb +61 -59
- data/lib/ccs/components/govuk/notification_banner.rb +83 -81
- data/lib/ccs/components/govuk/pagination/increment/next.rb +29 -27
- data/lib/ccs/components/govuk/pagination/increment/previous.rb +28 -26
- data/lib/ccs/components/govuk/pagination/increment.rb +78 -76
- data/lib/ccs/components/govuk/pagination/item/ellipsis.rb +17 -15
- data/lib/ccs/components/govuk/pagination/item/form.rb +34 -32
- data/lib/ccs/components/govuk/pagination/item/tag.rb +33 -31
- data/lib/ccs/components/govuk/pagination/item.rb +47 -45
- data/lib/ccs/components/govuk/pagination.rb +69 -67
- data/lib/ccs/components/govuk/panel.rb +49 -47
- data/lib/ccs/components/govuk/phase_banner.rb +50 -48
- data/lib/ccs/components/govuk/skip_link.rb +39 -37
- data/lib/ccs/components/govuk/step_by_step_navigation/section/content/list/item.rb +40 -38
- data/lib/ccs/components/govuk/step_by_step_navigation/section/content/list.rb +30 -28
- data/lib/ccs/components/govuk/step_by_step_navigation/section/content/paragraph.rb +28 -26
- data/lib/ccs/components/govuk/step_by_step_navigation/section/content.rb +47 -45
- data/lib/ccs/components/govuk/step_by_step_navigation/section/heading.rb +49 -47
- data/lib/ccs/components/govuk/step_by_step_navigation/section.rb +44 -42
- data/lib/ccs/components/govuk/step_by_step_navigation.rb +41 -39
- data/lib/ccs/components/govuk/summary_list/action/link.rb +46 -44
- data/lib/ccs/components/govuk/summary_list/card/actions.rb +38 -36
- data/lib/ccs/components/govuk/summary_list/card/title.rb +37 -35
- data/lib/ccs/components/govuk/summary_list/card.rb +48 -46
- data/lib/ccs/components/govuk/summary_list/row/actions.rb +38 -36
- data/lib/ccs/components/govuk/summary_list/row/key.rb +30 -28
- data/lib/ccs/components/govuk/summary_list/row/value.rb +30 -28
- data/lib/ccs/components/govuk/summary_list/row.rb +47 -45
- data/lib/ccs/components/govuk/summary_list.rb +48 -46
- data/lib/ccs/components/govuk/table/body/data_cell.rb +38 -36
- data/lib/ccs/components/govuk/table/body/head_cell.rb +37 -35
- data/lib/ccs/components/govuk/table/header/head_cell.rb +39 -37
- data/lib/ccs/components/govuk/table.rb +83 -81
- data/lib/ccs/components/govuk/tabs/panel.rb +47 -45
- data/lib/ccs/components/govuk/tabs/tab.rb +42 -40
- data/lib/ccs/components/govuk/tabs.rb +48 -46
- data/lib/ccs/components/govuk/tag.rb +39 -37
- data/lib/ccs/components/govuk/warning_text.rb +49 -47
- data/lib/ccs/frontend_helpers/ccs_frontend/dashboard_section.rb +16 -14
- data/lib/ccs/frontend_helpers/ccs_frontend/footer.rb +17 -15
- data/lib/ccs/frontend_helpers/ccs_frontend/header.rb +17 -15
- data/lib/ccs/frontend_helpers/ccs_frontend.rb +1 -1
- data/lib/ccs/frontend_helpers/govuk_frontend/accordion.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/back_link.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/breadcrumbs.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/button.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/character_count.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/checkboxes.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/cookie_banner.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/date_input.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/details.rb +19 -17
- data/lib/ccs/frontend_helpers/govuk_frontend/error_message.rb +32 -30
- data/lib/ccs/frontend_helpers/govuk_frontend/error_summary.rb +38 -36
- data/lib/ccs/frontend_helpers/govuk_frontend/fieldset.rb +19 -17
- data/lib/ccs/frontend_helpers/govuk_frontend/file_upload.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/footer.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/form_group.rb +27 -25
- data/lib/ccs/frontend_helpers/govuk_frontend/header.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/hint.rb +18 -16
- data/lib/ccs/frontend_helpers/govuk_frontend/input.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/inset_text.rb +19 -17
- data/lib/ccs/frontend_helpers/govuk_frontend/label.rb +18 -16
- data/lib/ccs/frontend_helpers/govuk_frontend/notification_banner.rb +19 -17
- data/lib/ccs/frontend_helpers/govuk_frontend/pagination.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/panel.rb +19 -17
- data/lib/ccs/frontend_helpers/govuk_frontend/phase_banner.rb +19 -17
- data/lib/ccs/frontend_helpers/govuk_frontend/radios.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/select.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/skip_link.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/step_by_step_navigation.rb +24 -22
- data/lib/ccs/frontend_helpers/govuk_frontend/summary_list.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/table.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/tabs.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/tag.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/textarea.rb +17 -15
- data/lib/ccs/frontend_helpers/govuk_frontend/warning_text.rb +19 -17
- data/lib/ccs/frontend_helpers/version.rb +1 -1
- metadata +2 -2
@@ -1,103 +1,105 @@
|
|
1
1
|
require_relative '../base'
|
2
2
|
|
3
|
-
module CCS
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
# This is used to generate the button component from the
|
8
|
-
# {https://design-system.service.gov.uk/components/button GDS - Components - Button}
|
9
|
-
#
|
10
|
-
# @!attribute [r] text
|
11
|
-
# @return [String] Text for the button
|
12
|
-
# @!attribute [r] render_method
|
13
|
-
# @return [String] The method that will be used to render the button
|
14
|
-
|
15
|
-
class Button < Base
|
16
|
-
private
|
17
|
-
|
18
|
-
attr_reader :text, :render_method
|
19
|
-
|
20
|
-
public
|
21
|
-
|
22
|
-
# @param text [String] the text that will be shown in the button
|
23
|
-
# @param options [Hash] options that will be used in customising the HTML
|
3
|
+
module CCS
|
4
|
+
module Components
|
5
|
+
module GovUK
|
6
|
+
# = GOV.UK Button
|
24
7
|
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
# @option options [String] :href the URI that will be used in anchor tag
|
28
|
-
# @option options [ActionView::Helpers::FormBuilder] :form the form builder used to create the submit button
|
29
|
-
# @option options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
|
30
|
-
|
31
|
-
def initialize(text:, **options)
|
32
|
-
super(**options)
|
33
|
-
|
34
|
-
@options[:attributes][:class] << ' govuk-button--disabled' if @options[:attributes][:disabled]
|
35
|
-
@options[:attributes][:class] << ' govuk-button--start' if @options[:is_start_button]
|
36
|
-
|
37
|
-
@text = text
|
38
|
-
@render_method = :"render_#{if @options[:href]
|
39
|
-
:link
|
40
|
-
elsif @options[:form]
|
41
|
-
:submit
|
42
|
-
else
|
43
|
-
:button
|
44
|
-
end}"
|
45
|
-
end
|
46
|
-
|
47
|
-
# Generates the HTML for the GOV.UK Back link component
|
8
|
+
# This is used to generate the button component from the
|
9
|
+
# {https://design-system.service.gov.uk/components/button GDS - Components - Button}
|
48
10
|
#
|
49
|
-
#
|
11
|
+
# @!attribute [r] text
|
12
|
+
# @return [String] Text for the button
|
13
|
+
# @!attribute [r] render_method
|
14
|
+
# @return [String] The method that will be used to render the button
|
15
|
+
|
16
|
+
class Button < Base
|
17
|
+
private
|
18
|
+
|
19
|
+
attr_reader :text, :render_method
|
20
|
+
|
21
|
+
public
|
22
|
+
|
23
|
+
# @param text [String] the text that will be shown in the button
|
24
|
+
# @param options [Hash] options that will be used in customising the HTML
|
25
|
+
#
|
26
|
+
# @option options [String] :classes additional CSS classes for the button HTML
|
27
|
+
# @option options [Boolean] :is_start_button indicates if it is a start button
|
28
|
+
# @option options [String] :href the URI that will be used in anchor tag
|
29
|
+
# @option options [ActionView::Helpers::FormBuilder] :form the form builder used to create the submit button
|
30
|
+
# @option options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
|
31
|
+
|
32
|
+
def initialize(text:, **options)
|
33
|
+
super(**options)
|
34
|
+
|
35
|
+
@options[:attributes][:class] << ' govuk-button--disabled' if @options[:attributes][:disabled]
|
36
|
+
@options[:attributes][:class] << ' govuk-button--start' if @options[:is_start_button]
|
37
|
+
|
38
|
+
@text = text
|
39
|
+
@render_method = :"render_#{if @options[:href]
|
40
|
+
:link
|
41
|
+
elsif @options[:form]
|
42
|
+
:submit
|
43
|
+
else
|
44
|
+
:button
|
45
|
+
end}"
|
46
|
+
end
|
50
47
|
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
# Generates the HTML for the GOV.UK Back link component
|
49
|
+
#
|
50
|
+
# @return [ActiveSupport::SafeBuffer]
|
54
51
|
|
55
|
-
|
52
|
+
def render
|
53
|
+
send(@render_method)
|
54
|
+
end
|
56
55
|
|
57
|
-
|
56
|
+
# The default attributes for the button
|
58
57
|
|
59
|
-
|
58
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-button', data: { module: 'govuk-button' } }.freeze
|
60
59
|
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
private
|
61
|
+
|
62
|
+
# Generates the HTML for the GOV.UK button component as an anchor tag.
|
63
|
+
#
|
64
|
+
# @return [ActiveSupport::SafeBuffer]
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
def render_link
|
67
|
+
@options[:attributes][:role] = :button
|
68
|
+
@options[:attributes][:draggable] = false
|
68
69
|
|
69
|
-
|
70
|
-
|
71
|
-
|
70
|
+
link_to(@options[:href], **@options[:attributes]) do
|
71
|
+
concat(text)
|
72
|
+
concat(start_button_icon) if @options[:is_start_button]
|
73
|
+
end
|
72
74
|
end
|
73
|
-
end
|
74
75
|
|
75
|
-
|
76
|
-
|
77
|
-
|
76
|
+
# Generates the HTML for the GOV.UK button component as a button.
|
77
|
+
#
|
78
|
+
# @return [ActiveSupport::SafeBuffer]
|
78
79
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
def render_button
|
81
|
+
button_tag(**@options[:attributes]) do
|
82
|
+
concat(text)
|
83
|
+
concat(start_button_icon) if @options[:is_start_button]
|
84
|
+
end
|
83
85
|
end
|
84
|
-
end
|
85
86
|
|
86
|
-
|
87
|
-
|
88
|
-
|
87
|
+
# Generates the HTML for the GOV.UK button component as an input.
|
88
|
+
#
|
89
|
+
# @return [ActiveSupport::SafeBuffer]
|
89
90
|
|
90
|
-
|
91
|
-
|
92
|
-
|
91
|
+
def render_submit
|
92
|
+
@options[:form].submit(text, **@options[:attributes])
|
93
|
+
end
|
93
94
|
|
94
|
-
|
95
|
-
|
96
|
-
|
95
|
+
# Generates the arrow if the button is a start button
|
96
|
+
#
|
97
|
+
# @return [ActiveSupport::SafeBuffer]
|
97
98
|
|
98
|
-
|
99
|
-
|
100
|
-
|
99
|
+
def start_button_icon
|
100
|
+
tag.svg(class: 'govuk-button__start-icon', xmlns: 'http://www.w3.org/2000/svg', width: 17.5, height: 19, viewBox: '0 0 33 40', aria: { hidden: true }, focusable: false) do
|
101
|
+
tag.path(fill: 'currentColor', d: 'M0 0h13l20 20-20 20H0l20-20z')
|
102
|
+
end
|
101
103
|
end
|
102
104
|
end
|
103
105
|
end
|
@@ -1,57 +1,59 @@
|
|
1
1
|
require_relative '../../base'
|
2
2
|
require_relative '../button'
|
3
3
|
|
4
|
-
module CCS
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
# The individual cookie banner action.
|
10
|
-
# It defaults to creating button unless a +href+ is set which will create a link
|
11
|
-
#
|
12
|
-
# @!attribute [r] text
|
13
|
-
# @return [String] Text for the action
|
14
|
-
# @!attribute [r] href
|
15
|
-
# @return [String] The href for the action
|
16
|
-
|
17
|
-
class Action < Base
|
18
|
-
private
|
19
|
-
|
20
|
-
attr_reader :text, :href
|
21
|
-
|
22
|
-
public
|
23
|
-
|
24
|
-
# @param text [String] the button or link text
|
25
|
-
# @param href [String] the href for a link
|
26
|
-
# @param options [Hash] options that will be used in customising the HTML
|
4
|
+
module CCS
|
5
|
+
module Components
|
6
|
+
module GovUK
|
7
|
+
class CookieBanner < Base
|
8
|
+
# = GOV.UK Cookie Banner Action
|
27
9
|
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
10
|
+
# The individual cookie banner action.
|
11
|
+
# It defaults to creating button unless a +href+ is set which will create a link
|
12
|
+
#
|
13
|
+
# @!attribute [r] text
|
14
|
+
# @return [String] Text for the action
|
15
|
+
# @!attribute [r] href
|
16
|
+
# @return [String] The href for the action
|
32
17
|
|
33
|
-
|
34
|
-
|
18
|
+
class Action < Base
|
19
|
+
private
|
35
20
|
|
36
|
-
|
37
|
-
@href = href
|
38
|
-
end
|
21
|
+
attr_reader :text, :href
|
39
22
|
|
40
|
-
|
41
|
-
|
42
|
-
|
23
|
+
public
|
24
|
+
|
25
|
+
# @param text [String] the button or link text
|
26
|
+
# @param href [String] the href for a link
|
27
|
+
# @param options [Hash] options that will be used in customising the HTML
|
28
|
+
#
|
29
|
+
# @option options [String] : classes additional CSS classes for the cookie action button or link
|
30
|
+
# @option options [Hash] :attributes any additional attributes that will added as part of the HTML.
|
31
|
+
# If the +:type+ key is present with a value of +:button+,
|
32
|
+
# the action will be rendered as a button
|
33
|
+
|
34
|
+
def initialize(text:, href: nil, **options)
|
35
|
+
super(**options)
|
43
36
|
|
44
|
-
|
45
|
-
|
46
|
-
link_to(text, href, **options[:attributes])
|
47
|
-
else
|
48
|
-
Button.new(text: text, href: href, context: context, **options).render
|
37
|
+
@text = text
|
38
|
+
@href = href
|
49
39
|
end
|
50
|
-
end
|
51
40
|
|
52
|
-
|
41
|
+
# Generates the HTML for a cookie banner message action
|
42
|
+
#
|
43
|
+
# @return [ActiveSupport::SafeBuffer]
|
44
|
+
|
45
|
+
def render
|
46
|
+
if href && options[:attributes][:type] != :button
|
47
|
+
link_to(text, href, **options[:attributes])
|
48
|
+
else
|
49
|
+
Button.new(text: text, href: href, context: context, **options).render
|
50
|
+
end
|
51
|
+
end
|
53
52
|
|
54
|
-
|
53
|
+
# The default attributes for the cookie banner action
|
54
|
+
|
55
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-link' }.freeze
|
56
|
+
end
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|
@@ -1,77 +1,79 @@
|
|
1
1
|
require_relative '../../base'
|
2
2
|
require_relative 'action'
|
3
3
|
|
4
|
-
module CCS
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
4
|
+
module CCS
|
5
|
+
module Components
|
6
|
+
module GovUK
|
7
|
+
class CookieBanner < Base
|
8
|
+
# = GOV.UK Cookie Banner Message
|
9
|
+
#
|
10
|
+
# The individual cookie banner message
|
11
|
+
#
|
12
|
+
# @!attribute [r] heading_text
|
13
|
+
# @return [String] Heading text for the message
|
14
|
+
# @!attribute [r] content
|
15
|
+
# @return [ActiveSupport::SafeBuffer] HTML for the message
|
16
|
+
# @!attribute [r] text
|
17
|
+
# @return [String] Text for the message
|
18
|
+
# @!attribute [r] actions
|
19
|
+
# @return [Array<Action>] Array of initialised cookie banner actions
|
19
20
|
|
20
|
-
|
21
|
-
|
21
|
+
class Message < Base
|
22
|
+
private
|
22
23
|
|
23
|
-
|
24
|
+
attr_reader :heading_text, :content, :text, :actions
|
24
25
|
|
25
|
-
|
26
|
+
public
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
# @param heading_text [String] the heading text that displays in the message
|
29
|
+
# @param content [ActiveSupport::SafeBuffer] HTML to use as content for the message
|
30
|
+
# @param text [String] if +:content+ is blank then this is the text used for the message
|
31
|
+
# @param actions [Array<Hash>] the buttons and/or links that you want to display in the message.
|
32
|
+
# See {Components::GovUK::CookieBanner::Action#initialize Action#initialize} for details of the items in the array.
|
33
|
+
# @param options [Hash] options that will be used in customising the HTML
|
34
|
+
#
|
35
|
+
# @option options [String] :classes additional CSS classes for the cookie message HTML
|
36
|
+
# @option options [Hash] :attributes any additional attributes that will added as part of the HTML
|
36
37
|
|
37
|
-
|
38
|
-
|
38
|
+
def initialize(heading_text: nil, content: nil, text: nil, actions: nil, **options)
|
39
|
+
super(**options)
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
@heading_text = heading_text
|
42
|
+
@content = content
|
43
|
+
@text = text
|
44
|
+
@actions = actions.map { |action| Action.new(context: @context, **action) } if actions
|
45
|
+
end
|
45
46
|
|
46
|
-
|
47
|
+
# rubocop:disable Metrics/AbcSize
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
# Generates the HTML for the GOV.UK Cookie Banner Message
|
50
|
+
#
|
51
|
+
# @return [ActiveSupport::SafeBuffer]
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
53
|
+
def render
|
54
|
+
tag.div(**options[:attributes]) do
|
55
|
+
concat(tag.div(class: 'govuk-grid-row') do
|
56
|
+
tag.div(class: 'govuk-grid-column-two-thirds') do
|
57
|
+
concat(tag.h2(heading_text, class: 'govuk-cookie-banner__heading govuk-heading-m')) if heading_text
|
58
|
+
concat(tag.div(class: 'govuk-cookie-banner__content') do
|
59
|
+
content || tag.p(text, class: 'govuk-body')
|
60
|
+
end)
|
61
|
+
end
|
62
|
+
end)
|
63
|
+
if actions
|
64
|
+
concat(tag.div(class: 'govuk-button-group') do
|
65
|
+
actions.each { |action| concat(action.render) }
|
59
66
|
end)
|
60
67
|
end
|
61
|
-
end)
|
62
|
-
if actions
|
63
|
-
concat(tag.div(class: 'govuk-button-group') do
|
64
|
-
actions.each { |action| concat(action.render) }
|
65
|
-
end)
|
66
68
|
end
|
67
69
|
end
|
68
|
-
end
|
69
70
|
|
70
|
-
|
71
|
+
# rubocop:enable Metrics/AbcSize
|
71
72
|
|
72
|
-
|
73
|
+
# The default attributes for the cookie banner message
|
73
74
|
|
74
|
-
|
75
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-cookie-banner__message govuk-width-container' }.freeze
|
76
|
+
end
|
75
77
|
end
|
76
78
|
end
|
77
79
|
end
|
@@ -1,53 +1,55 @@
|
|
1
1
|
require_relative '../base'
|
2
2
|
require_relative 'cookie_banner/message'
|
3
3
|
|
4
|
-
module CCS
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
# This is used to generate the cookie banner component from the
|
9
|
-
# {https://design-system.service.gov.uk/components/cookie-banner GDS - Components - Cookie banner}
|
10
|
-
#
|
11
|
-
# @!attribute [r] messages
|
12
|
-
# @return [Array<Message>] An array of the initialised cookie banner messages
|
13
|
-
|
14
|
-
class CookieBanner < Base
|
15
|
-
private
|
16
|
-
|
17
|
-
attr_reader :messages
|
18
|
-
|
19
|
-
public
|
20
|
-
|
21
|
-
# @param messages [Array<Hash>] An array of messages for the cookie banner.
|
22
|
-
# See {Components::GovUK::CookieBanner::Message#initialize Message#initialize} for details of the items in the array.
|
23
|
-
# @param options [Hash] options that will be used in customising the HTML
|
4
|
+
module CCS
|
5
|
+
module Components
|
6
|
+
module GovUK
|
7
|
+
# = GOV.UK Cookie Banner
|
24
8
|
#
|
25
|
-
#
|
26
|
-
#
|
9
|
+
# This is used to generate the cookie banner component from the
|
10
|
+
# {https://design-system.service.gov.uk/components/cookie-banner GDS - Components - Cookie banner}
|
11
|
+
#
|
12
|
+
# @!attribute [r] messages
|
13
|
+
# @return [Array<Message>] An array of the initialised cookie banner messages
|
27
14
|
|
28
|
-
|
29
|
-
|
15
|
+
class CookieBanner < Base
|
16
|
+
private
|
30
17
|
|
31
|
-
|
32
|
-
@options[:attributes][:role] = 'region'
|
33
|
-
(@options[:attributes][:aria] ||= {})[:label] ||= 'Cookie banner'
|
18
|
+
attr_reader :messages
|
34
19
|
|
35
|
-
|
36
|
-
end
|
20
|
+
public
|
37
21
|
|
38
|
-
|
39
|
-
|
40
|
-
|
22
|
+
# @param messages [Array<Hash>] An array of messages for the cookie banner.
|
23
|
+
# See {Components::GovUK::CookieBanner::Message#initialize Message#initialize} for details of the items in the array.
|
24
|
+
# @param options [Hash] options that will be used in customising the HTML
|
25
|
+
#
|
26
|
+
# @option options [String] :classes additional CSS classes for the cookie banner HTML
|
27
|
+
# @option options [Hash] :attributes any additional attributes that will added as part of the HTML
|
28
|
+
|
29
|
+
def initialize(messages:, **options)
|
30
|
+
super(**options)
|
31
|
+
|
32
|
+
(@options[:attributes][:data] ||= {})[:nosnippet] = 'true'
|
33
|
+
@options[:attributes][:role] = 'region'
|
34
|
+
(@options[:attributes][:aria] ||= {})[:label] ||= 'Cookie banner'
|
41
35
|
|
42
|
-
|
43
|
-
tag.div(**options[:attributes]) do
|
44
|
-
messages.each { |message| concat(message.render) }
|
36
|
+
@messages = messages.map { |message| Message.new(context: @context, **message) }
|
45
37
|
end
|
46
|
-
end
|
47
38
|
|
48
|
-
|
39
|
+
# Generates the HTML for the GOV.UK Cookie banner component
|
40
|
+
#
|
41
|
+
# @return [ActiveSupport::SafeBuffer]
|
42
|
+
|
43
|
+
def render
|
44
|
+
tag.div(**options[:attributes]) do
|
45
|
+
messages.each { |message| concat(message.render) }
|
46
|
+
end
|
47
|
+
end
|
49
48
|
|
50
|
-
|
49
|
+
# The default attributes for the cookie banner
|
50
|
+
|
51
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-cookie-banner' }.freeze
|
52
|
+
end
|
51
53
|
end
|
52
54
|
end
|
53
55
|
end
|
@@ -1,51 +1,53 @@
|
|
1
1
|
require_relative '../base'
|
2
2
|
|
3
|
-
module CCS
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
module CCS
|
4
|
+
module Components
|
5
|
+
module GovUK
|
6
|
+
# = GOV.UK Details
|
7
|
+
#
|
8
|
+
# This is used to generate the details component from the
|
9
|
+
# {https://design-system.service.gov.uk/components/details GDS - Components - Details}
|
10
|
+
#
|
11
|
+
# @!attribute [r] summary_text
|
12
|
+
# @return [String] Summary text for the details element
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
class Details < Base
|
15
|
+
private
|
15
16
|
|
16
|
-
|
17
|
+
attr_reader :summary_text
|
17
18
|
|
18
|
-
|
19
|
+
public
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
# @param summary_text [String] the summary text for the details element
|
22
|
+
# @param options [Hash] options that will be used in customising the HTML
|
23
|
+
#
|
24
|
+
# @option options [String] :classes additional CSS classes for the details HTML
|
25
|
+
# @option options [Hash] :attributes ({ data: { module: 'govuk-details' } }) any additional attributes that will added as part of the HTML
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
@summary_text = summary_text
|
30
|
-
end
|
27
|
+
def initialize(summary_text:, **options)
|
28
|
+
super(**options)
|
31
29
|
|
32
|
-
|
33
|
-
|
34
|
-
# @yield HTML that will be contained within the 'govuk-details__text' div
|
35
|
-
#
|
36
|
-
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Details
|
37
|
-
# which can then be rendered on the page
|
30
|
+
@summary_text = summary_text
|
31
|
+
end
|
38
32
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
33
|
+
# Generates the HTML for the GOV.UK Details component
|
34
|
+
#
|
35
|
+
# @yield HTML that will be contained within the 'govuk-details__text' div
|
36
|
+
#
|
37
|
+
# @return [ActiveSupport::SafeBuffer] the HTML for the GOV.UK Details
|
38
|
+
# which can then be rendered on the page
|
39
|
+
|
40
|
+
def render(&block)
|
41
|
+
tag.details(**options[:attributes]) do
|
42
|
+
concat(tag.summary(tag.span(summary_text, class: 'govuk-details__summary-text'), class: 'govuk-details__summary'))
|
43
|
+
concat(tag.div(class: 'govuk-details__text', &block))
|
44
|
+
end
|
43
45
|
end
|
44
|
-
end
|
45
46
|
|
46
|
-
|
47
|
+
# The default attributes for the details
|
47
48
|
|
48
|
-
|
49
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-details', data: { module: 'govuk-details' } }.freeze
|
50
|
+
end
|
49
51
|
end
|
50
52
|
end
|
51
53
|
end
|