Skip to content

Commit

Permalink
Address some points raised in review
Browse files Browse the repository at this point in the history
* the i18n data attributes should really be used for localisation,
  they're now Italian (thanks @edujackedu!)
* the official component is called 'password input' rather than
  'password field'. I've changed this around in the guide but
  left the actual code as #govuk_password_field so it's consistent
  with Rails' other form helpers
* renamed the example attributes from PIN and secret code to password_1,
  password_2, password_3. They need to be unique and not encourage
  people to use this component for things other than passwords
  • Loading branch information
peteryates committed Mar 27, 2024
1 parent d316ce7 commit 3bed57a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Password fields
title: Password input
---

markdown:
Expand All @@ -8,17 +8,17 @@ markdown:
Use this component whenever you need users to create or enter a password.

== render('/partials/example.*',
caption: 'A default password field',
caption: 'A default password input',
code: default_password)

== render('/partials/example.*',
caption: 'A password field with a custom label, caption and hint',
caption: 'A password input with a custom label, caption and hint',
code: password_with_a_captioned_heading_label_and_hint) do
markdown:
The password field's title, caption and hint can be customised in the usual way.
The password input's title, caption and hint can be customised in the usual way.

== render('/partials/example.*',
caption: 'Password field with custom text',
caption: 'Password input with custom text',
code: password_with_custom_text) do
markdown:
The component's text can be customised or localised by providing the following arguments:
Expand Down
22 changes: 11 additions & 11 deletions guide/lib/examples/password.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@ module Examples
module Password
def default_password
<<~PASSWORD
= f.govuk_password_field :password, label: { text: "Enter your password" }
= f.govuk_password_field :password_1, label: { text: "Password" }
PASSWORD
end

def password_with_a_captioned_heading_label_and_hint
<<~PASSWORD
= f.govuk_password_field(:pin,
label: { text: "Enter your PIN", tag: "h2", size: "l" },
= f.govuk_password_field(:password_2,
label: { text: "Password", tag: "h2", size: "l" },
caption: { text: "Security", size: "m" },
hint: { text: "Your PIN was emailed to you when you registered for this service" })
PASSWORD
end

def password_with_custom_text
<<~PASSWORD
= f.govuk_password_field(:secret_code,
label: { text: "Enter your secret code" },
show_password_text: "Display",
hide_password_text: "Conceal",
show_password_aria_label_text: "Display the secret code",
hide_password_aria_label_text: "Conceal the secret code",
password_shown_announcement_text: "The secret code has been displayed",
password_hidden_announcement_text: "The secret code has been concealed")
= f.govuk_password_field(:password_3,
label: { text: "Password", tag: "h2", size: "l" },
show_password_text: "Mostra",
hide_password_text: "Nascondi",
show_password_aria_label_text: "Mostra la password",
hide_password_aria_label_text: "Nascondi la password",
password_shown_announcement_text: "La password è visibile",
password_hidden_announcement_text: "La password non è visibile")
PASSWORD
end
end
Expand Down
2 changes: 1 addition & 1 deletion guide/lib/helpers/link_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def navigation_links
"Checkboxes" => "/form-elements/checkboxes/",
"Date input" => "/form-elements/date-input/",
"File upload" => "/form-elements/file-upload/",
"Password fields" => "/form-elements/password/",
"Password input" => "/form-elements/password-input/",
"Radios" => "/form-elements/radios/",
"Select" => "/form-elements/select/",
"Submit button" => "/form-elements/submit/",
Expand Down
6 changes: 3 additions & 3 deletions guide/lib/helpers/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class Person

# password examples
attr_accessor(
:password,
:pin,
:secret_code
:password_1,
:password_2,
:password_3
)

# width examples
Expand Down

0 comments on commit 3bed57a

Please sign in to comment.