diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js index f94d04a..8a6cea9 100644 --- a/app/javascript/controllers/index.js +++ b/app/javascript/controllers/index.js @@ -9,3 +9,6 @@ window.Stimulus = application; // Eager load all controllers defined in the import map under controllers/**/*_controller import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"; eagerLoadControllersFrom("controllers", application); + +import PasswordVisibility from "stimulus-password-visibility"; +application.register('password-visibility', PasswordVisibility) diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index 654b333..b5a133a 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -8,7 +8,20 @@

Welcome back!

<%= form_with(url: sign_in_path) do |f| %> <%= f.text_field :username, value: params[:username_hint], require: true, autofocus: true, autocomplete: "username", class: "input mt-2", placeholder: "Username" %> - <%= f.password_field :password, required: true, autocomplete: "current-password", class: "input mt-2", placeholder: "*****" %> + +
+ <%= f.password_field :password, class: "input mt-2", required: true, autocomplete: "current-password", + placeholder: "*****", spellcheck: false, + data: {"password-visibility-target" => "input"} %> + +
<%= f.submit "Log in", class: "button button-primary mt-2" %> <%= link_to "Sign up", sign_up_path, class: "text-small opacity-50 hover:opacity-100" %> diff --git a/config/importmap.rb b/config/importmap.rb index 446c8cb..b87643a 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -10,3 +10,4 @@ pin "@hotwired/stimulus", to: "https://ga.jspm.io/npm:@hotwired/stimulus@3.2.1/dist/stimulus.js" pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true pin_all_from "app/javascript/controllers", under: "controllers" +pin "stimulus-password-visibility", to: "https://ga.jspm.io/npm:stimulus-password-visibility@2.1.1/dist/stimulus-password-visibility.mjs"