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,55 +1,56 @@
|
|
1
|
-
require_relative '../../base'
|
2
1
|
require_relative 'link'
|
3
2
|
|
4
|
-
module CCS
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
# @!attribute [r] meta_links
|
12
|
-
# @return [Array<Link>] An array of the initialised meta links
|
13
|
-
# @!attribute [r] visually_hidden_title
|
14
|
-
# @return [String] Title for the meta section
|
15
|
-
# @!attribute [r] text
|
16
|
-
# @return [String] Text to add to the meta section of the footer
|
17
|
-
|
18
|
-
class Meta
|
19
|
-
include ActionView::Context
|
20
|
-
include ActionView::Helpers
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
attr_reader :meta_links, :visually_hidden_title, :text
|
25
|
-
|
26
|
-
public
|
27
|
-
|
28
|
-
# @param items [Array<Hash>] an array of links for the meta section.
|
29
|
-
# See {Components::GovUK::Footer::Link#initialize Link#initialize} for details of the items in the array.
|
30
|
-
# @param visually_hidden_title [String] ('Support links') title for the meta section
|
31
|
-
# @param text [String] text to add to the meta section of the footer
|
32
|
-
# @param context [ActionView::Base] the view context
|
33
|
-
|
34
|
-
def initialize(context:, items: nil, visually_hidden_title: nil, text: nil)
|
35
|
-
@meta_links = items&.map { |meta_link| Link.new(li_class: 'govuk-footer__inline-list-item', context: context, **meta_link) }
|
36
|
-
@visually_hidden_title = visually_hidden_title || 'Support links'
|
37
|
-
@text = text
|
38
|
-
end
|
39
|
-
|
40
|
-
# Generates the HTML for the GOV.UK Footer Meta sections
|
3
|
+
module CCS
|
4
|
+
module Components
|
5
|
+
module GovUK
|
6
|
+
class Footer < Base
|
7
|
+
# = GOV.UK Footer Meta
|
8
|
+
#
|
9
|
+
# The footer meta section
|
41
10
|
#
|
42
|
-
#
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
11
|
+
# @!attribute [r] meta_links
|
12
|
+
# @return [Array<Link>] An array of the initialised meta links
|
13
|
+
# @!attribute [r] visually_hidden_title
|
14
|
+
# @return [String] Title for the meta section
|
15
|
+
# @!attribute [r] text
|
16
|
+
# @return [String] Text to add to the meta section of the footer
|
17
|
+
|
18
|
+
class Meta
|
19
|
+
include ActionView::Context
|
20
|
+
include ActionView::Helpers
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_reader :meta_links, :visually_hidden_title, :text
|
25
|
+
|
26
|
+
public
|
27
|
+
|
28
|
+
# @param items [Array<Hash>] an array of links for the meta section.
|
29
|
+
# See {Components::GovUK::Footer::Link#initialize Link#initialize} for details of the items in the array.
|
30
|
+
# @param visually_hidden_title [String] ('Support links') title for the meta section
|
31
|
+
# @param text [String] text to add to the meta section of the footer
|
32
|
+
# @param context [ActionView::Base] the view context
|
33
|
+
|
34
|
+
def initialize(context:, items: nil, visually_hidden_title: nil, text: nil)
|
35
|
+
@meta_links = items&.map { |meta_link| Link.new(li_class: 'govuk-footer__inline-list-item', context: context, **meta_link) }
|
36
|
+
@visually_hidden_title = visually_hidden_title || 'Support links'
|
37
|
+
@text = text
|
38
|
+
end
|
39
|
+
|
40
|
+
# Generates the HTML for the GOV.UK Footer Meta sections
|
41
|
+
#
|
42
|
+
# @return [ActiveSupport::SafeBuffer]
|
43
|
+
|
44
|
+
def render
|
45
|
+
capture do
|
46
|
+
concat(tag.h2(visually_hidden_title, class: 'govuk-visually-hidden'))
|
47
|
+
if meta_links
|
48
|
+
concat(tag.ul(class: 'govuk-footer__inline-list') do
|
49
|
+
meta_links.each { |meta_link| concat(meta_link.render) }
|
50
|
+
end)
|
51
|
+
end
|
52
|
+
concat(tag.div(text, class: 'govuk-footer__meta-custom')) if text
|
51
53
|
end
|
52
|
-
concat(tag.div(text, class: 'govuk-footer__meta-custom')) if text
|
53
54
|
end
|
54
55
|
end
|
55
56
|
end
|
@@ -1,56 +1,57 @@
|
|
1
|
-
require_relative '../../base'
|
2
1
|
require_relative 'link'
|
3
2
|
|
4
|
-
module CCS
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
# @!attribute [r] title
|
12
|
-
# @return [String] Title for the navigation section
|
13
|
-
# @!attribute [r] navigation_links
|
14
|
-
# @return [Array<Link>] An array of the initialised navigation links
|
15
|
-
# @!attribute [r] width
|
16
|
-
# @return [String] Width of the navigation section
|
17
|
-
# @!attribute [r] columns
|
18
|
-
# @return [Integer] Number of columns to display the links in
|
19
|
-
|
20
|
-
class Navigation
|
21
|
-
include ActionView::Context
|
22
|
-
include ActionView::Helpers
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
attr_reader :title, :navigation_links, :width, :columns
|
27
|
-
|
28
|
-
public
|
29
|
-
|
30
|
-
# @param title [String] the title for the navigation section
|
31
|
-
# @param items [Array<Hash>] an array of links for the navigation section.
|
32
|
-
# See {Components::GovUK::Footer::Link#initialize Link#initialize} for details of the items in the array.
|
33
|
-
# @param width [String] ('full') width of each navigation section in the footer
|
34
|
-
# @param columns [Integer] (nil) number of columns to display the links
|
35
|
-
# @param context [ActionView::Base] the view context
|
36
|
-
|
37
|
-
def initialize(title:, items:, context:, width: nil, columns: nil)
|
38
|
-
@title = title
|
39
|
-
@navigation_links = items.map { |navigation_link| Link.new(li_class: 'govuk-footer__list-item', context: context, **navigation_link) }
|
40
|
-
@width = width || 'full'
|
41
|
-
@columns = columns
|
42
|
-
end
|
43
|
-
|
44
|
-
# Generates the HTML for the GOV.UK Footer Navigation sections
|
3
|
+
module CCS
|
4
|
+
module Components
|
5
|
+
module GovUK
|
6
|
+
class Footer < Base
|
7
|
+
# = GOV.UK Footer Navigation
|
8
|
+
#
|
9
|
+
# The individual footer navigation item
|
45
10
|
#
|
46
|
-
#
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
11
|
+
# @!attribute [r] title
|
12
|
+
# @return [String] Title for the navigation section
|
13
|
+
# @!attribute [r] navigation_links
|
14
|
+
# @return [Array<Link>] An array of the initialised navigation links
|
15
|
+
# @!attribute [r] width
|
16
|
+
# @return [String] Width of the navigation section
|
17
|
+
# @!attribute [r] columns
|
18
|
+
# @return [Integer] Number of columns to display the links in
|
19
|
+
|
20
|
+
class Navigation
|
21
|
+
include ActionView::Context
|
22
|
+
include ActionView::Helpers
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
attr_reader :title, :navigation_links, :width, :columns
|
27
|
+
|
28
|
+
public
|
29
|
+
|
30
|
+
# @param title [String] the title for the navigation section
|
31
|
+
# @param items [Array<Hash>] an array of links for the navigation section.
|
32
|
+
# See {Components::GovUK::Footer::Link#initialize Link#initialize} for details of the items in the array.
|
33
|
+
# @param width [String] ('full') width of each navigation section in the footer
|
34
|
+
# @param columns [Integer] (nil) number of columns to display the links
|
35
|
+
# @param context [ActionView::Base] the view context
|
36
|
+
|
37
|
+
def initialize(title:, items:, context:, width: nil, columns: nil)
|
38
|
+
@title = title
|
39
|
+
@navigation_links = items.map { |navigation_link| Link.new(li_class: 'govuk-footer__list-item', context: context, **navigation_link) }
|
40
|
+
@width = width || 'full'
|
41
|
+
@columns = columns
|
42
|
+
end
|
43
|
+
|
44
|
+
# Generates the HTML for the GOV.UK Footer Navigation sections
|
45
|
+
#
|
46
|
+
# @return [ActiveSupport::SafeBuffer]
|
47
|
+
|
48
|
+
def render
|
49
|
+
tag.div(class: "govuk-footer__section govuk-grid-column-#{width}") do
|
50
|
+
concat(tag.h2(title, class: 'govuk-footer__heading govuk-heading-m'))
|
51
|
+
concat(tag.ul(class: "govuk-footer__list #{"govuk-footer__list--columns-#{columns}" if columns}".rstrip) do
|
52
|
+
navigation_links.each { |navigation_link| concat(navigation_link.render) }
|
53
|
+
end)
|
54
|
+
end
|
54
55
|
end
|
55
56
|
end
|
56
57
|
end
|
@@ -2,126 +2,128 @@ require_relative '../base'
|
|
2
2
|
require_relative 'footer/navigation'
|
3
3
|
require_relative 'footer/meta'
|
4
4
|
|
5
|
-
module CCS
|
6
|
-
module
|
7
|
-
|
8
|
-
|
9
|
-
# This is used to generate the footer component from the
|
10
|
-
# {https://design-system.service.gov.uk/components/footer GDS - Components - Footer}
|
11
|
-
#
|
12
|
-
# @!attribute [r] navigation
|
13
|
-
# @return [Array<Navigation>] An array of the initialised navigation sections
|
14
|
-
# @!attribute [r] meta
|
15
|
-
# @return [Meta] The initialised meta section
|
16
|
-
|
17
|
-
class Footer < Base
|
18
|
-
private
|
19
|
-
|
20
|
-
attr_reader :navigation, :meta
|
21
|
-
|
22
|
-
public
|
23
|
-
|
24
|
-
# @param navigation [Array<Hash>] an array of sections for the footer navigation.
|
25
|
-
# See {Components::GovUK::Footer::Navigation#initialize Navigation#initialize} for details of the items in the array.
|
26
|
-
# @param meta [Hash] ptions for the meta section of the footer.
|
27
|
-
# See {Components::GovUK::Footer::Meta#initialize Meta#initialize} for details of the options.
|
28
|
-
# @param options [Hash] options that will be used in customising the HTML
|
5
|
+
module CCS
|
6
|
+
module Components
|
7
|
+
module GovUK
|
8
|
+
# = GOV.UK Footer
|
29
9
|
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
# @option options [ActiveSupport::SafeBuffer,String] :content_licence The content licence information, see {CCS::Components::GovUK::Footer#footer_content_licence footer_content_licence} for default
|
33
|
-
# @option options [ActiveSupport::SafeBuffer,String] :copyright The copyright information, (default: '© Crown copyright')
|
34
|
-
# @option options [Hash] :attributes additional attributes that will added as part of the HTML
|
35
|
-
|
36
|
-
def initialize(navigation: nil, meta: nil, **options)
|
37
|
-
super(**options)
|
38
|
-
|
39
|
-
@options[:attributes][:role] = 'contentinfo'
|
40
|
-
@options[:copyright] ||= '© Crown copyright'
|
41
|
-
|
42
|
-
@navigation = navigation&.map { |navigation_item| Navigation.new(context: @context, **navigation_item) }
|
43
|
-
@meta = Meta.new(context: @context, **meta) if meta
|
44
|
-
end
|
45
|
-
|
46
|
-
# rubocop:disable Metrics/AbcSize
|
47
|
-
|
48
|
-
# Generates the HTML for the GOV.UK Footer component
|
10
|
+
# This is used to generate the footer component from the
|
11
|
+
# {https://design-system.service.gov.uk/components/footer GDS - Components - Footer}
|
49
12
|
#
|
50
|
-
#
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
13
|
+
# @!attribute [r] navigation
|
14
|
+
# @return [Array<Navigation>] An array of the initialised navigation sections
|
15
|
+
# @!attribute [r] meta
|
16
|
+
# @return [Meta] The initialised meta section
|
17
|
+
|
18
|
+
class Footer < Base
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :navigation, :meta
|
22
|
+
|
23
|
+
public
|
24
|
+
|
25
|
+
# @param navigation [Array<Hash>] an array of sections for the footer navigation.
|
26
|
+
# See {Components::GovUK::Footer::Navigation#initialize Navigation#initialize} for details of the items in the array.
|
27
|
+
# @param meta [Hash] ptions for the meta section of the footer.
|
28
|
+
# See {Components::GovUK::Footer::Meta#initialize Meta#initialize} for details of the options.
|
29
|
+
# @param options [Hash] options that will be used in customising the HTML
|
30
|
+
#
|
31
|
+
# @option options [String] :classes additional CSS classes for the footer HTML
|
32
|
+
# @option options [String] :container_class classes that can be added to the inner container
|
33
|
+
# @option options [ActiveSupport::SafeBuffer,String] :content_licence The content licence information, see {CCS::Components::GovUK::Footer#footer_content_licence footer_content_licence} for default
|
34
|
+
# @option options [ActiveSupport::SafeBuffer,String] :copyright The copyright information, (default: '© Crown copyright')
|
35
|
+
# @option options [Hash] :attributes additional attributes that will added as part of the HTML
|
36
|
+
|
37
|
+
def initialize(navigation: nil, meta: nil, **options)
|
38
|
+
super(**options)
|
39
|
+
|
40
|
+
@options[:attributes][:role] = 'contentinfo'
|
41
|
+
@options[:copyright] ||= '© Crown copyright'
|
42
|
+
|
43
|
+
@navigation = navigation&.map { |navigation_item| Navigation.new(context: @context, **navigation_item) }
|
44
|
+
@meta = Meta.new(context: @context, **meta) if meta
|
45
|
+
end
|
46
|
+
|
47
|
+
# rubocop:disable Metrics/AbcSize
|
48
|
+
|
49
|
+
# Generates the HTML for the GOV.UK Footer component
|
50
|
+
#
|
51
|
+
# @return [ActiveSupport::SafeBuffer]
|
52
|
+
|
53
|
+
def render
|
54
|
+
tag.footer(**options[:attributes]) do
|
55
|
+
tag.div(class: "govuk-width-container #{options[:container_classes]}".rstrip) do
|
56
|
+
if navigation
|
57
|
+
concat(tag.div(class: 'govuk-footer__navigation') do
|
58
|
+
navigation.each { |navigation_item| concat(navigation_item.render) }
|
59
|
+
end)
|
60
|
+
concat(tag.hr(class: 'govuk-footer__section-break'))
|
61
|
+
end
|
62
|
+
concat(tag.div(class: 'govuk-footer__meta') do
|
63
|
+
concat(tag.div(class: 'govuk-footer__meta-item govuk-footer__meta-item--grow') do
|
64
|
+
concat(meta.render) if meta
|
65
|
+
concat(footer_logo)
|
66
|
+
concat(footer_content_licence)
|
67
|
+
end)
|
68
|
+
concat(footer_copyright)
|
58
69
|
end)
|
59
|
-
concat(tag.hr(class: 'govuk-footer__section-break'))
|
60
70
|
end
|
61
|
-
concat(tag.div(class: 'govuk-footer__meta') do
|
62
|
-
concat(tag.div(class: 'govuk-footer__meta-item govuk-footer__meta-item--grow') do
|
63
|
-
concat(meta.render) if meta
|
64
|
-
concat(footer_logo)
|
65
|
-
concat(footer_content_licence)
|
66
|
-
end)
|
67
|
-
concat(footer_copyright)
|
68
|
-
end)
|
69
71
|
end
|
70
72
|
end
|
71
|
-
end
|
72
73
|
|
73
|
-
|
74
|
+
# rubocop:enable Metrics/AbcSize
|
74
75
|
|
75
|
-
|
76
|
+
# The default attributes for the breadcrumbs
|
76
77
|
|
77
|
-
|
78
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-footer' }.freeze
|
78
79
|
|
79
|
-
|
80
|
+
private
|
80
81
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
82
|
+
# Generates the logo used in the footer
|
83
|
+
#
|
84
|
+
# @return [ActiveSupport::SafeBuffer]
|
85
|
+
|
86
|
+
def footer_logo
|
87
|
+
tag.svg(
|
88
|
+
class: 'govuk-footer__licence-logo',
|
89
|
+
aria: { hidden: 'true' },
|
90
|
+
focusable: 'false',
|
91
|
+
xmlns: 'http://www.w3.org/2000/svg',
|
92
|
+
viewBox: '0 0 483.2 195.7',
|
93
|
+
height: '17',
|
94
|
+
width: '41'
|
95
|
+
) do
|
96
|
+
tag.path(
|
97
|
+
fill: 'currentColor',
|
98
|
+
d: 'M421.5 142.8V.1l-50.7 32.3v161.1h112.4v-50.7zm-122.3-9.6A47.12 47.12 0 0 1 221 97.8c0-26 21.1-47.1 47.1-47.1 16.7 0 31.4 8.7 39.7 21.8l42.7-27.2A97.63 97.63 0 0 0 268.1 0c-36.5 0-68.3 20.1-85.1 49.7A98 98 0 0 0 97.8 0C43.9 0 0 43.9 0 97.8s43.9 97.8 97.8 97.8c36.5 0 68.3-20.1 85.1-49.7a97.76 97.76 0 0 0 149.6 25.4l19.4 22.2h3v-87.8h-80l24.3 27.5zM97.8 145c-26 0-47.1-21.1-47.1-47.1s21.1-47.1 47.1-47.1 47.2 21 47.2 47S123.8 145 97.8 145'
|
99
|
+
)
|
100
|
+
end
|
99
101
|
end
|
100
|
-
end
|
101
102
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
103
|
+
# Generates the content licence for the footer
|
104
|
+
#
|
105
|
+
# @return [ActiveSupport::SafeBuffer]
|
106
|
+
|
107
|
+
def footer_content_licence
|
108
|
+
tag.span(class: 'govuk-footer__licence-description') do
|
109
|
+
if options[:content_licence]
|
110
|
+
concat(options[:content_licence])
|
111
|
+
else
|
112
|
+
concat('All content is available under the')
|
113
|
+
concat(link_to('Open Government Licence v3.0', 'https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/', class: 'govuk-footer__link', rel: 'license'))
|
114
|
+
concat(', except where otherwise stated')
|
115
|
+
end
|
114
116
|
end
|
115
117
|
end
|
116
|
-
end
|
117
118
|
|
118
|
-
|
119
|
-
|
120
|
-
|
119
|
+
# Generates the copyright used in the footer
|
120
|
+
#
|
121
|
+
# @return [ActiveSupport::SafeBuffer]
|
121
122
|
|
122
|
-
|
123
|
-
|
124
|
-
|
123
|
+
def footer_copyright
|
124
|
+
tag.div(class: 'govuk-footer__meta-item') do
|
125
|
+
link_to(options[:copyright], 'https://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/', class: 'govuk-footer__link govuk-footer__copyright-logo')
|
126
|
+
end
|
125
127
|
end
|
126
128
|
end
|
127
129
|
end
|
@@ -1,58 +1,60 @@
|
|
1
1
|
require_relative '../base'
|
2
2
|
require_relative 'error_message'
|
3
3
|
|
4
|
-
module CCS
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
# This helper is used for generating the form group component from the Government Design Systems
|
9
|
-
#
|
10
|
-
# @!attribute [r] attribute
|
11
|
-
# @return [String,Symbol] Attribute that the form group is for
|
12
|
-
# @!attribute [r] error_message
|
13
|
-
# @return [String] Text for the error message
|
14
|
-
|
15
|
-
class FormGroup < Base
|
16
|
-
private
|
17
|
-
|
18
|
-
attr_reader :attribute, :error_message
|
19
|
-
|
20
|
-
public
|
21
|
-
|
22
|
-
# @param attribute [String,Symbol] the attribute that the form group is for
|
23
|
-
# @param error_message [String] (nil) the error message to be displayed
|
24
|
-
# @param options [Hash] options that will be used in customising the HTML
|
4
|
+
module CCS
|
5
|
+
module Components
|
6
|
+
module GovUK
|
7
|
+
# = GOV.UK FormGroup
|
25
8
|
#
|
26
|
-
#
|
27
|
-
#
|
9
|
+
# This helper is used for generating the form group component from the Government Design Systems
|
10
|
+
#
|
11
|
+
# @!attribute [r] attribute
|
12
|
+
# @return [String,Symbol] Attribute that the form group is for
|
13
|
+
# @!attribute [r] error_message
|
14
|
+
# @return [String] Text for the error message
|
28
15
|
|
29
|
-
|
30
|
-
|
16
|
+
class FormGroup < Base
|
17
|
+
private
|
31
18
|
|
32
|
-
|
33
|
-
@options[:attributes][:class][..15] = 'govuk-form-group govuk-form-group--error' if error_message
|
19
|
+
attr_reader :attribute, :error_message
|
34
20
|
|
35
|
-
|
36
|
-
@error_message = error_message
|
37
|
-
end
|
21
|
+
public
|
38
22
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
23
|
+
# @param attribute [String,Symbol] the attribute that the form group is for
|
24
|
+
# @param error_message [String] (nil) the error message to be displayed
|
25
|
+
# @param options [Hash] options that will be used in customising the HTML
|
26
|
+
#
|
27
|
+
# @option options [String] :classes additional CSS classes for the form group HTML
|
28
|
+
# @option options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
|
29
|
+
|
30
|
+
def initialize(attribute:, error_message: nil, **options)
|
31
|
+
super(**options)
|
46
32
|
|
47
|
-
|
48
|
-
|
49
|
-
|
33
|
+
@options[:attributes][:id] ||= "#{attribute}-form-group"
|
34
|
+
@options[:attributes][:class][..15] = 'govuk-form-group govuk-form-group--error' if error_message
|
35
|
+
|
36
|
+
@attribute = attribute
|
37
|
+
@error_message = error_message
|
50
38
|
end
|
51
|
-
end
|
52
39
|
|
53
|
-
|
40
|
+
# Generates the HTML for the GOV.UK Form Group component
|
41
|
+
#
|
42
|
+
# @yield HTML that will be contained within the 'govuk-form-group' div
|
43
|
+
#
|
44
|
+
# @yieldparam displayed_error_message [ActiveSupport::SafeBuffer] the HTML for the error message (if there is one)
|
45
|
+
#
|
46
|
+
# @return [ActiveSupport::SafeBuffer]
|
47
|
+
|
48
|
+
def render
|
49
|
+
tag.div(**options[:attributes]) do
|
50
|
+
yield((ErrorMessage.new(message: error_message, attribute: attribute, context: context).render if error_message))
|
51
|
+
end
|
52
|
+
end
|
54
53
|
|
55
|
-
|
54
|
+
# The default attributes for the form group
|
55
|
+
|
56
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-form-group' }.freeze
|
57
|
+
end
|
56
58
|
end
|
57
59
|
end
|
58
60
|
end
|
@@ -1,50 +1,52 @@
|
|
1
1
|
require_relative '../../base'
|
2
2
|
|
3
|
-
module CCS
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
# The individual header link item
|
9
|
-
#
|
10
|
-
# @!attribute [r] text
|
11
|
-
# @return [String] Text for the header link
|
12
|
-
# @!attribute [r] href
|
13
|
-
# @return [String] The href for the header link
|
14
|
-
|
15
|
-
class Link < Base
|
16
|
-
private
|
17
|
-
|
18
|
-
attr_reader :text, :href
|
19
|
-
|
20
|
-
public
|
21
|
-
|
22
|
-
# @param text [String] the text for the header link
|
23
|
-
# @param href [String] the href for the header link
|
24
|
-
# @param options [Hash] options that will be used in customising the HTML
|
3
|
+
module CCS
|
4
|
+
module Components
|
5
|
+
module GovUK
|
6
|
+
class Header < Base
|
7
|
+
# = GOV.UK Header link
|
25
8
|
#
|
26
|
-
#
|
27
|
-
#
|
9
|
+
# The individual header link item
|
10
|
+
#
|
11
|
+
# @!attribute [r] text
|
12
|
+
# @return [String] Text for the header link
|
13
|
+
# @!attribute [r] href
|
14
|
+
# @return [String] The href for the header link
|
28
15
|
|
29
|
-
|
30
|
-
|
16
|
+
class Link < Base
|
17
|
+
private
|
31
18
|
|
32
|
-
|
33
|
-
@href = href
|
34
|
-
end
|
19
|
+
attr_reader :text, :href
|
35
20
|
|
36
|
-
|
37
|
-
|
38
|
-
|
21
|
+
public
|
22
|
+
|
23
|
+
# @param text [String] the text for the header link
|
24
|
+
# @param href [String] the href for the header link
|
25
|
+
# @param options [Hash] options that will be used in customising the HTML
|
26
|
+
#
|
27
|
+
# @option options [Boolean] :active flag to mark the navigation item as active or not
|
28
|
+
# @option options [Hash] :attributes any additional attributes that will added as part of the HTML
|
29
|
+
|
30
|
+
def initialize(text:, href: nil, **options)
|
31
|
+
super(**options)
|
32
|
+
|
33
|
+
@text = text
|
34
|
+
@href = href
|
35
|
+
end
|
36
|
+
|
37
|
+
# Generates the HTML for the GOV.UK Header link
|
38
|
+
#
|
39
|
+
# @return [ActiveSupport::SafeBuffer]
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
def render
|
42
|
+
tag.li(class: "govuk-header__navigation-item #{'govuk-header__navigation-item--active' if options[:active]}".rstrip) do
|
43
|
+
if href
|
44
|
+
options[:attributes][:class] = 'govuk-header__link'
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
link_to(text, href, **options[:attributes])
|
47
|
+
else
|
48
|
+
text
|
49
|
+
end
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|