ccs-frontend_helpers 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -3
- data/CHANGELOG.md +30 -0
- data/Gemfile +6 -5
- data/Gemfile.lock +116 -112
- data/README.md +11 -0
- data/lib/ccs/components/govuk/accordion/section/content.rb +1 -1
- data/lib/ccs/components/govuk/accordion.rb +11 -0
- data/lib/ccs/components/govuk/button.rb +4 -1
- data/lib/ccs/components/govuk/cookie_banner/action.rb +1 -0
- data/lib/ccs/components/govuk/cookie_banner/message.rb +1 -1
- data/lib/ccs/components/govuk/details.rb +1 -1
- data/lib/ccs/components/govuk/error_message.rb +5 -2
- data/lib/ccs/components/govuk/exit_this_page.rb +79 -0
- data/lib/ccs/components/govuk/field/input/character_count.rb +60 -17
- data/lib/ccs/components/govuk/field/input/select.rb +2 -2
- data/lib/ccs/components/govuk/field/inputs/checkboxes.rb +7 -6
- data/lib/ccs/components/govuk/field/inputs/date_input.rb +3 -3
- data/lib/ccs/components/govuk/field/inputs/item/checkbox.rb +1 -13
- data/lib/ccs/components/govuk/field/inputs/item/radio.rb +1 -13
- data/lib/ccs/components/govuk/field/inputs/item.rb +24 -10
- data/lib/ccs/components/govuk/field/inputs/radios.rb +5 -6
- data/lib/ccs/components/govuk/field/inputs.rb +24 -6
- data/lib/ccs/components/govuk/fieldset.rb +1 -1
- data/lib/ccs/components/govuk/footer/meta.rb +1 -1
- data/lib/ccs/components/govuk/footer.rb +1 -1
- data/lib/ccs/components/govuk/header/navigation.rb +4 -2
- data/lib/ccs/components/govuk/header.rb +26 -7
- data/lib/ccs/components/govuk/pagination/increment/next.rb +6 -3
- data/lib/ccs/components/govuk/pagination/increment/previous.rb +6 -3
- data/lib/ccs/components/govuk/pagination/increment.rb +11 -3
- data/lib/ccs/components/govuk/pagination/item.rb +1 -1
- data/lib/ccs/components/govuk/pagination.rb +2 -2
- data/lib/ccs/components/govuk/summary_list/action/link.rb +18 -3
- data/lib/ccs/components/govuk/summary_list/card/actions.rb +3 -2
- data/lib/ccs/components/govuk/summary_list/card.rb +1 -1
- data/lib/ccs/components/govuk/summary_list/row/actions.rb +3 -2
- data/lib/ccs/components/govuk/summary_list/row.rb +7 -2
- data/lib/ccs/components/govuk/summary_list.rb +1 -1
- data/lib/ccs/components/govuk/tabs.rb +5 -3
- data/lib/ccs/components/govuk/task_list/item/status.rb +64 -0
- data/lib/ccs/components/govuk/task_list/item/title.rb +54 -0
- data/lib/ccs/components/govuk/task_list/item.rb +75 -0
- data/lib/ccs/components/govuk/task_list.rb +52 -0
- data/lib/ccs/components/govuk/warning_text.rb +1 -1
- data/lib/ccs/frontend_helpers/govuk_frontend/character_count.rb +1 -1
- data/lib/ccs/frontend_helpers/govuk_frontend/error_message.rb +1 -1
- data/lib/ccs/frontend_helpers/govuk_frontend/exit_this_page.rb +28 -0
- data/lib/ccs/frontend_helpers/govuk_frontend/task_list.rb +28 -0
- data/lib/ccs/frontend_helpers/govuk_frontend.rb +4 -0
- data/lib/ccs/frontend_helpers/version.rb +1 -1
- data/package.json +10 -0
- data/yarn.lock +8 -0
- metadata +11 -2
@@ -11,6 +11,8 @@ module CCS
|
|
11
11
|
# @!attribute [r] type
|
12
12
|
# @return [Symbol] The type of pagination increment
|
13
13
|
# @!attribute [r] text
|
14
|
+
# @return [String] Default text for the pagination increment
|
15
|
+
# @!attribute [r] default_text
|
14
16
|
# @return [String] Text for the pagination increment
|
15
17
|
# @!attribute [r] block_is_level
|
16
18
|
# @return [Boolean] Flag to indicate if previous and next blocks are level
|
@@ -20,11 +22,14 @@ module CCS
|
|
20
22
|
class Increment < Base
|
21
23
|
private
|
22
24
|
|
23
|
-
attr_reader :type, :text, :block_is_level, :label_text
|
25
|
+
attr_reader :type, :default_text, :text, :block_is_level, :label_text
|
24
26
|
|
25
27
|
public
|
26
28
|
|
29
|
+
# rubocop:disable Metrics/ParameterLists
|
30
|
+
|
27
31
|
# @param type [Symbol] the type of increment, either +:prev+ or +:next+
|
32
|
+
# @param default_text [String] the default text for the pagination increment
|
28
33
|
# @param text [String] the text for the pagination increment
|
29
34
|
# @param block_is_level [Boolean] when there are no items, this will be true and will add extra classes
|
30
35
|
# to the link to make the next and previous pagination links level
|
@@ -35,18 +40,21 @@ module CCS
|
|
35
40
|
# @option options [ActionView::Helpers::FormBuilder] :form optional form builder used to create the button
|
36
41
|
# @option options [Hash] :attributes any additional attributes that will added as part of the HTML
|
37
42
|
|
38
|
-
def initialize(type:,
|
43
|
+
def initialize(type:, default_text:, block_is_level:, text: nil, label_text: nil, **options)
|
39
44
|
super(**options)
|
40
45
|
|
41
46
|
@options[:attributes][:class] = "govuk-link govuk-pagination__link #{'pagination--button_as_link' if @options[:form]}".rstrip
|
42
47
|
@options[:attributes][:rel] = type.to_s
|
43
48
|
|
44
49
|
@type = type
|
45
|
-
@
|
50
|
+
@default_text = default_text
|
51
|
+
@text = text || default_text
|
46
52
|
@block_is_level = block_is_level
|
47
53
|
@label_text = label_text
|
48
54
|
end
|
49
55
|
|
56
|
+
# rubocop:enable Metrics/ParameterLists
|
57
|
+
|
50
58
|
# Generates the HTML for the pagination increment link/button
|
51
59
|
#
|
52
60
|
# @yield the HTML for the increment button/link
|
@@ -24,7 +24,7 @@ module CCS
|
|
24
24
|
# @param current [Boolean] flag to indicate if this item is the current page
|
25
25
|
#
|
26
26
|
# @option options [String] :classes additional CSS classes for the item HTML
|
27
|
-
# @option options [
|
27
|
+
# @option options [Boolean] :ellipsis If the value is +true+ then an ellipsis will be rendered
|
28
28
|
# @option options [Hash] :attributes any additional attributes that will added as part of the HTML
|
29
29
|
|
30
30
|
def initialize(number:, current: false, **options)
|
@@ -47,7 +47,7 @@ module CCS
|
|
47
47
|
|
48
48
|
@options[:attributes][:class] << ' govuk-pagination--block' if block_is_level
|
49
49
|
@options[:attributes][:role] = 'navigation'
|
50
|
-
(@options[:attributes][:aria] ||= {})[:label] ||= '
|
50
|
+
(@options[:attributes][:aria] ||= {})[:label] ||= 'Pagination'
|
51
51
|
|
52
52
|
@pagination_previous = Increment::Previous.new(block_is_level: block_is_level, form: @options[:form], context: @context, **pagination_previous) if pagination_previous
|
53
53
|
@pagination_next = Increment::Next.new(block_is_level: block_is_level, form: @options[:form], context: @context, **pagination_next) if pagination_next
|
@@ -88,7 +88,7 @@ module CCS
|
|
88
88
|
|
89
89
|
pagination_item_class = form ? Item::Form : Item::Tag
|
90
90
|
|
91
|
-
@pagination_items = pagination_items.map { |pagination_item| pagination_item[:
|
91
|
+
@pagination_items = pagination_items.map { |pagination_item| pagination_item[:ellipsis] ? Item::Ellipsis : pagination_item_class.new(form: form, context: context, **pagination_item) }
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
@@ -13,28 +13,32 @@ module CCS
|
|
13
13
|
# @return [String] The href for the action link
|
14
14
|
# @!attribute [r] visually_hidden_text
|
15
15
|
# @return [String] Visually hidden text for the action link
|
16
|
+
# @!attribute [r] card_title
|
17
|
+
# @return [String] Card title text for the action link
|
16
18
|
|
17
19
|
class Link < Base
|
18
20
|
private
|
19
21
|
|
20
|
-
attr_reader :text, :href, :visually_hidden_text
|
22
|
+
attr_reader :text, :href, :visually_hidden_text, :card_title
|
21
23
|
|
22
24
|
public
|
23
25
|
|
24
26
|
# @param text [String] the text for the action link
|
25
27
|
# @param href [String] the href for the action link
|
26
28
|
# @param visually_hidden_text [String] optional visually hidden text for the action link
|
29
|
+
# @param card_title [String] card title text for the action link
|
27
30
|
# @param options [Hash] options that will be used in customising the HTML
|
28
31
|
#
|
29
32
|
# @option options [String] :classes additional CSS classes for the summary list action link HTML
|
30
33
|
# @option options [Hash] :attributes any additional attributes that will added as part of the HTML
|
31
34
|
|
32
|
-
def initialize(text:, href:, visually_hidden_text: nil, **options)
|
35
|
+
def initialize(text:, href:, visually_hidden_text: nil, card_title: nil, **options)
|
33
36
|
super(**options)
|
34
37
|
|
35
38
|
@text = text
|
36
39
|
@href = href
|
37
40
|
@visually_hidden_text = visually_hidden_text
|
41
|
+
@card_title = card_title
|
38
42
|
end
|
39
43
|
|
40
44
|
# Generates the HTML for the GOV.UK Summary list action link
|
@@ -44,7 +48,18 @@ module CCS
|
|
44
48
|
def render
|
45
49
|
link_to(href, **@options[:attributes]) do
|
46
50
|
concat(text)
|
47
|
-
|
51
|
+
if visually_hidden_text.present? || card_title.present?
|
52
|
+
concat(tag.span(class: 'govuk-visually-hidden') do
|
53
|
+
if visually_hidden_text
|
54
|
+
concat(' ')
|
55
|
+
concat(visually_hidden_text)
|
56
|
+
end
|
57
|
+
if card_title
|
58
|
+
concat(' ')
|
59
|
+
concat("(#{card_title})")
|
60
|
+
end
|
61
|
+
end)
|
62
|
+
end
|
48
63
|
end
|
49
64
|
end
|
50
65
|
|
@@ -20,14 +20,15 @@ module CCS
|
|
20
20
|
|
21
21
|
# @param items [Array<Hash>] An array of attributes for the action links.
|
22
22
|
# See {Components::GovUK::SummaryList::Action::Link#initialize Action::Link#initialize} for details of the items in the array.
|
23
|
+
# @param card_title [String] the text for the card title
|
23
24
|
# @param options [Hash] options that will be used in customising the HTML
|
24
25
|
#
|
25
26
|
# @option options [String] :classes additional CSS classes for the summary list card actions HTML
|
26
27
|
|
27
|
-
def initialize(items:, **options)
|
28
|
+
def initialize(items:, card_title:, **options)
|
28
29
|
super(**options)
|
29
30
|
|
30
|
-
@action_links = items.map { |item| Action::Link.new(context: @context, **item) }
|
31
|
+
@action_links = items.map { |item| Action::Link.new(context: @context, card_title: card_title, **item) }
|
31
32
|
end
|
32
33
|
|
33
34
|
# Generates the HTML for the GOV.UK Summary list card actions
|
@@ -34,7 +34,7 @@ module CCS
|
|
34
34
|
super(**options)
|
35
35
|
|
36
36
|
@title = Title.new(context: @context, **title) if title
|
37
|
-
@actions = Actions.new(context: @context, **actions) if actions
|
37
|
+
@actions = Actions.new(context: @context, card_title: title&.dig(:text), **actions) if actions
|
38
38
|
end
|
39
39
|
|
40
40
|
# Generates the HTML for the GOV.UK Summary card
|
@@ -20,14 +20,15 @@ module CCS
|
|
20
20
|
|
21
21
|
# @param items [Array<Hash>] An array of attributes for the action links.
|
22
22
|
# See {Components::GovUK::SummaryList::Action::Link#initialize Action::Link#initialize} for details of the items in the array.
|
23
|
+
# @param card_title [String] the text for the card title
|
23
24
|
# @param options [Hash] options that will be used in customising the HTML
|
24
25
|
#
|
25
26
|
# @option options [String] :classes additional CSS classes for the summary list row actions HTML
|
26
27
|
|
27
|
-
def initialize(items:, **options)
|
28
|
+
def initialize(items:, card_title: nil, **options)
|
28
29
|
super(**options)
|
29
30
|
|
30
|
-
@action_links = items.map { |item| Action::Link.new(context: @context, **item) }
|
31
|
+
@action_links = items.map { |item| Action::Link.new(card_title: card_title, context: @context, **item) }
|
31
32
|
end
|
32
33
|
|
33
34
|
# Generates the HTML for the GOV.UK Summary list row actions
|
@@ -25,15 +25,18 @@ module CCS
|
|
25
25
|
|
26
26
|
public
|
27
27
|
|
28
|
+
# rubocop:disable Metrics/ParameterLists
|
29
|
+
|
28
30
|
# @param any_row_has_actions [Boolean] flag to indicate if any rows have actions
|
29
31
|
# @param key [Hash] attributes for the key, see {CCS::Components::GovUK::SummaryList::Row::Key#initialize Key#initialize} for more details.
|
30
32
|
# @param value [Hash] attributes for the value, see {CCS::Components::GovUK::SummaryList::Row::Value#initialize Value#initialize} for more details.
|
31
33
|
# @param actions [Hash] attributes for the actions, see {CCS::Components::GovUK::SummaryList::Row::Actions#initialize Actions#initialize} for more details.
|
34
|
+
# @param card_title [String] the text for the card title
|
32
35
|
# @param options [Hash] options that will be used in customising the HTML
|
33
36
|
#
|
34
37
|
# @option options [String] :classes additional CSS classes for the summary list row HTML
|
35
38
|
|
36
|
-
def initialize(any_row_has_actions:, key:, value:, actions: nil, **options)
|
39
|
+
def initialize(any_row_has_actions:, key:, value:, actions: nil, card_title: nil, **options)
|
37
40
|
super(**options)
|
38
41
|
|
39
42
|
actions_present = actions && actions[:items].present?
|
@@ -42,9 +45,11 @@ module CCS
|
|
42
45
|
|
43
46
|
@key = Key.new(context: @context, **key)
|
44
47
|
@value = Value.new(context: @context, **value)
|
45
|
-
@actions = Actions.new(context: @context, **actions) if actions_present
|
48
|
+
@actions = Actions.new(context: @context, card_title: card_title, **actions) if actions_present
|
46
49
|
end
|
47
50
|
|
51
|
+
# rubocop:enable Metrics/ParameterLists
|
52
|
+
|
48
53
|
# Generates the HTML for the GOV.UK Summary list row
|
49
54
|
#
|
50
55
|
# @return [ActiveSupport::SafeBuffer]
|
@@ -35,7 +35,7 @@ module CCS
|
|
35
35
|
|
36
36
|
any_row_has_actions = summary_list_items.any? { |summary_list_item| summary_list_item.dig(:actions, :items).present? }
|
37
37
|
|
38
|
-
@summary_list_rows = summary_list_items.map { |summary_list_item| Row.new(any_row_has_actions: any_row_has_actions, context: @context, **summary_list_item) }
|
38
|
+
@summary_list_rows = summary_list_items.map { |summary_list_item| Row.new(any_row_has_actions: any_row_has_actions, card_title: card&.dig(:title, :text), context: @context, **summary_list_item) }
|
39
39
|
@card = Card.new(context: @context, **card) if card
|
40
40
|
end
|
41
41
|
|
@@ -50,9 +50,11 @@ module CCS
|
|
50
50
|
def render
|
51
51
|
tag.div(**options[:attributes]) do
|
52
52
|
concat(tag.h2(title, class: 'govuk-tabs__title'))
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
if @tabs.present?
|
54
|
+
concat(tag.ul(class: 'govuk-tabs__list') do
|
55
|
+
@tabs.each { |tab| concat(tab.render) }
|
56
|
+
end)
|
57
|
+
end
|
56
58
|
@panels.each { |panel| concat(panel.render) }
|
57
59
|
end
|
58
60
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require_relative '../../../base'
|
2
|
+
require_relative '../../tag'
|
3
|
+
|
4
|
+
module CCS
|
5
|
+
module Components
|
6
|
+
module GovUK
|
7
|
+
class TaskList < Base
|
8
|
+
class Item < Base
|
9
|
+
# = GOV.UK Task list item status
|
10
|
+
#
|
11
|
+
# @!attribute [r] text
|
12
|
+
# @return [String] Text for the status
|
13
|
+
# @!attribute [r] tag_component
|
14
|
+
# @return [Tag] Tag for the status
|
15
|
+
|
16
|
+
class Status < Base
|
17
|
+
private
|
18
|
+
|
19
|
+
attr_reader :tag_component, :text
|
20
|
+
|
21
|
+
public
|
22
|
+
|
23
|
+
# @param id_prefix [String] the id prefix for the task list item
|
24
|
+
# @param tag_options [Hash] paramters for the govuk tag (see {Components::GovUK::Tag Tag}).
|
25
|
+
# options are:
|
26
|
+
# - +text+
|
27
|
+
# - +colour+
|
28
|
+
# - +options+
|
29
|
+
# @param text [String] the text for the status. If tag is nil then this is used
|
30
|
+
# @param options [Hash] options that will be used in customising the HTML
|
31
|
+
#
|
32
|
+
# @option options [String] :classes additional CSS classes for the task list row status HTML
|
33
|
+
|
34
|
+
def initialize(id_prefix:, tag_options: nil, text: nil, **options)
|
35
|
+
super(**options)
|
36
|
+
@options[:attributes][:id] = "#{id_prefix}-status"
|
37
|
+
|
38
|
+
@text = text
|
39
|
+
@tag_component = Tag.new(context: @context, **tag_options) if tag_options
|
40
|
+
end
|
41
|
+
|
42
|
+
# Generates the HTML for the GOV.UK Task list item status
|
43
|
+
#
|
44
|
+
# @return [ActiveSupport::SafeBuffer]
|
45
|
+
|
46
|
+
def render
|
47
|
+
tag.div(class: @options[:attributes][:class], id: @options[:attributes][:id]) do
|
48
|
+
if tag_component
|
49
|
+
tag_component.render
|
50
|
+
else
|
51
|
+
text
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# The default attributes for the task list item status
|
57
|
+
|
58
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-task-list__status' }.freeze
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require_relative '../../../base'
|
2
|
+
|
3
|
+
module CCS
|
4
|
+
module Components
|
5
|
+
module GovUK
|
6
|
+
class TaskList < Base
|
7
|
+
class Item < Base
|
8
|
+
# = GOV.UK Task list item title
|
9
|
+
#
|
10
|
+
# @!attribute [r] text
|
11
|
+
# @return [String] Text for the title
|
12
|
+
# @!attribute [r] href
|
13
|
+
# @return [String] Optional link for the title
|
14
|
+
|
15
|
+
class Title < Base
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_reader :text, :href
|
19
|
+
|
20
|
+
public
|
21
|
+
|
22
|
+
# @param text [String] the text for the title
|
23
|
+
# @param id_prefix [String] the id prefix for the task list item
|
24
|
+
# @param href [String] optional link for the title
|
25
|
+
# @param hint_text [String] flag to indicate if there is a hint
|
26
|
+
# @param options [Hash] options that will be used in customising the HTML
|
27
|
+
#
|
28
|
+
# @option options [String] :classes additional CSS classes for the task list item title HTML
|
29
|
+
|
30
|
+
def initialize(text:, id_prefix:, href: nil, hint_text: nil, **options)
|
31
|
+
super(**options)
|
32
|
+
@options[:attributes][:aria] = { describedby: (hint_text ? "#{id_prefix}-hint " : '') + "#{id_prefix}-status" } if href
|
33
|
+
|
34
|
+
@text = text
|
35
|
+
@href = href
|
36
|
+
end
|
37
|
+
|
38
|
+
# Generates the HTML for the GOV.UK Task list item title
|
39
|
+
#
|
40
|
+
# @return [ActiveSupport::SafeBuffer]
|
41
|
+
|
42
|
+
def render
|
43
|
+
if href
|
44
|
+
link_to(text, href, class: "govuk-link govuk-task-list__link #{@options[:attributes][:class]}".rstrip, aria: { describedby: @options[:attributes][:aria][:describedby] })
|
45
|
+
else
|
46
|
+
tag.div(text, class: @options[:attributes][:class])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require_relative '../../base'
|
2
|
+
require_relative 'item/title'
|
3
|
+
require_relative 'item/status'
|
4
|
+
|
5
|
+
module CCS
|
6
|
+
module Components
|
7
|
+
module GovUK
|
8
|
+
class TaskList < Base
|
9
|
+
# = GOV.UK Task list item
|
10
|
+
#
|
11
|
+
# The individual list item for the task list
|
12
|
+
#
|
13
|
+
# @!attribute [r] title
|
14
|
+
# @return [Title] Initialised task list item title
|
15
|
+
# @!attribute [r] status
|
16
|
+
# @return [Status] Initialised task list item status
|
17
|
+
# @!attribute [r] hint_text
|
18
|
+
# @return [String] optional hint text for the item
|
19
|
+
# @!attribute [r] id_prefix
|
20
|
+
# @return [String] ID prefix for the task list item
|
21
|
+
|
22
|
+
class Item < Base
|
23
|
+
private
|
24
|
+
|
25
|
+
attr_reader :id_prefix, :title, :hint_text, :status
|
26
|
+
|
27
|
+
public
|
28
|
+
|
29
|
+
# rubocop:disable Metrics/ParameterLists
|
30
|
+
|
31
|
+
# @param title [Hash] options for the item title.
|
32
|
+
# See {Components::GovUK::TaskList::Item::Title#initialize Title#initialize} for details of title.
|
33
|
+
# @param status [Hash] options for the item status.
|
34
|
+
# See {Components::GovUK::TaskList::Item::Status#initialize Status#initialize} for details of status.
|
35
|
+
# @param index [Integer] the index of the item
|
36
|
+
# @param id_prefix [String] the id prefix for the task list
|
37
|
+
# @param hint_text [String] optional hint text for the item
|
38
|
+
# @param options [Hash] options that will be used in customising the HTML
|
39
|
+
#
|
40
|
+
# @option options [String] :classes additional CSS classes for the task list item HTML
|
41
|
+
|
42
|
+
def initialize(title:, status:, index:, id_prefix:, hint_text: nil, **options)
|
43
|
+
super(**options)
|
44
|
+
@options[:attributes][:class] << ' govuk-task-list__item--with-link' if title[:href]
|
45
|
+
|
46
|
+
@id_prefix = "#{id_prefix}-#{index}"
|
47
|
+
@title = Title.new(context: @context, id_prefix: @id_prefix, hint_text: hint_text, **title)
|
48
|
+
@hint_text = hint_text
|
49
|
+
@status = Status.new(context: @context, id_prefix: @id_prefix, **status)
|
50
|
+
end
|
51
|
+
|
52
|
+
# rubocop:enable Metrics/ParameterLists
|
53
|
+
|
54
|
+
# Generates the HTML for the GOV.UK Task list item
|
55
|
+
#
|
56
|
+
# @return [ActiveSupport::SafeBuffer]
|
57
|
+
|
58
|
+
def render
|
59
|
+
tag.li(class: options[:attributes][:class]) do
|
60
|
+
concat(tag.div(class: 'govuk-task-list__name-and-hint') do
|
61
|
+
concat(title.render)
|
62
|
+
concat(tag.div(hint_text, class: 'govuk-task-list__hint', id: "#{id_prefix}-hint")) if hint_text
|
63
|
+
end)
|
64
|
+
concat(status.render)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# The default attributes for the task list item
|
69
|
+
|
70
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-task-list__item' }.freeze
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require_relative '../base'
|
2
|
+
require_relative 'task_list/item'
|
3
|
+
|
4
|
+
module CCS
|
5
|
+
module Components
|
6
|
+
module GovUK
|
7
|
+
# = GOV.UK Task list
|
8
|
+
#
|
9
|
+
# This is used to generate the task list component from the
|
10
|
+
# {https://design-system.service.gov.uk/components/task-list GDS - Components - Task list}
|
11
|
+
#
|
12
|
+
# @!attribute [r] task_list_items
|
13
|
+
# @return [Array<Link>] An array of the initialised task list items
|
14
|
+
|
15
|
+
class TaskList < Base
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_reader :task_list_items
|
19
|
+
|
20
|
+
public
|
21
|
+
|
22
|
+
# @param task_list_items [Array<Hash>] An array of task list items.
|
23
|
+
# See {Components::GovUK::TaskList::Item#initialize Item#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 task list HTML
|
27
|
+
# @option options [Sting] :id_prefix id prefix for the task list, defaults to +'task-list'+
|
28
|
+
# @option options [Hash] :attributes any additional attributes that will added as part of the HTML
|
29
|
+
|
30
|
+
def initialize(task_list_items:, id_prefix: nil, **options)
|
31
|
+
super(**options)
|
32
|
+
|
33
|
+
@task_list_items = task_list_items.map.with_index(1) { |task_list_item, index| Item.new(context: @context, index: index, id_prefix: id_prefix || 'task-list', **task_list_item) }
|
34
|
+
end
|
35
|
+
|
36
|
+
# Generates the HTML for the GOV.UK task list component
|
37
|
+
#
|
38
|
+
# @return [ActiveSupport::SafeBuffer]
|
39
|
+
|
40
|
+
def render
|
41
|
+
tag.ul(**options[:attributes]) do
|
42
|
+
task_list_items.each { |task_list_item| concat(task_list_item.render) }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# The default attributes for the task list
|
47
|
+
|
48
|
+
DEFAULT_ATTRIBUTES = { class: 'govuk-task-list' }.freeze
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -42,7 +42,7 @@ module CCS
|
|
42
42
|
tag.div(**options[:attributes]) do
|
43
43
|
concat(tag.span('!', class: 'govuk-warning-text__icon', aria: { hidden: true }))
|
44
44
|
concat(tag.strong(class: 'govuk-warning-text__text') do
|
45
|
-
concat(tag.span(options[:icon_fallback_text] || 'Warning', class: 'govuk-
|
45
|
+
concat(tag.span(options[:icon_fallback_text] || 'Warning', class: 'govuk-visually-hidden'))
|
46
46
|
if text
|
47
47
|
concat(text)
|
48
48
|
else
|
@@ -19,7 +19,7 @@ module CCS
|
|
19
19
|
#
|
20
20
|
# @return (see CCS::Components::GovUK::Input::CharacterCount#render)
|
21
21
|
|
22
|
-
def govuk_character_count(attribute, character_count_options, **options)
|
22
|
+
def govuk_character_count(attribute, character_count_options = {}, **options)
|
23
23
|
Components::GovUK::Field::Input::CharacterCount.new(context: self, attribute: attribute, character_count_options: character_count_options, **options).render
|
24
24
|
end
|
25
25
|
end
|
@@ -19,7 +19,7 @@ module CCS
|
|
19
19
|
#
|
20
20
|
# @return (see CCS::Components::GovUK::ErrorMessage#render)
|
21
21
|
|
22
|
-
def govuk_error_message(error_message, attribute, **options)
|
22
|
+
def govuk_error_message(error_message, attribute = nil, **options)
|
23
23
|
Components::GovUK::ErrorMessage.new(context: self, message: error_message, attribute: attribute, **options).render
|
24
24
|
end
|
25
25
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../components/govuk/exit_this_page'
|
4
|
+
|
5
|
+
module CCS
|
6
|
+
module FrontendHelpers
|
7
|
+
module GovUKFrontend
|
8
|
+
# = GOV.UK Exit this page
|
9
|
+
#
|
10
|
+
# This is used to generate the exit this page component from the
|
11
|
+
# {https://design-system.service.gov.uk/components/exit-this-page GDS - Components - Exit this page}
|
12
|
+
|
13
|
+
module ExitThisPage
|
14
|
+
# Generates the HTML for the GOV.UK Exit this page component
|
15
|
+
#
|
16
|
+
# @param (see CCS::Components::GovUK::ExitThisPage#initialize)
|
17
|
+
#
|
18
|
+
# @option (see CCS::Components::GovUK::ExitThisPage#initialize)
|
19
|
+
#
|
20
|
+
# @return (see CCS::Components::GovUK::ExitThisPage#render)
|
21
|
+
|
22
|
+
def govuk_exit_this_page(text = nil, redirect_url = nil, **options)
|
23
|
+
Components::GovUK::ExitThisPage.new(context: self, text: text, redirect_url: redirect_url, **options).render
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../components/govuk/task_list'
|
4
|
+
|
5
|
+
module CCS
|
6
|
+
module FrontendHelpers
|
7
|
+
module GovUKFrontend
|
8
|
+
# = GOV.UK Task list
|
9
|
+
#
|
10
|
+
# This helper is used for generating the task list component from the
|
11
|
+
# {https://design-system.service.gov.uk/components/task-list GDS - Components - Task list}
|
12
|
+
|
13
|
+
module TaskList
|
14
|
+
# Generates the HTML for the GOV.UK Task list component
|
15
|
+
#
|
16
|
+
# @param (see CCS::Components::GovUK::TaskList#initialize)
|
17
|
+
#
|
18
|
+
# @option (see CCS::Components::GovUK::TaskList#initialize)
|
19
|
+
#
|
20
|
+
# @return (see CCS::Components::GovUK::TaskList#render)
|
21
|
+
|
22
|
+
def govuk_task_list(task_list_items, **options)
|
23
|
+
Components::GovUK::TaskList.new(context: self, task_list_items: task_list_items, **options).render
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -11,6 +11,7 @@ require_relative 'govuk_frontend/date_input'
|
|
11
11
|
require_relative 'govuk_frontend/details'
|
12
12
|
require_relative 'govuk_frontend/error_message'
|
13
13
|
require_relative 'govuk_frontend/error_summary'
|
14
|
+
require_relative 'govuk_frontend/exit_this_page'
|
14
15
|
require_relative 'govuk_frontend/fieldset'
|
15
16
|
require_relative 'govuk_frontend/file_upload'
|
16
17
|
require_relative 'govuk_frontend/footer'
|
@@ -32,6 +33,7 @@ require_relative 'govuk_frontend/summary_list'
|
|
32
33
|
require_relative 'govuk_frontend/table'
|
33
34
|
require_relative 'govuk_frontend/tabs'
|
34
35
|
require_relative 'govuk_frontend/tag'
|
36
|
+
require_relative 'govuk_frontend/task_list'
|
35
37
|
require_relative 'govuk_frontend/textarea'
|
36
38
|
require_relative 'govuk_frontend/warning_text'
|
37
39
|
|
@@ -52,6 +54,7 @@ module CCS
|
|
52
54
|
include Details
|
53
55
|
include ErrorMessage
|
54
56
|
include ErrorSummary
|
57
|
+
include ExitThisPage
|
55
58
|
include FileUpload
|
56
59
|
include Fieldset
|
57
60
|
include Footer
|
@@ -73,6 +76,7 @@ module CCS
|
|
73
76
|
include Table
|
74
77
|
include Tabs
|
75
78
|
include Tag
|
79
|
+
include TaskList
|
76
80
|
include Textarea
|
77
81
|
include WarningText
|
78
82
|
end
|
data/package.json
ADDED
data/yarn.lock
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
2
|
+
# yarn lockfile v1
|
3
|
+
|
4
|
+
|
5
|
+
govuk-frontend@^5.2.0:
|
6
|
+
version "5.2.0"
|
7
|
+
resolved "https://registry.yarnpkg.com/govuk-frontend/-/govuk-frontend-5.2.0.tgz#f8e0bf98b771b8ee1501fd45bbba24a091f3846d"
|
8
|
+
integrity sha512-beD3wztHpkKz6JUpPwnwop1ejb4rTFMPLCutKLCIDmUS4BPpW59ggVUfctsRqHd2Zjw9wxljdRdeIJ8AZFyyTw==
|