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,49 +1,51 @@
|
|
1
1
|
require_relative '../base'
|
2
2
|
|
3
|
-
module CCS
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
# This is used to generate the skip link component from the
|
8
|
-
# {https://design-system.service.gov.uk/components/skip-link GDS - Components - Skip link}
|
9
|
-
#
|
10
|
-
# @!attribute [r] text
|
11
|
-
# @return [String] Text for the skip link
|
12
|
-
# @!attribute [r] href
|
13
|
-
# @return [String] The href for the skip link
|
14
|
-
|
15
|
-
class SkipLink < Base
|
16
|
-
private
|
17
|
-
|
18
|
-
attr_reader :text, :href
|
19
|
-
|
20
|
-
public
|
21
|
-
|
22
|
-
# @param text [String] the text for the skip link
|
23
|
-
# @param href [String] the href for the skip link
|
24
|
-
# @param options [Hash] options that will be used in customising the HTML
|
3
|
+
module CCS
|
4
|
+
module Components
|
5
|
+
module GovUK
|
6
|
+
# = GOV.UK Skip Link
|
25
7
|
#
|
26
|
-
#
|
27
|
-
#
|
8
|
+
# This is used to generate the skip link component from the
|
9
|
+
# {https://design-system.service.gov.uk/components/skip-link GDS - Components - Skip link}
|
10
|
+
#
|
11
|
+
# @!attribute [r] text
|
12
|
+
# @return [String] Text for the skip link
|
13
|
+
# @!attribute [r] href
|
14
|
+
# @return [String] The href for the skip link
|
28
15
|
|
29
|
-
|
30
|
-
|
16
|
+
class SkipLink < Base
|
17
|
+
private
|
31
18
|
|
32
|
-
|
33
|
-
@href = href || '#content'
|
34
|
-
end
|
19
|
+
attr_reader :text, :href
|
35
20
|
|
36
|
-
|
37
|
-
#
|
38
|
-
# @return [ActiveSupport::SafeBuffer]
|
21
|
+
public
|
39
22
|
|
40
|
-
|
41
|
-
|
42
|
-
|
23
|
+
# @param text [String] the text for the skip link
|
24
|
+
# @param href [String] the href for the skip link
|
25
|
+
# @param options [Hash] options that will be used in customising the HTML
|
26
|
+
#
|
27
|
+
# @option options [String] :classes additional CSS classes for the skip link HTML
|
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)
|
43
32
|
|
44
|
-
|
33
|
+
@text = text
|
34
|
+
@href = href || '#content'
|
35
|
+
end
|
45
36
|
|
46
|
-
|
37
|
+
# Generates the HTML for the GOV.UK Skip link component
|
38
|
+
#
|
39
|
+
# @return [ActiveSupport::SafeBuffer]
|
40
|
+
|
41
|
+
def render
|
42
|
+
link_to(text, href, **options[:attributes])
|
43
|
+
end
|
44
|
+
|
45
|
+
# The default attributes for the skip link
|
46
|
+
|
47
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-skip-link', data: { module: 'govuk-skip-link' } }.freeze
|
48
|
+
end
|
47
49
|
end
|
48
50
|
end
|
49
51
|
end
|
@@ -1,45 +1,47 @@
|
|
1
1
|
require 'action_view'
|
2
2
|
|
3
|
-
module CCS
|
4
|
-
module
|
5
|
-
|
6
|
-
class
|
7
|
-
class
|
8
|
-
class
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
# @!attribute [r] text
|
14
|
-
# @return [String] Text for the list item
|
15
|
-
# @!attribute [r] classes
|
16
|
-
# @return [String] HTML classes for the list item
|
17
|
-
|
18
|
-
class Item
|
19
|
-
include ActionView::Context
|
20
|
-
include ActionView::Helpers
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
attr_reader :text, :classes
|
25
|
-
|
26
|
-
public
|
27
|
-
|
28
|
-
# @param text [String] the text for the list item
|
29
|
-
# @param no_marker [Boolean] flag to hide the bullet marker
|
30
|
-
|
31
|
-
def initialize(text:, no_marker: nil)
|
32
|
-
@text = text
|
33
|
-
@classes = "gem-c-step-nav__list-item js-list-item #{'gem-c-step-nav__list--no-marker' if no_marker}".rstrip
|
34
|
-
end
|
35
|
-
|
36
|
-
# Generates the HTML for an individual the GOV.UK Step by step navigation list item
|
3
|
+
module CCS
|
4
|
+
module Components
|
5
|
+
module GovUK
|
6
|
+
class StepByStepNavigation < Base
|
7
|
+
class Section < Base
|
8
|
+
class Content
|
9
|
+
class List
|
10
|
+
# = GOV.UK Step by step navigation section content list item
|
11
|
+
#
|
12
|
+
# Generates the list item HTML for the step by step navigation section content
|
37
13
|
#
|
38
|
-
#
|
14
|
+
# @!attribute [r] text
|
15
|
+
# @return [String] Text for the list item
|
16
|
+
# @!attribute [r] classes
|
17
|
+
# @return [String] HTML classes for the list item
|
18
|
+
|
19
|
+
class Item
|
20
|
+
include ActionView::Context
|
21
|
+
include ActionView::Helpers
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
attr_reader :text, :classes
|
26
|
+
|
27
|
+
public
|
28
|
+
|
29
|
+
# @param text [String] the text for the list item
|
30
|
+
# @param no_marker [Boolean] flag to hide the bullet marker
|
31
|
+
|
32
|
+
def initialize(text:, no_marker: nil)
|
33
|
+
@text = text
|
34
|
+
@classes = "gem-c-step-nav__list-item js-list-item #{'gem-c-step-nav__list--no-marker' if no_marker}".rstrip
|
35
|
+
end
|
36
|
+
|
37
|
+
# Generates the HTML for an individual the GOV.UK Step by step navigation list item
|
38
|
+
#
|
39
|
+
# @return [ActiveSupport::SafeBuffer]
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
def render
|
42
|
+
tag.li(class: classes) do
|
43
|
+
tag.span(text)
|
44
|
+
end
|
43
45
|
end
|
44
46
|
end
|
45
47
|
end
|
@@ -2,42 +2,44 @@ require 'action_view'
|
|
2
2
|
|
3
3
|
require_relative 'list/item'
|
4
4
|
|
5
|
-
module CCS
|
6
|
-
module
|
7
|
-
|
8
|
-
class
|
9
|
-
class
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
module CCS
|
6
|
+
module Components
|
7
|
+
module GovUK
|
8
|
+
class StepByStepNavigation < Base
|
9
|
+
class Section < Base
|
10
|
+
class Content
|
11
|
+
# = GOV.UK Step by step navigation section content list
|
12
|
+
#
|
13
|
+
# Generates the list HTML for the step by step navigation section content
|
14
|
+
#
|
15
|
+
# @!attribute [r] items
|
16
|
+
# @return [Item] Array of initialised list items
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
class List
|
19
|
+
include ActionView::Context
|
20
|
+
include ActionView::Helpers
|
20
21
|
|
21
|
-
|
22
|
+
private
|
22
23
|
|
23
|
-
|
24
|
+
attr_reader :items
|
24
25
|
|
25
|
-
|
26
|
+
public
|
26
27
|
|
27
|
-
|
28
|
-
|
28
|
+
# @param items [Array<Hash>] An array of options for the list items
|
29
|
+
# See {Components::GovUK::StepByStepNavigation::Section::Content::List::Item#initialize Item#initialize} for details of the items in the array.
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
def initialize(items:)
|
32
|
+
@items = items.map { |item| Item.new(**item) }
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
# Generates the HTML for the GOV.UK Step by step navigation section content list
|
36
|
+
#
|
37
|
+
# @return [ActiveSupport::SafeBuffer]
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
def render
|
40
|
+
tag.ul(class: 'gem-c-step-nav__list gem-c-step-nav__list--choice', data: { length: items.length.to_s }) do
|
41
|
+
items.each { |item| concat(item.render) }
|
42
|
+
end
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
@@ -1,39 +1,41 @@
|
|
1
1
|
require 'action_view'
|
2
2
|
|
3
|
-
module CCS
|
4
|
-
module
|
5
|
-
|
6
|
-
class
|
7
|
-
class
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
3
|
+
module CCS
|
4
|
+
module Components
|
5
|
+
module GovUK
|
6
|
+
class StepByStepNavigation < Base
|
7
|
+
class Section < Base
|
8
|
+
class Content
|
9
|
+
# = GOV.UK Step by step navigation section content paragraph
|
10
|
+
#
|
11
|
+
# Generates the paragraph HTML for the step by step navigation section content
|
12
|
+
#
|
13
|
+
# @!attribute [r] text
|
14
|
+
# @return [String] Text for the paragraph
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
class Paragraph
|
17
|
+
include ActionView::Context
|
18
|
+
include ActionView::Helpers
|
18
19
|
|
19
|
-
|
20
|
+
private
|
20
21
|
|
21
|
-
|
22
|
+
attr_reader :text
|
22
23
|
|
23
|
-
|
24
|
+
public
|
24
25
|
|
25
|
-
|
26
|
+
# @param text [String] the text for the paragraph
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
def initialize(text:)
|
29
|
+
@text = text
|
30
|
+
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
# Generates the HTML for the GOV.UK Step by step navigation section content paragraph
|
33
|
+
#
|
34
|
+
# @return [ActiveSupport::SafeBuffer]
|
34
35
|
|
35
|
-
|
36
|
-
|
36
|
+
def render
|
37
|
+
tag.p(text, class: 'gem-c-step-nav__paragraph')
|
38
|
+
end
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
@@ -3,55 +3,57 @@ require 'action_view'
|
|
3
3
|
require_relative 'content/list'
|
4
4
|
require_relative 'content/paragraph'
|
5
5
|
|
6
|
-
module CCS
|
7
|
-
module
|
8
|
-
|
9
|
-
class
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
6
|
+
module CCS
|
7
|
+
module Components
|
8
|
+
module GovUK
|
9
|
+
class StepByStepNavigation < Base
|
10
|
+
class Section < Base
|
11
|
+
# = GOV.UK Step by step navigation section content
|
12
|
+
#
|
13
|
+
# The content for a navigation section
|
14
|
+
#
|
15
|
+
# @!attribute [r] section_id
|
16
|
+
# @return [String] ID for the section content
|
17
|
+
# @!attribute [r] content_items
|
18
|
+
# @return [Array<Paragraph|List>] An array of the initialised content items
|
19
|
+
|
20
|
+
class Content
|
21
|
+
include ActionView::Context
|
22
|
+
include ActionView::Helpers
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
attr_reader :section_id, :content_items
|
27
|
+
|
28
|
+
public
|
29
|
+
|
30
|
+
# @param content_items [Array<Hash>] array of content items.
|
31
|
+
# If the type is +:paragraph+, see {Components::GovUK::StepByStepNavigation::Section::Content::Paragraph#initialize Paragraph#initialize}.
|
32
|
+
# If the type is +:list+, see {Components::GovUK::StepByStepNavigation::Section::Content::List#initialize List#initialize}.
|
33
|
+
# @param index [String] the index of the section
|
34
|
+
# @param id [String] the id of the section
|
35
|
+
|
36
|
+
def initialize(content_items:, index:, id:)
|
37
|
+
@section_id = "step-panel-#{id}-#{index}"
|
38
|
+
|
39
|
+
@content_items = content_items.map do |content_item|
|
40
|
+
case content_item[:type]
|
41
|
+
when :paragraph
|
42
|
+
Paragraph.new(text: content_item[:text])
|
43
|
+
when :list
|
44
|
+
List.new(items: content_item[:items])
|
45
|
+
end
|
44
46
|
end
|
45
47
|
end
|
46
|
-
end
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
# Generates the HTML for the GOV.UK Step by step navigation section content
|
50
|
+
#
|
51
|
+
# @return [ActiveSupport::SafeBuffer]
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
53
|
+
def render
|
54
|
+
tag.div(class: 'gem-c-step-nav__panel js-panel', id: section_id) do
|
55
|
+
content_items.each { |content_item| concat(content_item.render) }
|
56
|
+
end
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|
@@ -1,65 +1,67 @@
|
|
1
1
|
require 'action_view'
|
2
2
|
|
3
|
-
module CCS
|
4
|
-
module
|
5
|
-
|
6
|
-
class
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
3
|
+
module CCS
|
4
|
+
module Components
|
5
|
+
module GovUK
|
6
|
+
class StepByStepNavigation < Base
|
7
|
+
class Section < Base
|
8
|
+
# = GOV.UK Step by step navigation section heading
|
9
|
+
#
|
10
|
+
# The heading for a navigation section
|
11
|
+
#
|
12
|
+
# @!attribute [r] text
|
13
|
+
# @return [String] Text for the section heading
|
14
|
+
# @!attribute [r] index
|
15
|
+
# @return [String] Index of the section
|
16
|
+
# @!attribute [r] logic
|
17
|
+
# @return [String] Optional text to show in the sidebar
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
class Heading
|
20
|
+
include ActionView::Context
|
21
|
+
include ActionView::Helpers
|
21
22
|
|
22
|
-
|
23
|
+
private
|
23
24
|
|
24
|
-
|
25
|
+
attr_reader :text, :index, :logic
|
25
26
|
|
26
|
-
|
27
|
+
public
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
# @param text [String] text for the section heading
|
30
|
+
# @param index [String] the index of the section
|
31
|
+
# @param logic [String] text to show instead of a number in the sidebar
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
def initialize(text:, index:, logic: nil)
|
34
|
+
@text = text
|
35
|
+
@index = index
|
36
|
+
@logic = logic
|
37
|
+
end
|
37
38
|
|
38
|
-
|
39
|
+
# rubocop:disable Metrics/AbcSize
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
# Generates the HTML for the GOV.UK Step by step navigation section heading
|
42
|
+
#
|
43
|
+
# @return [ActiveSupport::SafeBuffer]
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
45
|
+
def render
|
46
|
+
tag.div(class: 'gem-c-step-nav__header js-toggle-panel', data: { position: index }) do
|
47
|
+
tag.h2(class: 'gem-c-step-nav__title') do
|
48
|
+
concat(tag.span(class: "gem-c-step-nav__circle gem-c-step-nav__circle--#{logic ? 'logic' : 'number'}") do
|
49
|
+
tag.span(class: 'gem-c-step-nav__circle-inner') do
|
50
|
+
tag.span(class: 'gem-c-step-nav__circle-background') do
|
51
|
+
concat(tag.span('Step', class: 'govuk-visually-hidden'))
|
52
|
+
concat(logic || index)
|
53
|
+
end
|
52
54
|
end
|
53
|
-
end
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
55
|
+
end)
|
56
|
+
concat(tag.span(class: 'js-step-title') do
|
57
|
+
tag.span(text, class: 'js-step-title-text')
|
58
|
+
end)
|
59
|
+
end
|
58
60
|
end
|
59
61
|
end
|
60
|
-
end
|
61
62
|
|
62
|
-
|
63
|
+
# rubocop:enable Metrics/AbcSize
|
64
|
+
end
|
63
65
|
end
|
64
66
|
end
|
65
67
|
end
|
@@ -2,50 +2,52 @@ require_relative '../../base'
|
|
2
2
|
require_relative 'section/heading'
|
3
3
|
require_relative 'section/content'
|
4
4
|
|
5
|
-
module CCS
|
6
|
-
module
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
# @!attribute [r] heading
|
13
|
-
# @return [Heading] Initialised heading for the section
|
14
|
-
# @!attribute [r] content
|
15
|
-
# @return [Content] Initialised content for the section
|
16
|
-
|
17
|
-
class Section < Base
|
18
|
-
private
|
19
|
-
|
20
|
-
attr_reader :heading, :content
|
21
|
-
|
22
|
-
public
|
23
|
-
|
24
|
-
# @param heading [Hash] options for the section heading.
|
25
|
-
# See {Components::GovUK::StepByStepNavigation::Section::Heading#initialize Heading#initialize} for details of the options.
|
26
|
-
# @param content [Hash] options for the section content.
|
27
|
-
# See {Components::GovUK::StepByStepNavigation::Section::Content#initialize Content#initialize} for details of the options.
|
28
|
-
# @param index [String] the index of the section
|
29
|
-
# @param context [ActionView::Base] the view context
|
30
|
-
|
31
|
-
def initialize(heading:, content:, index:, context:)
|
32
|
-
super(context: context)
|
33
|
-
|
34
|
-
@options[:attributes][:class] = 'gem-c-step-nav__step js-step'
|
35
|
-
@options[:attributes][:id] = heading[:text].downcase.gsub(' ', '-').gsub('(', '').gsub(')', '')
|
36
|
-
|
37
|
-
@heading = Heading.new(index: index, **heading)
|
38
|
-
@content = Content.new(content_items: content, index: index, id: @options[:attributes][:id])
|
39
|
-
end
|
40
|
-
|
41
|
-
# Generates the HTML for the GOV.UK Step by step navigation section
|
5
|
+
module CCS
|
6
|
+
module Components
|
7
|
+
module GovUK
|
8
|
+
class StepByStepNavigation < Base
|
9
|
+
# = GOV.UK Step by step navigation section
|
10
|
+
#
|
11
|
+
# The individual section for the step by step navigation
|
42
12
|
#
|
43
|
-
#
|
13
|
+
# @!attribute [r] heading
|
14
|
+
# @return [Heading] Initialised heading for the section
|
15
|
+
# @!attribute [r] content
|
16
|
+
# @return [Content] Initialised content for the section
|
17
|
+
|
18
|
+
class Section < Base
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :heading, :content
|
22
|
+
|
23
|
+
public
|
24
|
+
|
25
|
+
# @param heading [Hash] options for the section heading.
|
26
|
+
# See {Components::GovUK::StepByStepNavigation::Section::Heading#initialize Heading#initialize} for details of the options.
|
27
|
+
# @param content [Hash] options for the section content.
|
28
|
+
# See {Components::GovUK::StepByStepNavigation::Section::Content#initialize Content#initialize} for details of the options.
|
29
|
+
# @param index [String] the index of the section
|
30
|
+
# @param context [ActionView::Base] the view context
|
31
|
+
|
32
|
+
def initialize(heading:, content:, index:, context:)
|
33
|
+
super(context: context)
|
34
|
+
|
35
|
+
@options[:attributes][:class] = 'gem-c-step-nav__step js-step'
|
36
|
+
@options[:attributes][:id] = heading[:text].downcase.gsub(' ', '-').gsub('(', '').gsub(')', '')
|
37
|
+
|
38
|
+
@heading = Heading.new(index: index, **heading)
|
39
|
+
@content = Content.new(content_items: content, index: index, id: @options[:attributes][:id])
|
40
|
+
end
|
41
|
+
|
42
|
+
# Generates the HTML for the GOV.UK Step by step navigation section
|
43
|
+
#
|
44
|
+
# @return [ActiveSupport::SafeBuffer]
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
def render
|
47
|
+
tag.li(class: @options[:attributes][:class], id: @options[:attributes][:id]) do
|
48
|
+
concat(heading.render)
|
49
|
+
concat(content.render)
|
50
|
+
end
|
49
51
|
end
|
50
52
|
end
|
51
53
|
end
|