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,57 +1,59 @@
|
|
1
1
|
require_relative '../base'
|
2
2
|
require_relative 'step_by_step_navigation/section'
|
3
3
|
|
4
|
-
module CCS
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
# This is used for generating the Step by step navigation component from the
|
9
|
-
# {https://design-system.service.gov.uk/patterns/step-by-step-navigation/ GDS - Pages - Step by step navigation}
|
10
|
-
#
|
11
|
-
# @!attribute [r] step_by_step_navigation_sections
|
12
|
-
# @return [Array<Section>] An array of the initialised step by step navigation sections
|
13
|
-
|
14
|
-
class StepByStepNavigation < Base
|
15
|
-
private
|
16
|
-
|
17
|
-
attr_reader :step_by_step_navigation_sections
|
18
|
-
|
19
|
-
public
|
20
|
-
|
21
|
-
# @param step_by_step_navigation_sections [Array<Hash>] An array of options for the step by step navigation section.
|
22
|
-
# See {Components::GovUK::StepByStepNavigation::Section#initialize Section#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 Step by step navigation
|
24
8
|
#
|
25
|
-
#
|
26
|
-
#
|
9
|
+
# This is used for generating the Step by step navigation component from the
|
10
|
+
# {https://design-system.service.gov.uk/patterns/step-by-step-navigation/ GDS - Pages - Step by step navigation}
|
11
|
+
#
|
12
|
+
# @!attribute [r] step_by_step_navigation_sections
|
13
|
+
# @return [Array<Section>] An array of the initialised step by step navigation sections
|
27
14
|
|
28
|
-
|
29
|
-
|
15
|
+
class StepByStepNavigation < Base
|
16
|
+
private
|
30
17
|
|
31
|
-
|
18
|
+
attr_reader :step_by_step_navigation_sections
|
32
19
|
|
33
|
-
|
34
|
-
end
|
20
|
+
public
|
35
21
|
|
36
|
-
|
37
|
-
|
38
|
-
|
22
|
+
# @param step_by_step_navigation_sections [Array<Hash>] An array of options for the step by step navigation section.
|
23
|
+
# See {Components::GovUK::StepByStepNavigation::Section#initialize Section#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 step by step navigation HTML
|
27
|
+
# @option options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
|
28
|
+
|
29
|
+
def initialize(step_by_step_navigation_sections:, **options)
|
30
|
+
super(**options)
|
31
|
+
|
32
|
+
DEFAULT_SHOW_HIDE_TEXT.each { |key, value| @options[:attributes][:data][key] ||= value }
|
39
33
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
34
|
+
@step_by_step_navigation_sections = step_by_step_navigation_sections.map.with_index(1) { |step_by_step_section, index| Section.new(index: index.to_s, context: @context, **step_by_step_section) }
|
35
|
+
end
|
36
|
+
|
37
|
+
# Generates the HTML for the GOV.UK Step by step navigation component (experimental)
|
38
|
+
#
|
39
|
+
# @return [ActiveSupport::SafeBuffer]
|
40
|
+
|
41
|
+
def render
|
42
|
+
tag.div(**options[:attributes]) do
|
43
|
+
tag.ol(class: 'gem-c-step-nav__steps') do
|
44
|
+
step_by_step_navigation_sections.each { |step_by_step_navigation_section| concat(step_by_step_navigation_section.render) }
|
45
|
+
end
|
44
46
|
end
|
45
47
|
end
|
46
|
-
end
|
47
48
|
|
48
|
-
|
49
|
+
# The default attributes for the step byt step navigation
|
49
50
|
|
50
|
-
|
51
|
+
DEFAULT_ATTRIBUTES = { class: 'gem-c-step-nav gem-c-step-nav--large gem-c-step-nav--active', data: { module: 'govuk-step-by-step-navigation' } }.freeze
|
51
52
|
|
52
|
-
|
53
|
+
# Default text for the show and hide buttons which are part of each section
|
53
54
|
|
54
|
-
|
55
|
+
DEFAULT_SHOW_HIDE_TEXT = { 'show-text': 'Show', 'hide-text': 'Hide', 'show-all-text': 'Show all', 'hide-all-text': 'Hide all' }.freeze
|
56
|
+
end
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|
@@ -1,55 +1,57 @@
|
|
1
1
|
require_relative '../../../base'
|
2
2
|
|
3
|
-
module CCS
|
4
|
-
module
|
5
|
-
|
6
|
-
class
|
7
|
-
|
8
|
-
|
9
|
-
# @!attribute [r] text
|
10
|
-
# @return [String] Text for the action link
|
11
|
-
# @!attribute [r] href
|
12
|
-
# @return [String] The href for the action link
|
13
|
-
# @!attribute [r] visually_hidden_text
|
14
|
-
# @return [String] Visually hidden text for the action link
|
15
|
-
|
16
|
-
class Link < Base
|
17
|
-
private
|
18
|
-
|
19
|
-
attr_reader :text, :href, :visually_hidden_text
|
20
|
-
|
21
|
-
public
|
22
|
-
|
23
|
-
# @param text [String] the text for the action link
|
24
|
-
# @param href [String] the href for the action link
|
25
|
-
# @param visually_hidden_text [String] optional visually hidden text for the action link
|
26
|
-
# @param options [Hash] options that will be used in customising the HTML
|
3
|
+
module CCS
|
4
|
+
module Components
|
5
|
+
module GovUK
|
6
|
+
class SummaryList < Base
|
7
|
+
class Action
|
8
|
+
# = GOV.UK Summary list action link
|
27
9
|
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
|
31
|
-
|
32
|
-
|
10
|
+
# @!attribute [r] text
|
11
|
+
# @return [String] Text for the action link
|
12
|
+
# @!attribute [r] href
|
13
|
+
# @return [String] The href for the action link
|
14
|
+
# @!attribute [r] visually_hidden_text
|
15
|
+
# @return [String] Visually hidden text for the action link
|
16
|
+
|
17
|
+
class Link < Base
|
18
|
+
private
|
19
|
+
|
20
|
+
attr_reader :text, :href, :visually_hidden_text
|
21
|
+
|
22
|
+
public
|
23
|
+
|
24
|
+
# @param text [String] the text for the action link
|
25
|
+
# @param href [String] the href for the action link
|
26
|
+
# @param visually_hidden_text [String] optional visually hidden text for the action 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 summary list action link HTML
|
30
|
+
# @option options [Hash] :attributes any additional attributes that will added as part of the HTML
|
31
|
+
|
32
|
+
def initialize(text:, href:, visually_hidden_text: nil, **options)
|
33
|
+
super(**options)
|
34
|
+
|
35
|
+
@text = text
|
36
|
+
@href = href
|
37
|
+
@visually_hidden_text = visually_hidden_text
|
38
|
+
end
|
33
39
|
|
34
|
-
|
35
|
-
|
36
|
-
@
|
37
|
-
end
|
40
|
+
# Generates the HTML for the GOV.UK Summary list action link
|
41
|
+
#
|
42
|
+
# @return [ActiveSupport::SafeBuffer]
|
38
43
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
link_to(href, **@options[:attributes]) do
|
45
|
-
concat(text)
|
46
|
-
concat(tag.span(visually_hidden_text, class: 'govuk-visually-hidden')) if visually_hidden_text
|
44
|
+
def render
|
45
|
+
link_to(href, **@options[:attributes]) do
|
46
|
+
concat(text)
|
47
|
+
concat(tag.span(visually_hidden_text, class: 'govuk-visually-hidden')) if visually_hidden_text
|
48
|
+
end
|
47
49
|
end
|
48
|
-
end
|
49
50
|
|
50
|
-
|
51
|
+
# The default attributes for the summary list action link
|
51
52
|
|
52
|
-
|
53
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-link' }.freeze
|
54
|
+
end
|
53
55
|
end
|
54
56
|
end
|
55
57
|
end
|
@@ -1,55 +1,57 @@
|
|
1
1
|
require_relative '../../../base'
|
2
2
|
require_relative '../action/link'
|
3
3
|
|
4
|
-
module CCS
|
5
|
-
module
|
6
|
-
|
7
|
-
class
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
module CCS
|
5
|
+
module Components
|
6
|
+
module GovUK
|
7
|
+
class SummaryList < Base
|
8
|
+
class Card < Base
|
9
|
+
# = GOV.UK Summary list card actions
|
10
|
+
#
|
11
|
+
# @!attribute [r] action_links
|
12
|
+
# @return [Array<Action::Link>] An array of the initialised aummary list card action links
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
class Actions < Base
|
15
|
+
private
|
15
16
|
|
16
|
-
|
17
|
+
attr_reader :action_links
|
17
18
|
|
18
|
-
|
19
|
+
public
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
# @param items [Array<Hash>] An array of attributes for the action links.
|
22
|
+
# See {Components::GovUK::SummaryList::Action::Link#initialize Action::Link#initialize} for details of the items in the array.
|
23
|
+
# @param options [Hash] options that will be used in customising the HTML
|
24
|
+
#
|
25
|
+
# @option options [String] :classes additional CSS classes for the summary list card actions HTML
|
25
26
|
|
26
|
-
|
27
|
-
|
27
|
+
def initialize(items:, **options)
|
28
|
+
super(**options)
|
28
29
|
|
29
|
-
|
30
|
-
|
30
|
+
@action_links = items.map { |item| Action::Link.new(context: @context, **item) }
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
# Generates the HTML for the GOV.UK Summary list card actions
|
34
|
+
#
|
35
|
+
# @return [ActiveSupport::SafeBuffer]
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
37
|
+
def render
|
38
|
+
if action_links.length == 1
|
39
|
+
tag.div(class: @options[:attributes][:class]) do
|
40
|
+
action_links.first.render
|
41
|
+
end
|
42
|
+
else
|
43
|
+
tag.ul(class: @options[:attributes][:class]) do
|
44
|
+
action_links.each do |action_link|
|
45
|
+
concat(tag.li(action_link.render, class: 'govuk-summary-card__action'))
|
46
|
+
end
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
48
|
-
end
|
49
50
|
|
50
|
-
|
51
|
+
# The default attributes for the summary list card actions
|
51
52
|
|
52
|
-
|
53
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-summary-card__actions' }.freeze
|
54
|
+
end
|
53
55
|
end
|
54
56
|
end
|
55
57
|
end
|
@@ -1,47 +1,49 @@
|
|
1
1
|
require_relative '../../../base'
|
2
2
|
|
3
|
-
module CCS
|
4
|
-
module
|
5
|
-
|
6
|
-
class
|
7
|
-
|
8
|
-
|
9
|
-
# @!attribute [r] text
|
10
|
-
# @return [String] Text for the title
|
11
|
-
# @!attribute [r] heading_level
|
12
|
-
# @return [String] Heading level for the title
|
13
|
-
|
14
|
-
class Title < Base
|
15
|
-
private
|
16
|
-
|
17
|
-
attr_reader :text, :heading_level
|
18
|
-
|
19
|
-
public
|
20
|
-
|
21
|
-
# @param text [String] the text for the title
|
22
|
-
# @param heading_level [String] heading level, from 1 to 6
|
23
|
-
# @param options [Hash] options that will be used in customising the HTML
|
3
|
+
module CCS
|
4
|
+
module Components
|
5
|
+
module GovUK
|
6
|
+
class SummaryList < Base
|
7
|
+
class Card < Base
|
8
|
+
# = GOV.UK Summary list card title
|
24
9
|
#
|
25
|
-
#
|
10
|
+
# @!attribute [r] text
|
11
|
+
# @return [String] Text for the title
|
12
|
+
# @!attribute [r] heading_level
|
13
|
+
# @return [String] Heading level for the title
|
26
14
|
|
27
|
-
|
28
|
-
|
15
|
+
class Title < Base
|
16
|
+
private
|
29
17
|
|
30
|
-
|
31
|
-
@heading_level = heading_level
|
32
|
-
end
|
18
|
+
attr_reader :text, :heading_level
|
33
19
|
|
34
|
-
|
35
|
-
#
|
36
|
-
# @return [ActiveSupport::SafeBuffer]
|
20
|
+
public
|
37
21
|
|
38
|
-
|
39
|
-
|
40
|
-
|
22
|
+
# @param text [String] the text for the title
|
23
|
+
# @param heading_level [String] heading level, from 1 to 6
|
24
|
+
# @param options [Hash] options that will be used in customising the HTML
|
25
|
+
#
|
26
|
+
# @option options [String] :classes additional CSS classes for the summary list card title HTML
|
27
|
+
|
28
|
+
def initialize(text:, heading_level: '2', **options)
|
29
|
+
super(**options)
|
41
30
|
|
42
|
-
|
31
|
+
@text = text
|
32
|
+
@heading_level = heading_level
|
33
|
+
end
|
43
34
|
|
44
|
-
|
35
|
+
# Generates the HTML for the GOV.UK Summary list card title
|
36
|
+
#
|
37
|
+
# @return [ActiveSupport::SafeBuffer]
|
38
|
+
|
39
|
+
def render
|
40
|
+
tag.send("h#{heading_level}", text, class: @options[:attributes][:class])
|
41
|
+
end
|
42
|
+
|
43
|
+
# The default attributes for the summary list card title
|
44
|
+
|
45
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-summary-card__title' }.freeze
|
46
|
+
end
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
@@ -2,59 +2,61 @@ require_relative '../../base'
|
|
2
2
|
require_relative 'card/title'
|
3
3
|
require_relative 'card/actions'
|
4
4
|
|
5
|
-
module CCS
|
6
|
-
module
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
# This is used for generating the summary cards component from the
|
11
|
-
# {https://design-system.service.gov.uk/components/summary-list/#summary-cards GDS - Components - Summary cards}
|
12
|
-
#
|
13
|
-
# @!attribute [r] title
|
14
|
-
# @return [Title] Initialised summary card title
|
15
|
-
# @!attribute [r] actions
|
16
|
-
# @return [Actions] Initialised summary card actions
|
17
|
-
|
18
|
-
class Card < Base
|
19
|
-
private
|
20
|
-
|
21
|
-
attr_reader :title, :actions
|
22
|
-
|
23
|
-
public
|
24
|
-
|
25
|
-
# @param title [Hash] attributes for the title, see {CCS::Components::GovUK::SummaryList::Card::Title#initialize Title#initialize} for more details.
|
26
|
-
# @param actions [Hash] attributes for the actions, see {CCS::Components::GovUK::SummaryList::Card::Actions#initialize Actions#initialize} for more details.
|
27
|
-
# @param options [Hash] options that will be used in customising the HTML
|
5
|
+
module CCS
|
6
|
+
module Components
|
7
|
+
module GovUK
|
8
|
+
class SummaryList < Base
|
9
|
+
# = GOV.UK Summary card
|
28
10
|
#
|
29
|
-
#
|
30
|
-
#
|
11
|
+
# This is used for generating the summary cards component from the
|
12
|
+
# {https://design-system.service.gov.uk/components/summary-list/#summary-cards GDS - Components - Summary cards}
|
13
|
+
#
|
14
|
+
# @!attribute [r] title
|
15
|
+
# @return [Title] Initialised summary card title
|
16
|
+
# @!attribute [r] actions
|
17
|
+
# @return [Actions] Initialised summary card actions
|
31
18
|
|
32
|
-
|
33
|
-
|
19
|
+
class Card < Base
|
20
|
+
private
|
34
21
|
|
35
|
-
|
36
|
-
@actions = Actions.new(context: @context, **actions) if actions
|
37
|
-
end
|
22
|
+
attr_reader :title, :actions
|
38
23
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
24
|
+
public
|
25
|
+
|
26
|
+
# @param title [Hash] attributes for the title, see {CCS::Components::GovUK::SummaryList::Card::Title#initialize Title#initialize} for more details.
|
27
|
+
# @param actions [Hash] attributes for the actions, see {CCS::Components::GovUK::SummaryList::Card::Actions#initialize Actions#initialize} for more details.
|
28
|
+
# @param options [Hash] options that will be used in customising the HTML
|
29
|
+
#
|
30
|
+
# @option options [String] :classes additional CSS classes for the summary card HTML
|
31
|
+
# @option options [Hash] :attributes any additional attributes that will be added as part of the HTML
|
32
|
+
|
33
|
+
def initialize(title: nil, actions: nil, **options)
|
34
|
+
super(**options)
|
35
|
+
|
36
|
+
@title = Title.new(context: @context, **title) if title
|
37
|
+
@actions = Actions.new(context: @context, **actions) if actions
|
52
38
|
end
|
53
|
-
end
|
54
39
|
|
55
|
-
|
40
|
+
# Generates the HTML for the GOV.UK Summary card
|
41
|
+
#
|
42
|
+
# @yield the HTML for the summary list
|
43
|
+
#
|
44
|
+
# @return [ActiveSupport::SafeBuffer]
|
45
|
+
|
46
|
+
def render(&block)
|
47
|
+
tag.div(**@options[:attributes]) do
|
48
|
+
concat(tag.div(class: 'govuk-summary-card__title-wrapper') do
|
49
|
+
concat(title.render) if title
|
50
|
+
concat(actions.render) if actions
|
51
|
+
end)
|
52
|
+
concat(tag.div(class: 'govuk-summary-card__content', &block))
|
53
|
+
end
|
54
|
+
end
|
56
55
|
|
57
|
-
|
56
|
+
# The default attributes for the summary card
|
57
|
+
|
58
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-summary-card' }.freeze
|
59
|
+
end
|
58
60
|
end
|
59
61
|
end
|
60
62
|
end
|
@@ -1,55 +1,57 @@
|
|
1
1
|
require_relative '../../../base'
|
2
2
|
require_relative '../action/link'
|
3
3
|
|
4
|
-
module CCS
|
5
|
-
module
|
6
|
-
|
7
|
-
class
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
module CCS
|
5
|
+
module Components
|
6
|
+
module GovUK
|
7
|
+
class SummaryList < Base
|
8
|
+
class Row < Base
|
9
|
+
# = GOV.UK Summary list row actions
|
10
|
+
#
|
11
|
+
# @!attribute [r] action_links
|
12
|
+
# @return [Array<Action::Link>] An array of the initialised aummary list row action links
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
class Actions < Base
|
15
|
+
private
|
15
16
|
|
16
|
-
|
17
|
+
attr_reader :action_links
|
17
18
|
|
18
|
-
|
19
|
+
public
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
# @param items [Array<Hash>] An array of attributes for the action links.
|
22
|
+
# See {Components::GovUK::SummaryList::Action::Link#initialize Action::Link#initialize} for details of the items in the array.
|
23
|
+
# @param options [Hash] options that will be used in customising the HTML
|
24
|
+
#
|
25
|
+
# @option options [String] :classes additional CSS classes for the summary list row actions HTML
|
25
26
|
|
26
|
-
|
27
|
-
|
27
|
+
def initialize(items:, **options)
|
28
|
+
super(**options)
|
28
29
|
|
29
|
-
|
30
|
-
|
30
|
+
@action_links = items.map { |item| Action::Link.new(context: @context, **item) }
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
33
|
+
# Generates the HTML for the GOV.UK Summary list row actions
|
34
|
+
#
|
35
|
+
# @return [ActiveSupport::SafeBuffer]
|
36
|
+
|
37
|
+
def render
|
38
|
+
tag.dd(class: @options[:attributes][:class]) do
|
39
|
+
if action_links.length == 1
|
40
|
+
action_links.first.render
|
41
|
+
else
|
42
|
+
tag.ul(class: 'govuk-summary-list__actions-list') do
|
43
|
+
action_links.each do |action_link|
|
44
|
+
concat(tag.li(action_link.render, class: 'govuk-summary-list__actions-list-item'))
|
45
|
+
end
|
44
46
|
end
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
48
|
-
end
|
49
50
|
|
50
|
-
|
51
|
+
# The default attributes for the summary list row actions
|
51
52
|
|
52
|
-
|
53
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-summary-list__actions' }.freeze
|
54
|
+
end
|
53
55
|
end
|
54
56
|
end
|
55
57
|
end
|