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.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -1
  3. data/Gemfile.lock +1 -1
  4. data/lib/ccs/components/ccs/dashboard_section/panel.rb +43 -41
  5. data/lib/ccs/components/ccs/dashboard_section.rb +50 -48
  6. data/lib/ccs/components/ccs/footer/link.rb +41 -39
  7. data/lib/ccs/components/ccs/footer/meta.rb +49 -48
  8. data/lib/ccs/components/ccs/footer/navigation.rb +51 -50
  9. data/lib/ccs/components/ccs/footer.rb +69 -67
  10. data/lib/ccs/components/ccs/header/link.rb +47 -45
  11. data/lib/ccs/components/ccs/header/navigation.rb +85 -84
  12. data/lib/ccs/components/ccs/header/service_authentication.rb +35 -34
  13. data/lib/ccs/components/ccs/header.rb +87 -85
  14. data/lib/ccs/components/ccs/logo.rb +36 -34
  15. data/lib/ccs/components/govuk/accordion/section/content.rb +42 -42
  16. data/lib/ccs/components/govuk/accordion/section/header.rb +48 -48
  17. data/lib/ccs/components/govuk/accordion/section.rb +49 -48
  18. data/lib/ccs/components/govuk/accordion.rb +43 -41
  19. data/lib/ccs/components/govuk/back_link.rb +39 -37
  20. data/lib/ccs/components/govuk/breadcrumbs/link.rb +42 -40
  21. data/lib/ccs/components/govuk/breadcrumbs.rb +40 -38
  22. data/lib/ccs/components/govuk/button.rb +83 -81
  23. data/lib/ccs/components/govuk/cookie_banner/action.rb +45 -43
  24. data/lib/ccs/components/govuk/cookie_banner/message.rb +57 -55
  25. data/lib/ccs/components/govuk/cookie_banner.rb +40 -38
  26. data/lib/ccs/components/govuk/details.rb +38 -36
  27. data/lib/ccs/components/govuk/error_message.rb +46 -44
  28. data/lib/ccs/components/govuk/error_summary/item.rb +41 -39
  29. data/lib/ccs/components/govuk/error_summary.rb +49 -47
  30. data/lib/ccs/components/govuk/field/input/character_count.rb +101 -99
  31. data/lib/ccs/components/govuk/field/input/file_upload.rb +29 -27
  32. data/lib/ccs/components/govuk/field/input/select.rb +61 -59
  33. data/lib/ccs/components/govuk/field/input/text_input/fix.rb +39 -37
  34. data/lib/ccs/components/govuk/field/input/text_input.rb +75 -73
  35. data/lib/ccs/components/govuk/field/input/textarea.rb +43 -41
  36. data/lib/ccs/components/govuk/field/input.rb +46 -44
  37. data/lib/ccs/components/govuk/field/inputs/checkboxes.rb +43 -41
  38. data/lib/ccs/components/govuk/field/inputs/date_input/item.rb +48 -46
  39. data/lib/ccs/components/govuk/field/inputs/date_input.rb +68 -66
  40. data/lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb +29 -27
  41. data/lib/ccs/components/govuk/field/inputs/item/checkbox/tag.rb +26 -24
  42. data/lib/ccs/components/govuk/field/inputs/item/checkbox.rb +32 -30
  43. data/lib/ccs/components/govuk/field/inputs/item/divider.rb +39 -37
  44. data/lib/ccs/components/govuk/field/inputs/item/radio/form.rb +27 -25
  45. data/lib/ccs/components/govuk/field/inputs/item/radio/tag.rb +26 -24
  46. data/lib/ccs/components/govuk/field/inputs/item/radio.rb +32 -30
  47. data/lib/ccs/components/govuk/field/inputs/item.rb +100 -98
  48. data/lib/ccs/components/govuk/field/inputs/radios.rb +43 -41
  49. data/lib/ccs/components/govuk/field/inputs.rb +42 -40
  50. data/lib/ccs/components/govuk/field.rb +90 -88
  51. data/lib/ccs/components/govuk/fieldset/legend.rb +50 -48
  52. data/lib/ccs/components/govuk/fieldset.rb +40 -38
  53. data/lib/ccs/components/govuk/footer/link.rb +41 -39
  54. data/lib/ccs/components/govuk/footer/meta.rb +49 -48
  55. data/lib/ccs/components/govuk/footer/navigation.rb +51 -50
  56. data/lib/ccs/components/govuk/footer.rb +105 -103
  57. data/lib/ccs/components/govuk/form_group.rb +45 -43
  58. data/lib/ccs/components/govuk/header/link.rb +41 -39
  59. data/lib/ccs/components/govuk/header/navigation.rb +54 -53
  60. data/lib/ccs/components/govuk/header.rb +84 -82
  61. data/lib/ccs/components/govuk/hint.rb +33 -31
  62. data/lib/ccs/components/govuk/inset_text.rb +39 -37
  63. data/lib/ccs/components/govuk/label.rb +61 -59
  64. data/lib/ccs/components/govuk/notification_banner.rb +83 -81
  65. data/lib/ccs/components/govuk/pagination/increment/next.rb +29 -27
  66. data/lib/ccs/components/govuk/pagination/increment/previous.rb +28 -26
  67. data/lib/ccs/components/govuk/pagination/increment.rb +78 -76
  68. data/lib/ccs/components/govuk/pagination/item/ellipsis.rb +17 -15
  69. data/lib/ccs/components/govuk/pagination/item/form.rb +34 -32
  70. data/lib/ccs/components/govuk/pagination/item/tag.rb +33 -31
  71. data/lib/ccs/components/govuk/pagination/item.rb +47 -45
  72. data/lib/ccs/components/govuk/pagination.rb +69 -67
  73. data/lib/ccs/components/govuk/panel.rb +49 -47
  74. data/lib/ccs/components/govuk/phase_banner.rb +50 -48
  75. data/lib/ccs/components/govuk/skip_link.rb +39 -37
  76. data/lib/ccs/components/govuk/step_by_step_navigation/section/content/list/item.rb +40 -38
  77. data/lib/ccs/components/govuk/step_by_step_navigation/section/content/list.rb +30 -28
  78. data/lib/ccs/components/govuk/step_by_step_navigation/section/content/paragraph.rb +28 -26
  79. data/lib/ccs/components/govuk/step_by_step_navigation/section/content.rb +47 -45
  80. data/lib/ccs/components/govuk/step_by_step_navigation/section/heading.rb +49 -47
  81. data/lib/ccs/components/govuk/step_by_step_navigation/section.rb +44 -42
  82. data/lib/ccs/components/govuk/step_by_step_navigation.rb +41 -39
  83. data/lib/ccs/components/govuk/summary_list/action/link.rb +46 -44
  84. data/lib/ccs/components/govuk/summary_list/card/actions.rb +38 -36
  85. data/lib/ccs/components/govuk/summary_list/card/title.rb +37 -35
  86. data/lib/ccs/components/govuk/summary_list/card.rb +48 -46
  87. data/lib/ccs/components/govuk/summary_list/row/actions.rb +38 -36
  88. data/lib/ccs/components/govuk/summary_list/row/key.rb +30 -28
  89. data/lib/ccs/components/govuk/summary_list/row/value.rb +30 -28
  90. data/lib/ccs/components/govuk/summary_list/row.rb +47 -45
  91. data/lib/ccs/components/govuk/summary_list.rb +48 -46
  92. data/lib/ccs/components/govuk/table/body/data_cell.rb +38 -36
  93. data/lib/ccs/components/govuk/table/body/head_cell.rb +37 -35
  94. data/lib/ccs/components/govuk/table/header/head_cell.rb +39 -37
  95. data/lib/ccs/components/govuk/table.rb +83 -81
  96. data/lib/ccs/components/govuk/tabs/panel.rb +47 -45
  97. data/lib/ccs/components/govuk/tabs/tab.rb +42 -40
  98. data/lib/ccs/components/govuk/tabs.rb +48 -46
  99. data/lib/ccs/components/govuk/tag.rb +39 -37
  100. data/lib/ccs/components/govuk/warning_text.rb +49 -47
  101. data/lib/ccs/frontend_helpers/ccs_frontend/dashboard_section.rb +16 -14
  102. data/lib/ccs/frontend_helpers/ccs_frontend/footer.rb +17 -15
  103. data/lib/ccs/frontend_helpers/ccs_frontend/header.rb +17 -15
  104. data/lib/ccs/frontend_helpers/ccs_frontend.rb +1 -1
  105. data/lib/ccs/frontend_helpers/govuk_frontend/accordion.rb +17 -15
  106. data/lib/ccs/frontend_helpers/govuk_frontend/back_link.rb +17 -15
  107. data/lib/ccs/frontend_helpers/govuk_frontend/breadcrumbs.rb +17 -15
  108. data/lib/ccs/frontend_helpers/govuk_frontend/button.rb +17 -15
  109. data/lib/ccs/frontend_helpers/govuk_frontend/character_count.rb +17 -15
  110. data/lib/ccs/frontend_helpers/govuk_frontend/checkboxes.rb +17 -15
  111. data/lib/ccs/frontend_helpers/govuk_frontend/cookie_banner.rb +17 -15
  112. data/lib/ccs/frontend_helpers/govuk_frontend/date_input.rb +17 -15
  113. data/lib/ccs/frontend_helpers/govuk_frontend/details.rb +19 -17
  114. data/lib/ccs/frontend_helpers/govuk_frontend/error_message.rb +32 -30
  115. data/lib/ccs/frontend_helpers/govuk_frontend/error_summary.rb +38 -36
  116. data/lib/ccs/frontend_helpers/govuk_frontend/fieldset.rb +19 -17
  117. data/lib/ccs/frontend_helpers/govuk_frontend/file_upload.rb +17 -15
  118. data/lib/ccs/frontend_helpers/govuk_frontend/footer.rb +17 -15
  119. data/lib/ccs/frontend_helpers/govuk_frontend/form_group.rb +27 -25
  120. data/lib/ccs/frontend_helpers/govuk_frontend/header.rb +17 -15
  121. data/lib/ccs/frontend_helpers/govuk_frontend/hint.rb +18 -16
  122. data/lib/ccs/frontend_helpers/govuk_frontend/input.rb +17 -15
  123. data/lib/ccs/frontend_helpers/govuk_frontend/inset_text.rb +19 -17
  124. data/lib/ccs/frontend_helpers/govuk_frontend/label.rb +18 -16
  125. data/lib/ccs/frontend_helpers/govuk_frontend/notification_banner.rb +19 -17
  126. data/lib/ccs/frontend_helpers/govuk_frontend/pagination.rb +17 -15
  127. data/lib/ccs/frontend_helpers/govuk_frontend/panel.rb +19 -17
  128. data/lib/ccs/frontend_helpers/govuk_frontend/phase_banner.rb +19 -17
  129. data/lib/ccs/frontend_helpers/govuk_frontend/radios.rb +17 -15
  130. data/lib/ccs/frontend_helpers/govuk_frontend/select.rb +17 -15
  131. data/lib/ccs/frontend_helpers/govuk_frontend/skip_link.rb +17 -15
  132. data/lib/ccs/frontend_helpers/govuk_frontend/step_by_step_navigation.rb +24 -22
  133. data/lib/ccs/frontend_helpers/govuk_frontend/summary_list.rb +17 -15
  134. data/lib/ccs/frontend_helpers/govuk_frontend/table.rb +17 -15
  135. data/lib/ccs/frontend_helpers/govuk_frontend/tabs.rb +17 -15
  136. data/lib/ccs/frontend_helpers/govuk_frontend/tag.rb +17 -15
  137. data/lib/ccs/frontend_helpers/govuk_frontend/textarea.rb +17 -15
  138. data/lib/ccs/frontend_helpers/govuk_frontend/warning_text.rb +19 -17
  139. data/lib/ccs/frontend_helpers/version.rb +1 -1
  140. metadata +2 -2
@@ -1,105 +1,107 @@
1
1
  require_relative '../base'
2
2
 
3
- module CCS::Components
4
- module GovUK
5
- # = GOV.UK Notification Banner
6
- #
7
- # This helper is used for generating the notification banner component from the
8
- # {https://design-system.service.gov.uk/components/notification-banner GDS - Components - Notification banner}
9
- #
10
- # @!attribute [r] text
11
- # @return [String] Text for the notification banner
12
- # @!attribute [r] success_banner
13
- # @return [Boolean] Indicates if this is a success banner
14
-
15
- class NotificationBanner < Base
16
- private
17
-
18
- attr_reader :text, :success_banner
19
-
20
- public
21
-
22
- # @param text [String] the text that will be used for the heading in the content section of the banner.
23
- # It is ignored if a block is given
24
- # @param success_banner [Boolean] will use the success banner options if this is set to true
25
- # @param options [Hash] options that will be used in customising the HTML
3
+ module CCS
4
+ module Components
5
+ module GovUK
6
+ # = GOV.UK Notification Banner
26
7
  #
27
- # @option options [String] :classes additional CSS classes for the notification banner HTML
28
- # @option options [String] :title_text ('Important') the title text shown at the top of the banner
29
- # @option options [String] :title_id ('govuk-notification-banner-title') the ID for the title text
30
- # @option options [String] :role ('region') the role for the banner
31
- # @option options [String] :heading_level (2) the heading level for the title text
32
- # @option options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
8
+ # This helper is used for generating the notification banner component from the
9
+ # {https://design-system.service.gov.uk/components/notification-banner GDS - Components - Notification banner}
10
+ #
11
+ # @!attribute [r] text
12
+ # @return [String] Text for the notification banner
13
+ # @!attribute [r] success_banner
14
+ # @return [Boolean] Indicates if this is a success banner
33
15
 
34
- def initialize(text: nil, success_banner: nil, **options)
35
- super(**options)
16
+ class NotificationBanner < Base
17
+ private
36
18
 
37
- @text = text
38
- @success_banner = success_banner || false
19
+ attr_reader :text, :success_banner
39
20
 
40
- set_additional_options_for_banner
41
- end
21
+ public
42
22
 
43
- # Generates the HTML for the GOV.UK Notification banner component
44
- #
45
- # @yield HTML that will be contained within the 'govuk-notification-banner__content' div
46
- #
47
- # @return [ActiveSupport::SafeBuffer]
48
-
49
- def render
50
- tag.div(**options[:attributes]) do
51
- concat(tag.div(class: 'govuk-notification-banner__header') do
52
- tag.send(:"h#{options[:heading_level] || 2}", options[:title_text], class: 'govuk-notification-banner__title', id: options[:title_id])
53
- end)
54
- concat(tag.div(class: 'govuk-notification-banner__content') do
55
- if block_given?
56
- yield
57
- else
58
- tag.p(text, class: 'govuk-notification-banner__heading')
59
- end
60
- end)
23
+ # @param text [String] the text that will be used for the heading in the content section of the banner.
24
+ # It is ignored if a block is given
25
+ # @param success_banner [Boolean] will use the success banner options if this is set to true
26
+ # @param options [Hash] options that will be used in customising the HTML
27
+ #
28
+ # @option options [String] :classes additional CSS classes for the notification banner HTML
29
+ # @option options [String] :title_text ('Important') the title text shown at the top of the banner
30
+ # @option options [String] :title_id ('govuk-notification-banner-title') the ID for the title text
31
+ # @option options [String] :role ('region') the role for the banner
32
+ # @option options [String] :heading_level (2) the heading level for the title text
33
+ # @option options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML
34
+
35
+ def initialize(text: nil, success_banner: nil, **options)
36
+ super(**options)
37
+
38
+ @text = text
39
+ @success_banner = success_banner || false
40
+
41
+ set_additional_options_for_banner
61
42
  end
62
- end
63
43
 
64
- # The default attributes for the notifaction banner
44
+ # Generates the HTML for the GOV.UK Notification banner component
45
+ #
46
+ # @yield HTML that will be contained within the 'govuk-notification-banner__content' div
47
+ #
48
+ # @return [ActiveSupport::SafeBuffer]
49
+
50
+ def render
51
+ tag.div(**options[:attributes]) do
52
+ concat(tag.div(class: 'govuk-notification-banner__header') do
53
+ tag.send(:"h#{options[:heading_level] || 2}", options[:title_text], class: 'govuk-notification-banner__title', id: options[:title_id])
54
+ end)
55
+ concat(tag.div(class: 'govuk-notification-banner__content') do
56
+ if block_given?
57
+ yield
58
+ else
59
+ tag.p(text, class: 'govuk-notification-banner__heading')
60
+ end
61
+ end)
62
+ end
63
+ end
65
64
 
66
- DEFAULT_ATTRIBUTES = { class: 'govuk-notification-banner', data: { module: 'govuk-notification-banner' } }.freeze
65
+ # The default attributes for the notifaction banner
67
66
 
68
- # Default options used in normal versions of the notification banner
67
+ DEFAULT_ATTRIBUTES = { class: 'govuk-notification-banner', data: { module: 'govuk-notification-banner' } }.freeze
69
68
 
70
- DEFAULT_OPTIONS = {
71
- title_text: 'Important',
72
- title_id: 'govuk-notification-banner-title',
73
- role: 'region'
74
- }.freeze
69
+ # Default options used in normal versions of the notification banner
75
70
 
76
- # Specific options for the success version of the notification banner
71
+ DEFAULT_OPTIONS = {
72
+ title_text: 'Important',
73
+ title_id: 'govuk-notification-banner-title',
74
+ role: 'region'
75
+ }.freeze
77
76
 
78
- SUCCESS_BANNER_OPTIONS = {
79
- classes: ' govuk-notification-banner--success',
80
- title_text: 'Success',
81
- role: 'alert'
82
- }.freeze
77
+ # Specific options for the success version of the notification banner
83
78
 
84
- private
79
+ SUCCESS_BANNER_OPTIONS = {
80
+ classes: ' govuk-notification-banner--success',
81
+ title_text: 'Success',
82
+ role: 'alert'
83
+ }.freeze
85
84
 
86
- # rubocop:disable Metrics/AbcSize
85
+ private
87
86
 
88
- # Determines the banner options to be used for the notification banner
87
+ # rubocop:disable Metrics/AbcSize
89
88
 
90
- def set_additional_options_for_banner
91
- banner_options = DEFAULT_OPTIONS.dup
89
+ # Determines the banner options to be used for the notification banner
92
90
 
93
- banner_options.merge!(SUCCESS_BANNER_OPTIONS) if success_banner
91
+ def set_additional_options_for_banner
92
+ banner_options = DEFAULT_OPTIONS.dup
94
93
 
95
- options[:title_text] ||= banner_options[:title_text]
96
- options[:title_id] ||= banner_options[:title_id]
97
- options[:attributes][:role] ||= banner_options[:role]
98
- options[:attributes][:class] << banner_options[:classes].to_s
99
- (options[:attributes][:aria] ||= {})[:labelledby] = options[:title_id]
100
- end
94
+ banner_options.merge!(SUCCESS_BANNER_OPTIONS) if success_banner
101
95
 
102
- # rubocop:enable Metrics/AbcSize
96
+ options[:title_text] ||= banner_options[:title_text]
97
+ options[:title_id] ||= banner_options[:title_id]
98
+ options[:attributes][:role] ||= banner_options[:role]
99
+ options[:attributes][:class] << banner_options[:classes].to_s
100
+ (options[:attributes][:aria] ||= {})[:labelledby] = options[:title_id]
101
+ end
102
+
103
+ # rubocop:enable Metrics/AbcSize
104
+ end
103
105
  end
104
106
  end
105
107
  end
@@ -1,40 +1,42 @@
1
1
  require_relative '../increment'
2
2
 
3
- module CCS::Components
4
- module GovUK
5
- class Pagination < Base
6
- class Increment < Base
7
- # = GOV.UK Pagination Next
8
- #
9
- # This generates the HTML for the pagination next link
10
-
11
- class Next < Increment
12
- # @param (see Increment#initialize)
3
+ module CCS
4
+ module Components
5
+ module GovUK
6
+ class Pagination < Base
7
+ class Increment < Base
8
+ # = GOV.UK Pagination Next
13
9
  #
14
- # @option (see Increment#initialize)
10
+ # This generates the HTML for the pagination next link
15
11
 
16
- def initialize(text: 'Next', **options)
17
- super(type: :next, text: text, **options)
18
- end
12
+ class Next < Increment
13
+ # @param (see Increment#initialize)
14
+ #
15
+ # @option (see Increment#initialize)
19
16
 
20
- # Generates the HTML for the next link in the pagination
21
- #
22
- # @return [ActiveSupport::SafeBuffer]
17
+ def initialize(text: 'Next', **options)
18
+ super(type: :next, text: text, **options)
19
+ end
23
20
 
24
- def render
25
- tag.div(class: 'govuk-pagination__next') do
26
- super() do
27
- concat(pagination_icon) if block_is_level
28
- concat(tag.span(text, class: pagination_text_classes))
29
- pagination_icon_label_text
30
- concat(pagination_icon) unless block_is_level
21
+ # Generates the HTML for the next link in the pagination
22
+ #
23
+ # @return [ActiveSupport::SafeBuffer]
24
+
25
+ def render
26
+ tag.div(class: 'govuk-pagination__next') do
27
+ super() do
28
+ concat(pagination_icon) if block_is_level
29
+ concat(tag.span(text, class: pagination_text_classes))
30
+ pagination_icon_label_text
31
+ concat(pagination_icon) unless block_is_level
32
+ end
31
33
  end
32
34
  end
33
- end
34
35
 
35
- # The path for the pagination next icon
36
+ # The path for the pagination next icon
36
37
 
37
- PAGINATION_ICON_PATH = 'm8.107-0.0078125-1.4136 1.414 4.2926 4.293h-12.986v2h12.896l-4.1855 3.9766 1.377 1.4492 6.7441-6.4062-6.7246-6.7266z'.freeze
38
+ PAGINATION_ICON_PATH = 'm8.107-0.0078125-1.4136 1.414 4.2926 4.293h-12.986v2h12.896l-4.1855 3.9766 1.377 1.4492 6.7441-6.4062-6.7246-6.7266z'.freeze
39
+ end
38
40
  end
39
41
  end
40
42
  end
@@ -1,39 +1,41 @@
1
1
  require_relative '../increment'
2
2
 
3
- module CCS::Components
4
- module GovUK
5
- class Pagination < Base
6
- class Increment < Base
7
- # = GOV.UK Pagination Previous
8
- #
9
- # This generates the HTML for the pagination previous link
10
-
11
- class Previous < Increment
12
- # @param (see Increment#initialize)
3
+ module CCS
4
+ module Components
5
+ module GovUK
6
+ class Pagination < Base
7
+ class Increment < Base
8
+ # = GOV.UK Pagination Previous
13
9
  #
14
- # @option (see Increment#initialize)
10
+ # This generates the HTML for the pagination previous link
15
11
 
16
- def initialize(text: 'Previous', **options)
17
- super(type: :prev, text: text, **options)
18
- end
12
+ class Previous < Increment
13
+ # @param (see Increment#initialize)
14
+ #
15
+ # @option (see Increment#initialize)
19
16
 
20
- # Generates the HTML for the previous link in the pagination
21
- #
22
- # @return [ActiveSupport::SafeBuffer]
17
+ def initialize(text: 'Previous', **options)
18
+ super(type: :prev, text: text, **options)
19
+ end
23
20
 
24
- def render
25
- tag.div(class: 'govuk-pagination__prev') do
26
- super() do
27
- concat(pagination_icon)
28
- concat(tag.span(text, class: pagination_text_classes))
29
- pagination_icon_label_text
21
+ # Generates the HTML for the previous link in the pagination
22
+ #
23
+ # @return [ActiveSupport::SafeBuffer]
24
+
25
+ def render
26
+ tag.div(class: 'govuk-pagination__prev') do
27
+ super() do
28
+ concat(pagination_icon)
29
+ concat(tag.span(text, class: pagination_text_classes))
30
+ pagination_icon_label_text
31
+ end
30
32
  end
31
33
  end
32
- end
33
34
 
34
- # The path for the pagination previous icon
35
+ # The path for the pagination previous icon
35
36
 
36
- PAGINATION_ICON_PATH = 'm6.5938-0.0078125-6.7266 6.7266 6.7441 6.4062 1.377-1.449-4.1856-3.9768h12.896v-2h-12.984l4.2931-4.293-1.414-1.414z'.freeze
37
+ PAGINATION_ICON_PATH = 'm6.5938-0.0078125-6.7266 6.7266 6.7441 6.4062 1.377-1.449-4.1856-3.9768h12.896v-2h-12.984l4.2931-4.293-1.414-1.414z'.freeze
38
+ end
37
39
  end
38
40
  end
39
41
  end
@@ -1,94 +1,96 @@
1
1
  require_relative '../../base'
2
2
 
3
- module CCS::Components
4
- module GovUK
5
- class Pagination < Base
6
- # = GOV.UK Pagination Increment
7
- #
8
- # This generates the HTML for a pagination increment, that is {Previous} and {Next}
9
- #
10
- # @!attribute [r] type
11
- # @return [Symbol] The type of pagination increment
12
- # @!attribute [r] text
13
- # @return [String] Text for the pagination increment
14
- # @!attribute [r] block_is_level
15
- # @return [Boolean] Flag to indicate if previous and next blocks are level
16
- # @!attribute [r] label_text
17
- # @return [Boolean] Additional label text for when +block_is_level == true+
18
-
19
- class Increment < Base
20
- private
21
-
22
- attr_reader :type, :text, :block_is_level, :label_text
23
-
24
- public
25
-
26
- # @param type [Symbol] the type of increment, either +:prev+ or +:next+
27
- # @param text [String] the text for the pagination increment
28
- # @param block_is_level [Boolean] when there are no items, this will be true and will add extra classes
29
- # to the link to make the next and previous pagination links level
30
- # @param label_text [String] additional text for the link when the pagination block is level
31
- # @param options [Hash] options that will be used in customising the HTML
3
+ module CCS
4
+ module Components
5
+ module GovUK
6
+ class Pagination < Base
7
+ # = GOV.UK Pagination Increment
32
8
  #
33
- # @option options [String] :href the URL for the link
34
- # @option options [ActionView::Helpers::FormBuilder] :form optional form builder used to create the button
35
- # @option options [Hash] :attributes any additional attributes that will added as part of the HTML
36
-
37
- def initialize(type:, text:, block_is_level:, label_text: nil, **options)
38
- super(**options)
39
-
40
- @options[:attributes][:class] = "govuk-link govuk-pagination__link #{'pagination--button_as_link' if @options[:form]}".rstrip
41
- @options[:attributes][:rel] = type.to_s
42
-
43
- @type = type
44
- @text = text
45
- @block_is_level = block_is_level
46
- @label_text = label_text
47
- end
48
-
49
- # Generates the HTML for the pagination increment link/button
50
- #
51
- # @yield the HTML for the increment button/link
9
+ # This generates the HTML for a pagination increment, that is {Previous} and {Next}
52
10
  #
53
- # @return [ActiveSupport::SafeBuffer]
11
+ # @!attribute [r] type
12
+ # @return [Symbol] The type of pagination increment
13
+ # @!attribute [r] text
14
+ # @return [String] Text for the pagination increment
15
+ # @!attribute [r] block_is_level
16
+ # @return [Boolean] Flag to indicate if previous and next blocks are level
17
+ # @!attribute [r] label_text
18
+ # @return [Boolean] Additional label text for when +block_is_level == true+
19
+
20
+ class Increment < Base
21
+ private
22
+
23
+ attr_reader :type, :text, :block_is_level, :label_text
24
+
25
+ public
26
+
27
+ # @param type [Symbol] the type of increment, either +:prev+ or +:next+
28
+ # @param text [String] the text for the pagination increment
29
+ # @param block_is_level [Boolean] when there are no items, this will be true and will add extra classes
30
+ # to the link to make the next and previous pagination links level
31
+ # @param label_text [String] additional text for the link when the pagination block is level
32
+ # @param options [Hash] options that will be used in customising the HTML
33
+ #
34
+ # @option options [String] :href the URL for the link
35
+ # @option options [ActionView::Helpers::FormBuilder] :form optional form builder used to create the button
36
+ # @option options [Hash] :attributes any additional attributes that will added as part of the HTML
37
+
38
+ def initialize(type:, text:, block_is_level:, label_text: nil, **options)
39
+ super(**options)
40
+
41
+ @options[:attributes][:class] = "govuk-link govuk-pagination__link #{'pagination--button_as_link' if @options[:form]}".rstrip
42
+ @options[:attributes][:rel] = type.to_s
43
+
44
+ @type = type
45
+ @text = text
46
+ @block_is_level = block_is_level
47
+ @label_text = label_text
48
+ end
54
49
 
55
- def render(&block)
56
- if options[:form]
57
- options[:form].button(**options[:attributes], &block)
58
- else
59
- link_to(options[:href], **options[:attributes], &block)
50
+ # Generates the HTML for the pagination increment link/button
51
+ #
52
+ # @yield the HTML for the increment button/link
53
+ #
54
+ # @return [ActiveSupport::SafeBuffer]
55
+
56
+ def render(&block)
57
+ if options[:form]
58
+ options[:form].button(**options[:attributes], &block)
59
+ else
60
+ link_to(options[:href], **options[:attributes], &block)
61
+ end
60
62
  end
61
- end
62
63
 
63
- private
64
+ private
64
65
 
65
- # Returns the classes for the link/button label
66
- #
67
- # @return [String]
66
+ # Returns the classes for the link/button label
67
+ #
68
+ # @return [String]
68
69
 
69
- def pagination_text_classes
70
- "govuk-pagination__link-title #{'govuk-pagination__link-title--decorated' if block_is_level && !label_text}".rstrip
71
- end
70
+ def pagination_text_classes
71
+ "govuk-pagination__link-title #{'govuk-pagination__link-title--decorated' if block_is_level && !label_text}".rstrip
72
+ end
72
73
 
73
- # Generates the icon for the pagination increment
74
- #
75
- # @return [ActiveSupport::SafeBuffer]
74
+ # Generates the icon for the pagination increment
75
+ #
76
+ # @return [ActiveSupport::SafeBuffer]
76
77
 
77
- def pagination_icon
78
- tag.svg(class: "govuk-pagination__icon govuk-pagination__icon--#{type}", xmlns: 'http://www.w3.org/2000/svg', height: '13', width: '15', aria: { hidden: 'true' }, focusable: 'false', viewBox: '0 0 15 13') do
79
- tag.path(d: self.class::PAGINATION_ICON_PATH)
78
+ def pagination_icon
79
+ tag.svg(class: "govuk-pagination__icon govuk-pagination__icon--#{type}", xmlns: 'http://www.w3.org/2000/svg', height: '13', width: '15', aria: { hidden: 'true' }, focusable: 'false', viewBox: '0 0 15 13') do
80
+ tag.path(d: self.class::PAGINATION_ICON_PATH)
81
+ end
80
82
  end
81
- end
82
83
 
83
- # Generates the label text for when the block is level
84
- #
85
- # @return [ActiveSupport::SafeBuffer]
84
+ # Generates the label text for when the block is level
85
+ #
86
+ # @return [ActiveSupport::SafeBuffer]
86
87
 
87
- def pagination_icon_label_text
88
- return unless block_is_level && label_text
88
+ def pagination_icon_label_text
89
+ return unless block_is_level && label_text
89
90
 
90
- concat(tag.span(':', class: 'govuk-visually-hidden'))
91
- concat(tag.span(label_text, class: 'govuk-pagination__link-label'))
91
+ concat(tag.span(':', class: 'govuk-visually-hidden'))
92
+ concat(tag.span(label_text, class: 'govuk-pagination__link-label'))
93
+ end
92
94
  end
93
95
  end
94
96
  end
@@ -1,23 +1,25 @@
1
1
  require 'action_view'
2
2
 
3
- module CCS::Components
4
- module GovUK
5
- class Pagination < Base
6
- class Item < Base
7
- # = GOV.UK Pagination Item ellipsis
8
- #
9
- # This generates the HTML for a pagination ellipsis
3
+ module CCS
4
+ module Components
5
+ module GovUK
6
+ class Pagination < Base
7
+ class Item < Base
8
+ # = GOV.UK Pagination Item ellipsis
9
+ #
10
+ # This generates the HTML for a pagination ellipsis
10
11
 
11
- class Ellipsis
12
- extend ActionView::Context
13
- extend ActionView::Helpers
12
+ class Ellipsis
13
+ extend ActionView::Context
14
+ extend ActionView::Helpers
14
15
 
15
- # Generates the HTML for the GOV.UK Pagination Item ellipsis
16
- #
17
- # @return [ActiveSupport::SafeBuffer]
16
+ # Generates the HTML for the GOV.UK Pagination Item ellipsis
17
+ #
18
+ # @return [ActiveSupport::SafeBuffer]
18
19
 
19
- def self.render
20
- tag.li('⋯', class: 'govuk-pagination__item govuk-pagination__item--ellipses')
20
+ def self.render
21
+ tag.li('⋯', class: 'govuk-pagination__item govuk-pagination__item--ellipses')
22
+ end
21
23
  end
22
24
  end
23
25
  end
@@ -1,43 +1,45 @@
1
1
  require_relative '../item'
2
2
 
3
- module CCS::Components
4
- module GovUK
5
- class Pagination < Base
6
- class Item < Base
7
- # = GOV.UK Pagination Item form
8
- #
9
- # This generates the HTML for the pagination item using a button tag
10
- #
11
- # @!attribute [r] form
12
- # @return [ActionView::Helpers::FormBuilder] Form builder used to create the button
13
-
14
- class Form < Item
15
- private
16
-
17
- attr_reader :form
18
-
19
- public
20
-
21
- # @param (see CCS::Components::GovUK::Pagination::Item)
22
- # @param form [ActionView::Helpers::FormBuilder] form builder used to create the button
3
+ module CCS
4
+ module Components
5
+ module GovUK
6
+ class Pagination < Base
7
+ class Item < Base
8
+ # = GOV.UK Pagination Item form
23
9
  #
24
- # @option (see CCS::Components::GovUK::Pagination::Item)
10
+ # This generates the HTML for the pagination item using a button tag
11
+ #
12
+ # @!attribute [r] form
13
+ # @return [ActionView::Helpers::FormBuilder] Form builder used to create the button
25
14
 
26
- def initialize(form:, **options)
27
- super(**options)
15
+ class Form < Item
16
+ private
28
17
 
29
- @options[:attributes][:class] << ' pagination-number--button_as_link'
18
+ attr_reader :form
30
19
 
31
- @form = form
32
- end
20
+ public
33
21
 
34
- # Generates the HTML for the GOV.UK Pagination item button
35
- #
36
- # @return [ActiveSupport::SafeBuffer]
22
+ # @param (see CCS::Components::GovUK::Pagination::Item)
23
+ # @param form [ActionView::Helpers::FormBuilder] form builder used to create the button
24
+ #
25
+ # @option (see CCS::Components::GovUK::Pagination::Item)
26
+
27
+ def initialize(form:, **options)
28
+ super(**options)
29
+
30
+ @options[:attributes][:class] << ' pagination-number--button_as_link'
31
+
32
+ @form = form
33
+ end
34
+
35
+ # Generates the HTML for the GOV.UK Pagination item button
36
+ #
37
+ # @return [ActiveSupport::SafeBuffer]
37
38
 
38
- def render
39
- super() do
40
- form.button(number, **@options[:attributes])
39
+ def render
40
+ super() do
41
+ form.button(number, **@options[:attributes])
42
+ end
41
43
  end
42
44
  end
43
45
  end