ccs-frontend_helpers 0.1.2 → 0.3.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 +40 -0
- data/Gemfile +7 -6
- data/Gemfile.lock +121 -114
- data/README.md +12 -0
- data/lib/ccs/components/ccs/footer.rb +0 -1
- data/lib/ccs/components/ccs/header.rb +0 -1
- 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/count_message.rb +62 -0
- data/lib/ccs/components/govuk/field/input/character_count.rb +55 -42
- data/lib/ccs/components/govuk/field/input/password_input/show_hide_button.rb +72 -0
- data/lib/ccs/components/govuk/field/input/password_input.rb +101 -0
- data/lib/ccs/components/govuk/field/input/select.rb +2 -2
- data/lib/ccs/components/govuk/field/input/text_input.rb +23 -7
- data/lib/ccs/components/govuk/field/input.rb +4 -0
- data/lib/ccs/components/govuk/field/inputs/checkboxes.rb +8 -28
- data/lib/ccs/components/govuk/field/inputs/date_input.rb +4 -25
- 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 +7 -23
- data/lib/ccs/components/govuk/field/inputs.rb +31 -7
- data/lib/ccs/components/govuk/field.rb +12 -2
- 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 -2
- data/lib/ccs/components/govuk/header/navigation.rb +4 -2
- data/lib/ccs/components/govuk/header.rb +26 -8
- 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 -3
- 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/password_input.rb +28 -0
- data/lib/ccs/frontend_helpers/govuk_frontend/task_list.rb +28 -0
- data/lib/ccs/frontend_helpers/govuk_frontend.rb +6 -0
- data/lib/ccs/frontend_helpers/version.rb +1 -1
- data/package.json +10 -0
- data/yarn.lock +8 -0
- metadata +15 -2
@@ -10,43 +10,22 @@ module CCS
|
|
10
10
|
#
|
11
11
|
# This is used for generating the date input component from the
|
12
12
|
# {https://design-system.service.gov.uk/components/date-input GDS - Components - Date Input}
|
13
|
-
#
|
14
|
-
# @!attribute [r] date_input_items
|
15
|
-
# @return [Array<DateInput::Item>] An array of the initialised date input items
|
16
13
|
|
17
14
|
class DateInput < Inputs
|
18
|
-
private
|
19
|
-
|
20
|
-
attr_reader :date_input_items
|
21
|
-
|
22
|
-
public
|
23
|
-
|
24
15
|
# @param (see CCS::Components::GovUK::Field::Inputs#initialize)
|
25
16
|
# @param date_items [Array<Hash>] an array of options for the date items.
|
26
17
|
# See {Components::GovUK::Field::Inputs::DateInput::Item#initialize Item#initialize} for details of the items in the array.
|
27
18
|
#
|
28
19
|
# @option (see CCS::Components::GovUK::Field::Inputs#initialize)
|
29
20
|
|
30
|
-
def initialize(attribute:, date_items:
|
31
|
-
(options[:fieldset][:attributes] ||= {})[:role] = 'group'
|
21
|
+
def initialize(attribute:, date_items: nil, **options)
|
22
|
+
(options[:fieldset][:attributes] ||= {})[:role] = 'group' if options[:fieldset]
|
32
23
|
|
33
24
|
super(attribute: attribute, **options)
|
34
25
|
|
35
|
-
|
36
|
-
|
37
|
-
@date_input_items = date_items.map { |date_input_item| Item.new(attribute: attribute, error_message: @error_message, model: @options[:model], form: @options[:form], context: @context, **date_input_item) }
|
38
|
-
end
|
39
|
-
|
40
|
-
# Generates the HTML for the GOV.UK date input component
|
41
|
-
#
|
42
|
-
# @return [ActiveSupport::SafeBuffer]
|
26
|
+
date_items = default_date_items if date_items.blank?
|
43
27
|
|
44
|
-
|
45
|
-
super() do
|
46
|
-
tag.div(**options[:attributes]) do
|
47
|
-
date_input_items.each { |date_input_item| concat(date_input_item.render) }
|
48
|
-
end
|
49
|
-
end
|
28
|
+
@input_items = date_items.map { |date_input_item| Item.new(attribute: attribute, error_message: @error_message, model: @options[:model], form: @options[:form], context: @context, **date_input_item) }
|
50
29
|
end
|
51
30
|
|
52
31
|
# The default attributes for the date input
|
@@ -17,23 +17,11 @@ module CCS
|
|
17
17
|
# @option (see CCS::Components::GovUK::Field::Items::Item#initialize))
|
18
18
|
|
19
19
|
def initialize(attribute:, label:, **options)
|
20
|
-
super(attribute: attribute, **options)
|
20
|
+
super(attribute: attribute, item_class: 'govuk-checkboxes__item', **options)
|
21
21
|
|
22
22
|
label[:classes] = "govuk-checkboxes__label #{label[:classes]}".rstrip
|
23
23
|
end
|
24
24
|
|
25
|
-
# Generates the HTML to wrap arround a checkbox input
|
26
|
-
#
|
27
|
-
# @yield the checkbox item input HTML
|
28
|
-
#
|
29
|
-
# @return [ActiveSupport::SafeBuffer]
|
30
|
-
|
31
|
-
def render(&block)
|
32
|
-
tag.div(class: 'govuk-checkboxes__item') do
|
33
|
-
super(&block)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
25
|
# The default attributes for the checkbox
|
38
26
|
|
39
27
|
DEFAULT_ATTRIBUTES = { class: 'govuk-checkboxes__input' }.freeze
|
@@ -17,23 +17,11 @@ module CCS
|
|
17
17
|
# @option (see CCS::Components::GovUK::Field::Items::Item#initialize))
|
18
18
|
|
19
19
|
def initialize(attribute:, label:, **options)
|
20
|
-
super(attribute: attribute, **options)
|
20
|
+
super(attribute: attribute, item_class: 'govuk-radios__item', **options)
|
21
21
|
|
22
22
|
label[:classes] = "govuk-radios__label #{label[:classes]}".rstrip
|
23
23
|
end
|
24
24
|
|
25
|
-
# Generates the HTML to wrap arround a radio input
|
26
|
-
#
|
27
|
-
# @yield the radio item input HTML
|
28
|
-
#
|
29
|
-
# @return [ActiveSupport::SafeBuffer]
|
30
|
-
|
31
|
-
def render(&block)
|
32
|
-
tag.div(class: 'govuk-radios__item') do
|
33
|
-
super(&block)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
25
|
# The default attributes for the radio
|
38
26
|
|
39
27
|
DEFAULT_ATTRIBUTES = { class: 'govuk-radios__input' }.freeze
|
@@ -19,6 +19,8 @@ module CCS
|
|
19
19
|
# @return [String,Symbol] The attribute of the item
|
20
20
|
# @!attribute [r] value
|
21
21
|
# @return [String] The value of the item
|
22
|
+
# @!attribute [r] item_class
|
23
|
+
# @return [String] The CSS class for the item
|
22
24
|
# @!attribute [r] label
|
23
25
|
# @return [Label] The initialised item label
|
24
26
|
# @!attribute [r] hint
|
@@ -27,13 +29,19 @@ module CCS
|
|
27
29
|
# @return [ActiveSupport::SafeBuffer] The conditional HTML
|
28
30
|
|
29
31
|
class Item < Base
|
32
|
+
include ActionView::Context
|
33
|
+
include ActionView::Helpers
|
34
|
+
|
30
35
|
private
|
31
36
|
|
32
|
-
attr_reader :attribute, :value, :label, :hint, :conditional_content
|
37
|
+
attr_reader :attribute, :value, :item_class, :label, :hint, :conditional_content
|
33
38
|
|
34
39
|
public
|
35
40
|
|
41
|
+
# rubocop:disable Metrics/ParameterLists
|
42
|
+
|
36
43
|
# @param attribute [String,Symbol] the attribute of the item
|
44
|
+
# @param item_class [String] the CSS class for the item
|
37
45
|
# @param value [String] the value of the item
|
38
46
|
# @param hint [Hash] options for an item hint see {CCS::Components::GovUK::Hint#initialize Hint#initialize} for more details.
|
39
47
|
# If no hint is given then no hint will be rendered
|
@@ -48,15 +56,18 @@ module CCS
|
|
48
56
|
# @option conditional [ActiveSupport::SafeBuffer] content the HTML content
|
49
57
|
# @option conditional [Hash] attributes[:id] the id of the conditional section
|
50
58
|
|
51
|
-
def initialize(attribute:, value:, hint: nil, conditional: nil, **options)
|
59
|
+
def initialize(attribute:, value:, item_class:, hint: nil, conditional: nil, **options)
|
52
60
|
super(**options)
|
53
61
|
|
54
62
|
initialise_item_hint(attribute, value, hint) if hint
|
55
|
-
initialize_item_conditional(attribute, value, conditional) if conditional
|
63
|
+
initialize_item_conditional(attribute, value, conditional) if conditional && conditional[:content]
|
56
64
|
@attribute = attribute
|
57
65
|
@value = value
|
66
|
+
@item_class = item_class
|
58
67
|
end
|
59
68
|
|
69
|
+
# rubocop:enable Metrics/ParameterLists
|
70
|
+
|
60
71
|
# Generates the HTML to wrap arround a input
|
61
72
|
#
|
62
73
|
# @yield the item input HTML
|
@@ -64,10 +75,14 @@ module CCS
|
|
64
75
|
# @return [ActiveSupport::SafeBuffer]
|
65
76
|
|
66
77
|
def render
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
78
|
+
capture do
|
79
|
+
concat(tag.div(class: @item_class) do
|
80
|
+
concat(yield)
|
81
|
+
concat(label.render)
|
82
|
+
concat(hint.render) if hint
|
83
|
+
end)
|
84
|
+
concat(conditional_content) if conditional_content
|
85
|
+
end
|
71
86
|
end
|
72
87
|
|
73
88
|
private
|
@@ -82,8 +97,7 @@ module CCS
|
|
82
97
|
hint[:attributes] ||= {}
|
83
98
|
hint[:classes] = "govuk-#{self.class::ITEM_TYPE}__hint #{hint[:classes]}".rstrip
|
84
99
|
hint[:attributes][:id] ||= "#{attribute}_#{value}-item-hint"
|
85
|
-
|
86
|
-
(@options[:attributes][:aria] ||= {})[:describedby] = hint[:attributes][:id]
|
100
|
+
(@options[:attributes][:aria] ||= {})[:describedby] = [@options.dig(:attributes, :aria, :describedby), hint[:attributes][:id]].compact.join(' ')
|
87
101
|
|
88
102
|
@hint = Hint.new(context: @context, **hint)
|
89
103
|
end
|
@@ -97,7 +111,7 @@ module CCS
|
|
97
111
|
def initialize_item_conditional(attribute, value, conditional)
|
98
112
|
conditional[:attributes] ||= {}
|
99
113
|
conditional[:attributes][:class] = "govuk-#{self.class::ITEM_TYPE}__conditional #{"govuk-#{self.class::ITEM_TYPE}__conditional--hidden" unless @options[:checked]}".rstrip
|
100
|
-
conditional[:attributes][:id] ||= sanitize_to_id("
|
114
|
+
conditional[:attributes][:id] ||= sanitize_to_id("conditional-#{attribute}_#{value}")
|
101
115
|
|
102
116
|
(@options[:attributes][:data] ||= {})[:'aria-controls'] = conditional[:attributes][:id]
|
103
117
|
|
@@ -12,18 +12,15 @@ module CCS
|
|
12
12
|
#
|
13
13
|
# This is used for generating the radios component from the
|
14
14
|
# {https://design-system.service.gov.uk/components/radios GDS - Components - Radios}
|
15
|
-
#
|
16
|
-
# @!attribute [r] radio_items
|
17
|
-
# @return [Array<Item::Divider|Item::Radio|Item::Radio>] An array of the initialised radio items
|
18
15
|
|
19
16
|
class Radios < Inputs
|
20
17
|
private
|
21
18
|
|
22
|
-
attr_reader :
|
19
|
+
attr_reader :input_items
|
23
20
|
|
24
21
|
public
|
25
22
|
|
26
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
23
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
27
24
|
|
28
25
|
# @param (see CCS::Components::GovUK::Field::Inputs#initialize)
|
29
26
|
# @param radio_items [Array<Hash>] an array of options for the radios.
|
@@ -34,29 +31,16 @@ module CCS
|
|
34
31
|
def initialize(attribute:, radio_items:, **options)
|
35
32
|
super(attribute: attribute, **options)
|
36
33
|
|
37
|
-
if @options[:model] || @options[:form]
|
38
|
-
|
39
|
-
|
40
|
-
end
|
34
|
+
@options[:value] = (@options[:model] || @options[:form].object).send(attribute) if @options[:model] || @options[:form]
|
35
|
+
|
36
|
+
radio_items.each { |radio_item| radio_item[:checked] = @options[:value] == radio_item[:value] } if @options[:value]
|
41
37
|
|
42
38
|
radio_item_class = @options[:form] ? Item::Radio::Form : Inputs::Item::Radio::Tag
|
43
39
|
|
44
|
-
@
|
40
|
+
@input_items = radio_items.map { |radio_item| radio_item[:divider] ? Item::Divider.new(divider: radio_item[:divider], type: 'radios') : radio_item_class.new(attribute: attribute, form: @options[:form], context: @context, **radio_item) }
|
45
41
|
end
|
46
42
|
|
47
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
48
|
-
|
49
|
-
# Generates the HTML for the GOV.UK Radios component
|
50
|
-
#
|
51
|
-
# @return [ActiveSupport::SafeBuffer]
|
52
|
-
|
53
|
-
def render
|
54
|
-
super() do
|
55
|
-
tag.div(**options[:attributes]) do
|
56
|
-
radio_items.each { |radio_item| concat(radio_item.render) }
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
43
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
60
44
|
|
61
45
|
# The default attributes for the radios
|
62
46
|
|
@@ -14,11 +14,13 @@ module CCS
|
|
14
14
|
#
|
15
15
|
# @!attribute [r] fieldset
|
16
16
|
# @return [Fieldset] The initialised fieldset
|
17
|
+
# @!attribute [r] input_items
|
18
|
+
# @return [Array<Item>] An array of the initialised items
|
17
19
|
|
18
20
|
class Inputs < Field
|
19
21
|
private
|
20
22
|
|
21
|
-
attr_reader :fieldset
|
23
|
+
attr_reader :fieldset, :input_items
|
22
24
|
|
23
25
|
public
|
24
26
|
|
@@ -27,9 +29,11 @@ module CCS
|
|
27
29
|
#
|
28
30
|
# @option (see CCS::Components::GovUK::Field#initialize)
|
29
31
|
|
30
|
-
def initialize(attribute:, fieldset
|
32
|
+
def initialize(attribute:, fieldset: nil, **options)
|
31
33
|
super(attribute: attribute, **options)
|
32
34
|
|
35
|
+
return unless fieldset
|
36
|
+
|
33
37
|
set_described_by(fieldset, @attribute, @error_message, options[:hint])
|
34
38
|
|
35
39
|
@fieldset = Fieldset.new(context: @context, **fieldset)
|
@@ -41,15 +45,35 @@ module CCS
|
|
41
45
|
#
|
42
46
|
# @return [ActiveSupport::SafeBuffer]
|
43
47
|
|
44
|
-
def render
|
48
|
+
def render(&block)
|
45
49
|
super() do |display_error_message|
|
46
|
-
fieldset
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
+
if fieldset
|
51
|
+
fieldset.render do
|
52
|
+
field_inner_html(display_error_message, &block)
|
53
|
+
end
|
54
|
+
else
|
55
|
+
field_inner_html(display_error_message, &block)
|
50
56
|
end
|
51
57
|
end
|
52
58
|
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
# Generates the HTML structure for the field component
|
63
|
+
#
|
64
|
+
# @yield (see CCS::Components::GovUK::Field#render)
|
65
|
+
#
|
66
|
+
# @return [ActiveSupport::SafeBuffer]
|
67
|
+
|
68
|
+
def field_inner_html(display_error_message)
|
69
|
+
concat(hint.render) if hint
|
70
|
+
concat(display_error_message)
|
71
|
+
concat(tag.div(**options[:attributes]) do
|
72
|
+
concat(before_input) if before_input
|
73
|
+
input_items.each { |input_item| concat(input_item.render) }
|
74
|
+
concat(after_input) if after_input
|
75
|
+
end)
|
76
|
+
end
|
53
77
|
end
|
54
78
|
end
|
55
79
|
end
|
@@ -18,14 +18,20 @@ module CCS
|
|
18
18
|
# @return [FormGroup] The initialised form group
|
19
19
|
# @!attribute [r] hint
|
20
20
|
# @return [Hint] The initialised hint
|
21
|
+
# @!attribute [r] before_input
|
22
|
+
# @return [String] Text or HTML to go before the input
|
23
|
+
# @!attribute [r] after_input
|
24
|
+
# @return [String] Text or HTML to go after the input
|
21
25
|
|
22
26
|
class Field < Base
|
23
27
|
private
|
24
28
|
|
25
|
-
attr_reader :attribute, :error_message, :form_group, :hint
|
29
|
+
attr_reader :attribute, :error_message, :form_group, :hint, :before_input, :after_input
|
26
30
|
|
27
31
|
public
|
28
32
|
|
33
|
+
# rubocop:disable Metrics/ParameterLists
|
34
|
+
|
29
35
|
# @param attribute [String, Symbol] the attribute of the field
|
30
36
|
# @param hint [Hash] attributes for the hint, see {CCS::Components::GovUK::Hint#initialize Hint#initialize} for more details.
|
31
37
|
# If no hint is given then no hint will be rendered
|
@@ -39,7 +45,7 @@ module CCS
|
|
39
45
|
# @option options [String] :classes additional CSS classes for the field HTML
|
40
46
|
# @option options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
|
41
47
|
|
42
|
-
def initialize(attribute:, form_group: nil, hint: nil, **options)
|
48
|
+
def initialize(attribute:, form_group: nil, hint: nil, before_input: nil, after_input: nil, **options)
|
43
49
|
super(**options)
|
44
50
|
|
45
51
|
(hint[:attributes] ||= {})[:id] = "#{attribute}-hint" if hint && !hint.dig(:attributes, :id)
|
@@ -49,8 +55,12 @@ module CCS
|
|
49
55
|
|
50
56
|
@form_group = FormGroup.new(attribute: attribute, error_message: @error_message, context: @context, **(form_group || {}))
|
51
57
|
@hint = Hint.new(context: @context, **hint) if hint
|
58
|
+
@before_input = before_input
|
59
|
+
@after_input = after_input
|
52
60
|
end
|
53
61
|
|
62
|
+
# rubocop:enable Metrics/ParameterLists
|
63
|
+
|
54
64
|
# Generates the HTML to wrap arround a GDS form input component
|
55
65
|
#
|
56
66
|
# @yield the field HTML
|
@@ -44,7 +44,7 @@ module CCS
|
|
44
44
|
def render
|
45
45
|
capture do
|
46
46
|
concat(tag.h2(visually_hidden_title, class: 'govuk-visually-hidden'))
|
47
|
-
if meta_links
|
47
|
+
if meta_links.present?
|
48
48
|
concat(tag.ul(class: 'govuk-footer__inline-list') do
|
49
49
|
meta_links.each { |meta_link| concat(meta_link.render) }
|
50
50
|
end)
|
@@ -37,7 +37,6 @@ module CCS
|
|
37
37
|
def initialize(navigation: nil, meta: nil, **options)
|
38
38
|
super(**options)
|
39
39
|
|
40
|
-
@options[:attributes][:role] = 'contentinfo'
|
41
40
|
@options[:copyright] ||= '© Crown copyright'
|
42
41
|
|
43
42
|
@navigation = navigation&.map { |navigation_item| Navigation.new(context: @context, **navigation_item) }
|
@@ -53,7 +52,7 @@ module CCS
|
|
53
52
|
def render
|
54
53
|
tag.footer(**options[:attributes]) do
|
55
54
|
tag.div(class: "govuk-width-container #{options[:container_classes]}".rstrip) do
|
56
|
-
if navigation
|
55
|
+
if navigation.present?
|
57
56
|
concat(tag.div(class: 'govuk-footer__navigation') do
|
58
57
|
navigation.each { |navigation_item| concat(navigation_item.render) }
|
59
58
|
end)
|
@@ -44,7 +44,9 @@ module CCS
|
|
44
44
|
def initialize(navigation:, context:, menu_button: nil)
|
45
45
|
menu_button ||= {}
|
46
46
|
menu_button[:text] ||= 'Menu'
|
47
|
-
|
47
|
+
|
48
|
+
menu_button[:aria] = { controls: 'navigation' }
|
49
|
+
menu_button[:aria][:label] = menu_button[:label] if menu_button[:label]
|
48
50
|
|
49
51
|
@menu_button = menu_button
|
50
52
|
@navigation_links = navigation[:items].map { |navigation_link| Link.new(context: context, **navigation_link) }
|
@@ -58,7 +60,7 @@ module CCS
|
|
58
60
|
|
59
61
|
def render
|
60
62
|
tag.nav(aria: { label: navigation_label }, class: navigation_classes) do
|
61
|
-
concat(button_tag(menu_button[:text], type: :button, class: 'govuk-header__menu-button govuk-js-header-toggle', aria:
|
63
|
+
concat(button_tag(menu_button[:text], type: :button, class: 'govuk-header__menu-button govuk-js-header-toggle', aria: menu_button[:aria], hidden: true))
|
62
64
|
concat(tag.ul(id: 'navigation', class: 'govuk-header__navigation-list') do
|
63
65
|
navigation_links.each { |navigation_link| concat(navigation_link.render) }
|
64
66
|
end)
|
@@ -35,16 +35,17 @@ module CCS
|
|
35
35
|
# @option options [String] :container_classes classes for the container
|
36
36
|
# @option options [String] :homepage_url URL of the homepage. Defaults to +/+
|
37
37
|
# @option options [String] :product_name product name, used when the product name follows on directly from ‘GOV.UK
|
38
|
+
# @option options [Boolean] :use_tudor_crown flag to use the new tudor crown for the GOV.UK Logo
|
38
39
|
# @option options [Hash] :attributes additional attributes that will added as part of the header HTML
|
39
40
|
|
40
41
|
def initialize(navigation: nil, menu_button: nil, service: nil, **options)
|
41
42
|
super(**options)
|
42
43
|
|
43
|
-
@options[:attributes][:role] = 'banner'
|
44
44
|
@options[:container_classes] ||= 'govuk-width-container'
|
45
45
|
@options[:homepage_url] ||= '/'
|
46
|
+
@options[:use_tudor_crown] = true if @options[:use_tudor_crown].nil?
|
46
47
|
|
47
|
-
@navigation = Navigation.new(navigation: navigation, menu_button: menu_button, context: @context) if navigation
|
48
|
+
@navigation = Navigation.new(navigation: navigation, menu_button: menu_button, context: @context) if navigation && navigation[:items].present?
|
48
49
|
@service = service
|
49
50
|
end
|
50
51
|
|
@@ -79,12 +80,7 @@ module CCS
|
|
79
80
|
def header_logo
|
80
81
|
tag.div(class: 'govuk-header__logo') do
|
81
82
|
link_to(options[:homepage_url], class: 'govuk-header__link govuk-header__link--homepage') do
|
82
|
-
concat(
|
83
|
-
concat(tag.svg(class: 'govuk-header__logotype-crown', xmlns: 'http://www.w3.org/2000/svg', height: '30', width: '36', aria: { hidden: 'true' }, focusable: 'false', viewBox: '0 0 132 97') do
|
84
|
-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6 7.1-4.1 7.1-8.1 0-.8-.1-1.7-.4-2.4V34l-5.1-15.4c.4-.2.7-.6 1-.9zM66 92.8c16.9 0 32.8 1.1 47.1 3.2 4-16.9 8.9-26.7 14-33.5l-9.6-3.4c1 4.9 1.1 7.2 0 10.2-1.5-1.4-3-4.3-4.2-8.7L108.6 76c2.8-2 5-3.2 7.5-3.3-4.4 9.4-10 11.9-13.6 11.2-4.3-.8-6.3-4.6-5.6-7.9 1-4.7 5.7-5.9 8-.5 4.3-8.7-3-11.4-7.6-8.8 7.1-7.2 7.9-13.5 2.1-21.1-8 6.1-8.1 12.3-4.5 20.8-4.7-5.4-12.1-2.5-9.5 6.2 3.4-5.2 7.9-2 7.2 3.1-.6 4.3-6.4 7.8-13.5 7.2-10.3-.9-10.9-8-11.2-13.8 2.5-.5 7.1 1.8 11 7.3L80.2 60c-4.1 4.4-8 5.3-12.3 5.4 1.4-4.4 8-11.6 8-11.6H55.5s6.4 7.2 7.9 11.6c-4.2-.1-8-1-12.3-5.4l1.4 16.4c3.9-5.5 8.5-7.7 10.9-7.3-.3 5.8-.9 12.8-11.1 13.8-7.2.6-12.9-2.9-13.5-7.2-.7-5 3.8-8.3 7.1-3.1 2.7-8.7-4.6-11.6-9.4-6.2 3.7-8.5 3.6-14.7-4.6-20.8-5.8 7.6-5 13.9 2.2 21.1-4.7-2.6-11.9.1-7.7 8.8 2.3-5.5 7.1-4.2 8.1.5.7 3.3-1.3 7.1-5.7 7.9-3.5.7-9-1.8-13.5-11.2 2.5.1 4.7 1.3 7.5 3.3l-4.7-15.4c-1.2 4.4-2.7 7.2-4.3 8.7-1.1-3-.9-5.3 0-10.2l-9.5 3.4c5 6.9 9.9 16.7 14 33.5 14.8-2.1 30.8-3.2 47.7-3.2z')
|
85
|
-
end)
|
86
|
-
concat(tag.span('GOV.UK', class: 'govuk-header__logotype-text'))
|
87
|
-
end)
|
83
|
+
concat(options[:use_tudor_crown] ? tudor_crown : st_edwards_crown)
|
88
84
|
concat(tag.span(options[:product_name], class: 'govuk-header__product-name')) if options[:product_name]
|
89
85
|
end
|
90
86
|
end
|
@@ -101,6 +97,28 @@ module CCS
|
|
101
97
|
tag.span(service[:name], class: 'govuk-header__service-name')
|
102
98
|
end
|
103
99
|
end
|
100
|
+
|
101
|
+
# Generates the GOV.UK log with St. Edwards Crown
|
102
|
+
#
|
103
|
+
# @return [ActiveSupport::SafeBuffer]
|
104
|
+
|
105
|
+
def st_edwards_crown
|
106
|
+
tag.svg(class: 'govuk-header__logotype', xmlns: 'http://www.w3.org/2000/svg', height: '30', width: '152', aria: { label: 'GOV.UK' }, focusable: 'false', viewBox: '0 0 152 30', role: 'img') do
|
107
|
+
concat(tag.title('GOV.UK'))
|
108
|
+
concat(tag.path(d: 'M6.7 12.2c1 .4 2.1-.1 2.5-1s-.1-2.1-1-2.5c-1-.4-2.1.1-2.5 1-.4 1 0 2.1 1 2.5m-4.3 2.5c1 .4 2.1-.1 2.5-1s-.1-2.1-1-2.5c-1-.4-2.1.1-2.5 1-.5 1 0 2.1 1 2.5m-1.3 4.8c1 .4 2.1-.1 2.5-1 .4-1-.1-2.1-1-2.5-1-.4-2.1.1-2.5 1-.4 1 0 2.1 1 2.5m10.4-5.8c1 .4 2.1-.1 2.5-1s-.1-2.1-1-2.5c-1-.4-2.1.1-2.5 1s0 2.1 1 2.5m17.4-1.5c-1 .4-2.1-.1-2.5-1s.1-2.1 1-2.5c1-.4 2.1.1 2.5 1 .5 1 0 2.1-1 2.5m4.3 2.5c-1 .4-2.1-.1-2.5-1s.1-2.1 1-2.5c1-.4 2.1.1 2.5 1 .5 1 0 2.1-1 2.5m1.3 4.8c-1 .4-2.1-.1-2.5-1-.4-1 .1-2.1 1-2.5 1-.4 2.1.1 2.5 1 .4 1 0 2.1-1 2.5m-10.4-5.8c-1 .4-2.1-.1-2.5-1s.1-2.1 1-2.5c1-.4 2.1.1 2.5 1s0 2.1-1 2.5m-5.3-4.9 2.4 1.3V6.5l-2.4.8c-.1-.1-.1-.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-.4-1.7-.4-2.7v-.1c0-1 .1-1.9.4-2.7.2-.8.6-1.6 1.1-2.2.5-.6 1.1-1.1 1.7-1.4.7-.3 1.5-.5 2.4-.5.9 0 1.7.2 2.4.5s1.3.8 1.7 1.4c.5.6.8 1.3 1.1 2.2.2.8.4 1.7.4 2.7v.1zM92.9 28 87 7h4.7l4 15.7h.1l4-15.7h4.7l-5.9 21h-5.7zm28.8-3.6c.6 0 1.2-.1 1.7-.3.5-.2 1-.4 1.4-.8.4-.4.7-.8.9-1.4.2-.6.3-1.2.3-2v-13h4.1v13.6c0 1.2-.2 2.2-.6 3.1s-1 1.7-1.8 2.4c-.7.7-1.6 1.2-2.7 1.5-1 .4-2.2.5-3.4.5-1.2 0-2.4-.2-3.4-.5-1-.4-1.9-.9-2.7-1.5-.8-.7-1.3-1.5-1.8-2.4-.4-.9-.6-2-.6-3.1V6.9h4.2v13c0 .8.1 1.4.3 2 .2.6.5 1 .9 1.4.4.4.8.6 1.4.8.6.2 1.1.3 1.8.3zm13-17.4h4.2v9.1l7.4-9.1h5.2l-7.2 8.4L152 28h-4.9l-5.5-9.4-2.7 3V28h-4.2V7zm-27.6 16.1c-1.5 0-2.7 1.2-2.7 2.7s1.2 2.7 2.7 2.7 2.7-1.2 2.7-2.7-1.2-2.7-2.7-2.7z'))
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# Generates the GOV.UK logo with a Tudor Crown
|
113
|
+
#
|
114
|
+
# @return [ActiveSupport::SafeBuffer]
|
115
|
+
|
116
|
+
def tudor_crown
|
117
|
+
tag.svg(class: 'govuk-header__logotype', xmlns: 'http://www.w3.org/2000/svg', height: '30', width: '148', aria: { label: 'GOV.UK' }, focusable: 'false', viewBox: '0 0 148 30', role: 'img') do
|
118
|
+
concat(tag.title('GOV.UK'))
|
119
|
+
concat(tag.path(d: 'M22.6 10.4c-1 .4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 2 .1 2.4 1s-.1 2-1 2.4m-5.9 6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2.7 2.7 2.7 2.7-1.2 2.7-2.7-1.2-2.7-2.7-2.7z'))
|
120
|
+
end
|
121
|
+
end
|
104
122
|
end
|
105
123
|
end
|
106
124
|
end
|
@@ -14,8 +14,8 @@ module CCS
|
|
14
14
|
#
|
15
15
|
# @option (see Increment#initialize)
|
16
16
|
|
17
|
-
def initialize(text:
|
18
|
-
super(type: :next, text: text, **options)
|
17
|
+
def initialize(text: nil, **options)
|
18
|
+
super(type: :next, text: text, default_text: 'Next', **options)
|
19
19
|
end
|
20
20
|
|
21
21
|
# Generates the HTML for the next link in the pagination
|
@@ -26,7 +26,10 @@ module CCS
|
|
26
26
|
tag.div(class: 'govuk-pagination__next') do
|
27
27
|
super() do
|
28
28
|
concat(pagination_icon) if block_is_level
|
29
|
-
concat(tag.span(
|
29
|
+
concat(tag.span(class: pagination_text_classes) do
|
30
|
+
concat(text)
|
31
|
+
concat(tag.span(' page', class: 'govuk-visually-hidden')) if text == default_text
|
32
|
+
end)
|
30
33
|
pagination_icon_label_text
|
31
34
|
concat(pagination_icon) unless block_is_level
|
32
35
|
end
|
@@ -14,8 +14,8 @@ module CCS
|
|
14
14
|
#
|
15
15
|
# @option (see Increment#initialize)
|
16
16
|
|
17
|
-
def initialize(text:
|
18
|
-
super(type: :prev, text: text, **options)
|
17
|
+
def initialize(text: nil, **options)
|
18
|
+
super(type: :prev, text: text, default_text: 'Previous', **options)
|
19
19
|
end
|
20
20
|
|
21
21
|
# Generates the HTML for the previous link in the pagination
|
@@ -26,7 +26,10 @@ module CCS
|
|
26
26
|
tag.div(class: 'govuk-pagination__prev') do
|
27
27
|
super() do
|
28
28
|
concat(pagination_icon)
|
29
|
-
concat(tag.span(
|
29
|
+
concat(tag.span(class: pagination_text_classes) do
|
30
|
+
concat(text)
|
31
|
+
concat(tag.span(' page', class: 'govuk-visually-hidden')) if text == default_text
|
32
|
+
end)
|
30
33
|
pagination_icon_label_text
|
31
34
|
end
|
32
35
|
end
|
@@ -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)
|
@@ -46,8 +46,7 @@ module CCS
|
|
46
46
|
block_is_level = pagination_items.blank? && (pagination_previous.present? || pagination_next.present?)
|
47
47
|
|
48
48
|
@options[:attributes][:class] << ' govuk-pagination--block' if block_is_level
|
49
|
-
@options[:attributes][:
|
50
|
-
(@options[:attributes][:aria] ||= {})[:label] ||= 'results'
|
49
|
+
(@options[:attributes][:aria] ||= {})[:label] ||= 'Pagination'
|
51
50
|
|
52
51
|
@pagination_previous = Increment::Previous.new(block_is_level: block_is_level, form: @options[:form], context: @context, **pagination_previous) if pagination_previous
|
53
52
|
@pagination_next = Increment::Next.new(block_is_level: block_is_level, form: @options[:form], context: @context, **pagination_next) if pagination_next
|
@@ -88,7 +87,7 @@ module CCS
|
|
88
87
|
|
89
88
|
pagination_item_class = form ? Item::Form : Item::Tag
|
90
89
|
|
91
|
-
@pagination_items = pagination_items.map { |pagination_item| pagination_item[:
|
90
|
+
@pagination_items = pagination_items.map { |pagination_item| pagination_item[:ellipsis] ? Item::Ellipsis : pagination_item_class.new(form: form, context: context, **pagination_item) }
|
92
91
|
end
|
93
92
|
end
|
94
93
|
end
|