govuk_publishing_components 37.9.1 → 38.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +29 -15
  3. data/app/assets/config/govuk_publishing_components_sassc-rails_manifest.js +0 -1
  4. data/app/assets/images/govuk_publishing_components/crests/hmrc_crest_13px.png +0 -0
  5. data/app/assets/images/govuk_publishing_components/crests/hmrc_crest_13px_x2.png +0 -0
  6. data/app/assets/images/govuk_publishing_components/crests/hmrc_crest_18px.png +0 -0
  7. data/app/assets/images/govuk_publishing_components/crests/hmrc_crest_18px_x2.png +0 -0
  8. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-page-views.js +2 -1
  9. data/app/assets/javascripts/govuk_publishing_components/components/layout-super-navigation-header.js +3 -3
  10. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +0 -1
  11. data/app/models/govuk_publishing_components/component_docs.rb +1 -3
  12. data/app/views/govuk_publishing_components/components/_govspeak.html.erb +0 -11
  13. data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +12 -1
  14. data/app/views/govuk_publishing_components/components/_notice.html.erb +1 -14
  15. data/app/views/govuk_publishing_components/components/_warning_text.html.erb +1 -10
  16. data/app/views/govuk_publishing_components/components/docs/contextual_footer.yml +6 -12
  17. data/app/views/govuk_publishing_components/components/docs/govspeak.yml +0 -9
  18. data/app/views/govuk_publishing_components/components/docs/notice.yml +0 -10
  19. data/app/views/govuk_publishing_components/components/docs/related_navigation.yml +9 -49
  20. data/app/views/govuk_publishing_components/components/docs/warning_text.yml +0 -7
  21. data/config/locales/ar.yml +0 -7
  22. data/config/locales/az.yml +0 -7
  23. data/config/locales/be.yml +0 -7
  24. data/config/locales/bg.yml +0 -7
  25. data/config/locales/bn.yml +0 -7
  26. data/config/locales/cs.yml +0 -7
  27. data/config/locales/cy.yml +0 -7
  28. data/config/locales/da.yml +0 -7
  29. data/config/locales/de.yml +0 -7
  30. data/config/locales/dr.yml +0 -7
  31. data/config/locales/el.yml +0 -7
  32. data/config/locales/en.yml +0 -7
  33. data/config/locales/es-419.yml +0 -7
  34. data/config/locales/es.yml +0 -7
  35. data/config/locales/et.yml +0 -7
  36. data/config/locales/fa.yml +0 -7
  37. data/config/locales/fi.yml +0 -7
  38. data/config/locales/fr.yml +0 -7
  39. data/config/locales/gd.yml +0 -7
  40. data/config/locales/gu.yml +0 -7
  41. data/config/locales/he.yml +0 -7
  42. data/config/locales/hi.yml +0 -7
  43. data/config/locales/hr.yml +0 -7
  44. data/config/locales/hu.yml +0 -7
  45. data/config/locales/hy.yml +0 -7
  46. data/config/locales/id.yml +0 -7
  47. data/config/locales/is.yml +0 -7
  48. data/config/locales/it.yml +0 -7
  49. data/config/locales/ja.yml +0 -7
  50. data/config/locales/ka.yml +0 -7
  51. data/config/locales/kk.yml +0 -7
  52. data/config/locales/ko.yml +0 -7
  53. data/config/locales/lt.yml +0 -7
  54. data/config/locales/lv.yml +0 -7
  55. data/config/locales/ms.yml +0 -7
  56. data/config/locales/mt.yml +0 -7
  57. data/config/locales/nl.yml +0 -7
  58. data/config/locales/no.yml +0 -7
  59. data/config/locales/pa-pk.yml +0 -7
  60. data/config/locales/pa.yml +0 -7
  61. data/config/locales/pl.yml +0 -7
  62. data/config/locales/ps.yml +0 -7
  63. data/config/locales/pt.yml +0 -7
  64. data/config/locales/ro.yml +0 -7
  65. data/config/locales/ru.yml +0 -7
  66. data/config/locales/si.yml +0 -7
  67. data/config/locales/sk.yml +0 -7
  68. data/config/locales/sl.yml +0 -7
  69. data/config/locales/so.yml +0 -7
  70. data/config/locales/sq.yml +0 -7
  71. data/config/locales/sr.yml +0 -7
  72. data/config/locales/sv.yml +0 -7
  73. data/config/locales/sw.yml +0 -7
  74. data/config/locales/ta.yml +0 -7
  75. data/config/locales/th.yml +0 -7
  76. data/config/locales/tk.yml +0 -7
  77. data/config/locales/tr.yml +0 -7
  78. data/config/locales/uk.yml +0 -7
  79. data/config/locales/ur.yml +0 -7
  80. data/config/locales/uz.yml +0 -7
  81. data/config/locales/vi.yml +0 -7
  82. data/config/locales/zh-hk.yml +0 -7
  83. data/config/locales/zh-tw.yml +0 -7
  84. data/config/locales/zh.yml +0 -7
  85. data/lib/govuk_publishing_components/presenters/breadcrumb_selector.rb +0 -5
  86. data/lib/govuk_publishing_components/presenters/component_wrapper_helper.rb +1 -1
  87. data/lib/govuk_publishing_components/presenters/content_item.rb +0 -4
  88. data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +0 -8
  89. data/lib/govuk_publishing_components/presenters/intervention_helper.rb +6 -4
  90. data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +6 -20
  91. data/lib/govuk_publishing_components/version.rb +1 -1
  92. data/lib/govuk_publishing_components.rb +0 -1
  93. metadata +3 -8
  94. data/app/assets/javascripts/govuk_publishing_components/components/show-password.js +0 -82
  95. data/app/assets/stylesheets/govuk_publishing_components/components/_show-password.scss +0 -70
  96. data/app/views/govuk_publishing_components/components/_show_password.html.erb +0 -46
  97. data/app/views/govuk_publishing_components/components/docs/show_password.yml +0 -91
  98. data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_topic.rb +0 -38
@@ -179,13 +179,6 @@ tr:
179
179
  share_links:
180
180
  all_opens_in_new_tab:
181
181
  opens_in_new_tab:
182
- show_password:
183
- announce_hide: Şifreniz gizli
184
- announce_show: Şifreniz gösteriliyor
185
- hide: Gizle
186
- hide_password: Şifreyi gizle
187
- show: Göster
188
- show_password: Şifreyi göster
189
182
  single_page_notification_button:
190
183
  subscribe_text:
191
184
  unsubscribe_text:
@@ -185,13 +185,6 @@ uk:
185
185
  share_links:
186
186
  all_opens_in_new_tab:
187
187
  opens_in_new_tab:
188
- show_password:
189
- announce_hide: Ваш пароль приховано
190
- announce_show: Ваш пароль показано
191
- hide: Приховати
192
- hide_password: Приховати пароль
193
- show: Показати
194
- show_password: Показати пароль
195
188
  single_page_notification_button:
196
189
  subscribe_text:
197
190
  unsubscribe_text:
@@ -175,13 +175,6 @@ ur:
175
175
  share_links:
176
176
  all_opens_in_new_tab:
177
177
  opens_in_new_tab:
178
- show_password:
179
- announce_hide: آپ کا پاس ورڈ پوشیدہ ہے
180
- announce_show: آپ کا پاس ورڈ دکھائی دے رہا ہے
181
- hide: پوشیدہ کریں
182
- hide_password: پاس ورڈ کو پوشیدہ کریں
183
- show: دکھائیں
184
- show_password: پاس ورڈ دکھائیں
185
178
  single_page_notification_button:
186
179
  subscribe_text:
187
180
  unsubscribe_text:
@@ -180,13 +180,6 @@ uz:
180
180
  share_links:
181
181
  all_opens_in_new_tab:
182
182
  opens_in_new_tab:
183
- show_password:
184
- announce_hide: Сизнинг пароль яширилган
185
- announce_show: Сизнинг пароль акс эттирилган
186
- hide: Яшириш
187
- hide_password: Парольни яшириш
188
- show: Кўрсатиш
189
- show_password: Парольни кўрсатиш
190
183
  single_page_notification_button:
191
184
  subscribe_text:
192
185
  unsubscribe_text:
@@ -177,13 +177,6 @@ vi:
177
177
  share_links:
178
178
  all_opens_in_new_tab:
179
179
  opens_in_new_tab:
180
- show_password:
181
- announce_hide: Mật khẩu của bạn bị ẩn
182
- announce_show: Mật khẩu của bạn được hiển thị
183
- hide: Ẩn
184
- hide_password: Ẩn mật khẩu
185
- show: Hiển thị
186
- show_password: Hiển thị mật khẩu
187
180
  single_page_notification_button:
188
181
  subscribe_text:
189
182
  unsubscribe_text:
@@ -176,13 +176,6 @@ zh-hk:
176
176
  share_links:
177
177
  all_opens_in_new_tab:
178
178
  opens_in_new_tab:
179
- show_password:
180
- announce_hide: 您的密碼已隱藏
181
- announce_show: 您的密碼已顯示
182
- hide: 隱藏
183
- hide_password: 隱藏密碼
184
- show: 顯示
185
- show_password: 顯示密碼
186
179
  single_page_notification_button:
187
180
  subscribe_text:
188
181
  unsubscribe_text:
@@ -176,13 +176,6 @@ zh-tw:
176
176
  share_links:
177
177
  all_opens_in_new_tab:
178
178
  opens_in_new_tab:
179
- show_password:
180
- announce_hide: 隱藏你的密碼
181
- announce_show: 顯示你的密碼
182
- hide: 隱藏
183
- hide_password: 隱藏密碼
184
- show: 顯示
185
- show_password: 顯示密碼
186
179
  single_page_notification_button:
187
180
  subscribe_text:
188
181
  unsubscribe_text:
@@ -176,13 +176,6 @@ zh:
176
176
  share_links:
177
177
  all_opens_in_new_tab:
178
178
  opens_in_new_tab:
179
- show_password:
180
- announce_hide: 您的密码已隐藏
181
- announce_show: 您的密码已显示
182
- hide: 隐藏
183
- hide_password: 隐藏密码
184
- show: 显示
185
- show_password: 显示密码
186
179
  single_page_notification_button:
187
180
  subscribe_text:
188
181
  unsubscribe_text:
@@ -55,11 +55,6 @@ module GovukPublishingComponents
55
55
  step_by_step: false,
56
56
  breadcrumbs: navigation.breadcrumbs,
57
57
  }
58
- elsif navigation.content_has_a_topic?
59
- {
60
- step_by_step: false,
61
- breadcrumbs: navigation.topic_breadcrumbs,
62
- }
63
58
  elsif navigation.use_taxon_breadcrumbs?
64
59
  {
65
60
  step_by_step: false,
@@ -60,7 +60,7 @@ module GovukPublishingComponents
60
60
  def check_id_is_valid(id)
61
61
  return if id.blank?
62
62
 
63
- raise(ArgumentError, "Id (#{id}) cannot start with a number or contain whitespace and can only contain letters, digits, `_` and `-`") unless /^[a-zA-Z][\w:-]*$/.match?(id)
63
+ raise(ArgumentError, "Id (#{id}) cannot start with a number or contain whitespace and can only contain letters, digits, `_` and `-`") unless /\A[a-zA-Z][\w:-]*\z/.match?(id)
64
64
  end
65
65
 
66
66
  def check_data_attributes_are_valid(attributes)
@@ -97,10 +97,6 @@ module GovukPublishingComponents
97
97
  filter_link_type(content_store_response.dig("links", "related_statistical_data_sets").to_a, "statistical_data_set")
98
98
  end
99
99
 
100
- def related_topics
101
- filter_link_type(content_store_response.dig("links", "topics").to_a, "topic")
102
- end
103
-
104
100
  def related_topical_events
105
101
  filter_link_type(content_store_response.dig("links", "topical_events").to_a, "topical_event")
106
102
  end
@@ -33,10 +33,6 @@ module GovukPublishingComponents
33
33
  @taxon_breadcrumbs ||= ContentBreadcrumbsBasedOnTaxons.call(content_item)
34
34
  end
35
35
 
36
- def topic_breadcrumbs
37
- @topic_breadcrumbs ||= ContentBreadcrumbsBasedOnTopic.call(content_item)
38
- end
39
-
40
36
  def breadcrumbs
41
37
  breadcrumbs_based_on_ancestors
42
38
  end
@@ -88,10 +84,6 @@ module GovukPublishingComponents
88
84
  content_item["document_type"] == "html_publication"
89
85
  end
90
86
 
91
- def content_has_a_topic?
92
- content_item.dig("links", "topics").present?
93
- end
94
-
95
87
  def content_tagged_to_current_step_by_step?
96
88
  # TODO: remove indirection here
97
89
  step_nav_helper.show_header?
@@ -27,10 +27,12 @@ module GovukPublishingComponents
27
27
  end
28
28
 
29
29
  def security_attr
30
- rel = "noopener noreferrer"
31
- rel << " external" unless @suggestion_link_url.start_with?("/", "https://gov.uk", "https://www.gov.uk")
32
-
33
- rel
30
+ # Link is external unless it begins with "/" (but not "//") or it's on gov.uk.
31
+ if %r{\A(/[^/]|https://(www\.)?gov\.uk(/|\z))}.match?(@suggestion_link_url)
32
+ "noopener noreferrer"
33
+ else
34
+ "noopener noreferrer external"
35
+ end
34
36
  end
35
37
 
36
38
  def show?
@@ -32,7 +32,7 @@ module GovukPublishingComponents
32
32
  }
33
33
  when :footer
34
34
  {
35
- "topics" => related_topics_or_taxons,
35
+ "topics" => related_browse_topics_or_taxons,
36
36
  "topical_events" => related_topical_events,
37
37
  "world_locations" => related_world_locations,
38
38
  "statistical_data_sets" => related_statistical_data_sets,
@@ -44,7 +44,7 @@ module GovukPublishingComponents
44
44
  "related_items" => related_items,
45
45
  "related_guides" => related_guides,
46
46
  "collections" => related_document_collections,
47
- "topics" => related_topics_or_taxons,
47
+ "topics" => related_browse_topics_or_taxons,
48
48
  "topical_events" => related_topical_events,
49
49
  "world_locations" => related_world_locations,
50
50
  "statistical_data_sets" => related_statistical_data_sets,
@@ -142,26 +142,12 @@ module GovukPublishingComponents
142
142
  @related_taxons ||= content_item_links_for("taxons", only: "taxon")
143
143
  end
144
144
 
145
- def related_topics_or_taxons
146
- return related_topics if related_topics.any?
147
- return related_taxons if related_taxons.any?
148
-
149
- []
145
+ def related_browse_topics_or_taxons
146
+ related_browse_topics.presence || related_taxons.presence || []
150
147
  end
151
148
 
152
- def related_topics
153
- @related_topics ||= begin
154
- mainstream_browse_page_links = content_item_links_for("mainstream_browse_pages", only: "mainstream_browse_page")
155
- topic_links = content_item_links_for("topics", only: "topic")
156
-
157
- return topic_links if topic_links.present? && mainstream_browse_page_links.empty?
158
-
159
- mainstream_browse_page_links + topic_links.find_all do |topic_link|
160
- mainstream_browse_page_links.none? do |mainstream_browse_page_link|
161
- mainstream_browse_page_link[:text] == topic_link[:text]
162
- end
163
- end
164
- end
149
+ def related_browse_topics
150
+ @related_browse_topics ||= content_item_links_for("mainstream_browse_pages", only: "mainstream_browse_page")
165
151
  end
166
152
 
167
153
  def related_topical_events
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "37.9.1".freeze
2
+ VERSION = "38.0.0".freeze
3
3
  end
@@ -24,7 +24,6 @@ require "govuk_publishing_components/presenters/page_with_step_by_step_navigatio
24
24
  require "govuk_publishing_components/presenters/public_layout_helper"
25
25
  require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_ancestors"
26
26
  require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons"
27
- require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_topic"
28
27
  require "govuk_publishing_components/presenters/checkboxes_helper"
29
28
  require "govuk_publishing_components/presenters/select_helper"
30
29
  require "govuk_publishing_components/presenters/meta_tags"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 37.9.1
4
+ version: 38.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-21 00:00:00.000000000 Z
11
+ date: 2024-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -511,7 +511,6 @@ files:
511
511
  - app/assets/javascripts/govuk_publishing_components/components/print-link.js
512
512
  - app/assets/javascripts/govuk_publishing_components/components/radio.js
513
513
  - app/assets/javascripts/govuk_publishing_components/components/reorderable-list.js
514
- - app/assets/javascripts/govuk_publishing_components/components/show-password.js
515
514
  - app/assets/javascripts/govuk_publishing_components/components/single-page-notification-button.js
516
515
  - app/assets/javascripts/govuk_publishing_components/components/skip-link.js
517
516
  - app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js
@@ -608,7 +607,6 @@ files:
608
607
  - app/assets/stylesheets/govuk_publishing_components/components/_search.scss
609
608
  - app/assets/stylesheets/govuk_publishing_components/components/_select.scss
610
609
  - app/assets/stylesheets/govuk_publishing_components/components/_share-links.scss
611
- - app/assets/stylesheets/govuk_publishing_components/components/_show-password.scss
612
610
  - app/assets/stylesheets/govuk_publishing_components/components/_signup-link.scss
613
611
  - app/assets/stylesheets/govuk_publishing_components/components/_single-page-notification-button.scss
614
612
  - app/assets/stylesheets/govuk_publishing_components/components/_skip-link.scss
@@ -748,7 +746,6 @@ files:
748
746
  - app/views/govuk_publishing_components/components/_search.html.erb
749
747
  - app/views/govuk_publishing_components/components/_select.html.erb
750
748
  - app/views/govuk_publishing_components/components/_share_links.html.erb
751
- - app/views/govuk_publishing_components/components/_show_password.html.erb
752
749
  - app/views/govuk_publishing_components/components/_signup_link.html.erb
753
750
  - app/views/govuk_publishing_components/components/_single_page_notification_button.html.erb
754
751
  - app/views/govuk_publishing_components/components/_skip_link.html.erb
@@ -836,7 +833,6 @@ files:
836
833
  - app/views/govuk_publishing_components/components/docs/search.yml
837
834
  - app/views/govuk_publishing_components/components/docs/select.yml
838
835
  - app/views/govuk_publishing_components/components/docs/share_links.yml
839
- - app/views/govuk_publishing_components/components/docs/show_password.yml
840
836
  - app/views/govuk_publishing_components/components/docs/signup_link.yml
841
837
  - app/views/govuk_publishing_components/components/docs/single_page_notification_button.yml
842
838
  - app/views/govuk_publishing_components/components/docs/skip_link.yml
@@ -957,7 +953,6 @@ files:
957
953
  - lib/govuk_publishing_components/presenters/component_wrapper_helper.rb
958
954
  - lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_ancestors.rb
959
955
  - lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons.rb
960
- - lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_topic.rb
961
956
  - lib/govuk_publishing_components/presenters/content_item.rb
962
957
  - lib/govuk_publishing_components/presenters/contents_list_helper.rb
963
958
  - lib/govuk_publishing_components/presenters/contextual_navigation.rb
@@ -1640,7 +1635,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1640
1635
  - !ruby/object:Gem::Version
1641
1636
  version: '0'
1642
1637
  requirements: []
1643
- rubygems_version: 3.5.6
1638
+ rubygems_version: 3.5.7
1644
1639
  signing_key:
1645
1640
  specification_version: 4
1646
1641
  summary: A gem to document components in GOV.UK frontend applications
@@ -1,82 +0,0 @@
1
- window.GOVUK = window.GOVUK || {}
2
- window.GOVUK.Modules = window.GOVUK.Modules || {};
3
-
4
- (function (Modules) {
5
- function ShowPassword ($module) {
6
- this.$module = $module
7
- this.input = this.$module.querySelector('.gem-c-input')
8
- }
9
-
10
- ShowPassword.prototype.init = function () {
11
- this.$module.togglePassword = this.togglePassword.bind(this)
12
- this.$module.revertToPasswordOnFormSubmit = this.revertToPasswordOnFormSubmit.bind(this)
13
- this.input.classList.add('gem-c-input--with-password')
14
-
15
- this.showPasswordText = this.$module.getAttribute('data-show-text')
16
- this.hidePasswordText = this.$module.getAttribute('data-hide-text')
17
- this.showPasswordFullText = this.$module.getAttribute('data-show-full-text')
18
- this.hidePasswordFullText = this.$module.getAttribute('data-hide-full-text')
19
- this.shownPassword = this.$module.getAttribute('data-announce-show')
20
- this.hiddenPassword = this.$module.getAttribute('data-announce-hide')
21
-
22
- // wrap the input in a new div
23
- this.wrapper = document.createElement('div')
24
- this.wrapper.classList.add('gem-c-show-password__input-wrapper')
25
- this.input.parentNode.insertBefore(this.wrapper, this.input)
26
- this.wrapper.appendChild(this.input)
27
-
28
- // create and append the button
29
- this.showHide = document.createElement('button')
30
- this.showHide.className = 'gem-c-show-password__toggle'
31
- this.showHide.setAttribute('aria-controls', this.input.getAttribute('id'))
32
- this.showHide.setAttribute('type', 'button')
33
- this.showHide.setAttribute('aria-label', this.showPasswordFullText)
34
- this.showHide.innerHTML = this.showPasswordText
35
- this.wrapper.insertBefore(this.showHide, this.input.nextSibling)
36
-
37
- // create and append the status text for screen readers
38
- this.statusText = document.createElement('span')
39
- this.statusText.classList.add('govuk-visually-hidden')
40
- this.statusText.innerHTML = this.hiddenPassword
41
- this.statusText.setAttribute('aria-live', 'polite')
42
- this.wrapper.insertBefore(this.statusText, this.showHide.nextSibling)
43
-
44
- this.showHide.addEventListener('click', this.$module.togglePassword)
45
- this.moveDataAttributesToButton()
46
-
47
- this.parentForm = this.input.form
48
- var disableFormSubmitCheck = this.$module.getAttribute('data-disable-form-submit-check')
49
-
50
- if (this.parentForm && !disableFormSubmitCheck) {
51
- this.parentForm.addEventListener('submit', this.$module.revertToPasswordOnFormSubmit)
52
- }
53
- }
54
-
55
- ShowPassword.prototype.togglePassword = function (event) {
56
- event.preventDefault()
57
- this.showHide.innerHTML = this.showHide.innerHTML === this.showPasswordText ? this.hidePasswordText : this.showPasswordText
58
- this.showHide.setAttribute('aria-label', this.showHide.getAttribute('aria-label') === this.showPasswordFullText ? this.hidePasswordFullText : this.showPasswordFullText)
59
- this.statusText.innerHTML = this.statusText.innerHTML === this.shownPassword ? this.hiddenPassword : this.shownPassword
60
- this.input.setAttribute('type', this.input.getAttribute('type') === 'text' ? 'password' : 'text')
61
- }
62
-
63
- ShowPassword.prototype.revertToPasswordOnFormSubmit = function (event) {
64
- this.showHide.innerHTML = this.showPasswordText
65
- this.showHide.setAttribute('aria-label', this.showPasswordFullText)
66
- this.statusText.innerHTML = this.hiddenPassword
67
- this.input.setAttribute('type', 'password')
68
- }
69
-
70
- ShowPassword.prototype.moveDataAttributesToButton = function () {
71
- var attrs = this.input.attributes
72
- for (var i = attrs.length; i >= 0; i--) {
73
- var attr = attrs[i]
74
- if (attr && /^data-button/.test(attr.name)) {
75
- this.showHide.setAttribute(attr.name.replace('-button', ''), attr.value)
76
- this.input.removeAttribute(attr.name)
77
- }
78
- }
79
- }
80
-
81
- Modules.ShowPassword = ShowPassword
82
- })(window.GOVUK.Modules)
@@ -1,70 +0,0 @@
1
- @import "govuk_publishing_components/individual_component_support";
2
-
3
- .gem-c-show-password__input-wrapper {
4
- display: table; // IE fallback
5
- display: flex;
6
- width: 100%;
7
- flex-direction: column;
8
-
9
- @include govuk-media-query($from: mobile) {
10
- flex-direction: row;
11
- }
12
-
13
- .gem-c-input--with-password {
14
- display: table-cell;
15
-
16
- &:focus {
17
- z-index: 1;
18
- }
19
-
20
- &::-ms-reveal {
21
- display: none;
22
- }
23
- }
24
- }
25
-
26
- .gem-c-show-password__toggle {
27
- @include govuk-font(19);
28
- z-index: 0;
29
- display: table-cell; // IE fallback
30
- padding: govuk-spacing(1) govuk-spacing(3);
31
- min-width: 5em; // stops the button width jumping when the text changes
32
- color: $govuk-link-colour;
33
- text-decoration: underline;
34
- background: govuk-colour("white");
35
- border: solid 2px $govuk-input-border-colour;
36
- white-space: nowrap;
37
- cursor: pointer;
38
-
39
- @include govuk-media-query($until: mobile) {
40
- padding: govuk-spacing(1);
41
- width: 100%;
42
- margin-top: -2px;
43
- white-space: normal;
44
- }
45
-
46
- @include govuk-media-query($from: mobile) {
47
- margin-left: -2px;
48
- margin-top: 0;
49
- margin-bottom: 0;
50
- }
51
-
52
- &:hover {
53
- color: $govuk-link-hover-colour;
54
- @include govuk-link-hover-decoration;
55
- }
56
-
57
- &:focus {
58
- z-index: 1;
59
- background: $govuk-focus-colour;
60
- color: $govuk-focus-text-colour;
61
- outline: 0;
62
- }
63
-
64
- &:active {
65
- z-index: 1;
66
- background: govuk-colour("white");
67
- border-color: $govuk-focus-colour;
68
- color: $govuk-link-active-colour;
69
- }
70
- }
@@ -1,46 +0,0 @@
1
- <%
2
- add_gem_component_stylesheet("show-password")
3
-
4
- disable_form_submit_check ||= false
5
- label ||= nil
6
- value ||= nil
7
- id ||= nil
8
- name ||= nil
9
- autocomplete = "off" unless ['new-password', 'current-password'].include?(autocomplete)
10
- describedby ||= nil
11
- hint ||= nil
12
- error_message ||= nil
13
- error_items ||= nil
14
- data ||= nil
15
-
16
- if !label
17
- raise ArgumentError, "This component requires a label"
18
- end
19
- %>
20
- <% if label %>
21
- <%= tag.div class: "gem-c-show-password",
22
- data: {
23
- module: "show-password",
24
- disable_form_submit_check: disable_form_submit_check,
25
- show_text: t('components.show_password.show'),
26
- hide_text: t('components.show_password.hide'),
27
- show_full_text: t('components.show_password.show_password'),
28
- hide_full_text: t('components.show_password.hide_password'),
29
- announce_show: t('components.show_password.announce_show'),
30
- announce_hide: t('components.show_password.announce_hide')
31
- } do %>
32
- <%= render "govuk_publishing_components/components/input", {
33
- label: label,
34
- value: value,
35
- id: id,
36
- name: name,
37
- describedby: describedby,
38
- hint: hint,
39
- error_message: error_message,
40
- error_items: error_items,
41
- type: "password",
42
- autocomplete: autocomplete,
43
- data: data,
44
- } %>
45
- <% end %>
46
- <% end %>
@@ -1,91 +0,0 @@
1
- name: Show password input (experimental)
2
- description: A password input field that allows the password to be shown.
3
- body: |
4
- Adds a password reveal button to an input that toggles its type from password to text, revealing the password. Does not appear if JavaScript is disabled.
5
-
6
- Uses a visually hidden bit of text to inform screen reader users of the state of the input rather than announcing the content of the password input when toggled.
7
-
8
- This component is currently experimental. If you are using it, please feed back any research findings to the Accounts team.
9
- accessibility_criteria: |
10
- The component must:
11
-
12
- * indicate to the user that the password has been shown or hidden
13
-
14
- Inputs in the component must:
15
-
16
- * accept focus
17
- * be focusable with a keyboard
18
- * be usable with a keyboard
19
- * be usable with touch
20
- * indicate when they have focus
21
- * be recognisable as form input elements
22
- * have correctly associated labels
23
- * be of the appropriate type for their use, e.g. password inputs should be of type 'password'
24
-
25
- Buttons in the component must:
26
-
27
- - accept focus
28
- - be focusable with a keyboard
29
- - indicate when it has focus
30
- - activate when focused and space is pressed
31
- - activate when focused and enter is pressed
32
- govuk_frontend_components:
33
- - text-input
34
- examples:
35
- default:
36
- data:
37
- label:
38
- text: Please enter your password
39
- value: this is my password
40
- disable_form_submit_check:
41
- description: The component sets the `autocomplete` attribute on the input to `off` so that browsers don't remember the password. This isn't reliable, so the component reverts the input type back to a password when its parent form is submitted. If this is causing conflicts with other JavaScript on your form, you can set `disable-form-submit-check` to `true` to disable this functionality and implement it yourself.
42
- data:
43
- label:
44
- text: Please enter your password
45
- value: this is my password
46
- disable_form_submit_check: true
47
- set_autocomplete_attribute:
48
- description: By default, `autocomplete` is set to `off`. This can be set to `new-password` or `current-password` to help browsers differentiate between new and current passwords.
49
- data:
50
- label:
51
- text: Please enter your password
52
- autocomplete: "current-password"
53
- value: this is my password
54
- with_attributes:
55
- description: The component accepts many but not all of the options that can be passed to a regular input, including `id`, `name` and `describedby` (not shown).
56
- data:
57
- label:
58
- text: Please enter your password
59
- value: this is my password
60
- id: custom_id
61
- name: custom_name
62
- with_hint:
63
- data:
64
- label:
65
- text: Please enter your password
66
- value: this is my password
67
- hint: Your password must be at least twelve thousand characters
68
- with_error:
69
- data:
70
- label:
71
- text: Please enter your password
72
- value: this is my password
73
- error_message: No it isn't
74
- with_error_items:
75
- data:
76
- label:
77
- text: Please enter your password
78
- value: this is my password
79
- error_items:
80
- - text: Look I keep telling you
81
- - text: This isn't your password
82
- with_data_attributes:
83
- description: Data attributes can be passed to add to the input element. If the data attribute starts with `data-button-` this attribute will be applied to the show/hide button, instead of the input. Note that if JavaScript disabled, all attributes are added to the input.
84
- data:
85
- label:
86
- text: Your password
87
- data:
88
- example_1: value
89
- example_2: thing
90
- button_example_1: wotsit
91
- button_example_2: doodad
@@ -1,38 +0,0 @@
1
- module GovukPublishingComponents
2
- module Presenters
3
- class ContentBreadcrumbsBasedOnTopic
4
- def self.call(content_item)
5
- new(content_item).breadcrumbs
6
- end
7
-
8
- attr_reader :content_item
9
-
10
- def initialize(content_item)
11
- @content_item = content_item
12
- end
13
-
14
- def breadcrumbs
15
- breadcrumbs = [{ title: "Home", url: "/" }]
16
- return breadcrumbs unless topics.present?
17
-
18
- breadcrumbs << topic_breadcrumb
19
- breadcrumbs
20
- end
21
-
22
- def topic_breadcrumb
23
- {
24
- title: first_topic["title"],
25
- url: first_topic["base_path"],
26
- }
27
- end
28
-
29
- def first_topic
30
- topics.first
31
- end
32
-
33
- def topics
34
- @topics ||= content_item.dig("links", "topics")
35
- end
36
- end
37
- end
38
- end