Skip to content

Commit

Permalink
Merge pull request #136 from wuletawwonte/111-add-show-password-button
Browse files Browse the repository at this point in the history
Add show password button
  • Loading branch information
LuigiR0jas committed Sep 2, 2024
2 parents 0476ae8 + 5ca3cf1 commit 00e18c9
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/assets/images/icons/eye-empty.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions app/assets/images/icons/eye-off.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions app/javascript/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import { application } from 'controllers/application'
// Eager load all controllers defined in the import map under controllers/**/*_controller
import { eagerLoadControllersFrom } from '@hotwired/stimulus-loading'
import Dropdown from '@stimulus-components/dropdown'
import PasswordVisibility from '@stimulus-components/password-visibility'

// Lazy load controllers as they appear in the DOM (remember not to preload controllers in import map!)
// import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading"
// lazyLoadControllersFrom("controllers", application)
eagerLoadControllersFrom('controllers', application)
application.register('dropdown', Dropdown)
application.register('password-visibility', PasswordVisibility)
8 changes: 7 additions & 1 deletion app/views/user_sessions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@

<div class="flex flex-col">
<%= form.label :password, class: "text-white italic font-bold mb-2" %>
<%= form.password_field :password, required: true, placeholder: "Password", data: { test_id: "password_field" } %>
<div class="relative" data-controller="password-visibility">
<%= form.password_field :password, required: true, class: "peer w-full", placeholder: "Password", data: { test_id: "password_field", "password-visibility-target": "input" } %>
<button class="absolute right-3 top-1/2 -translate-y-1/2 text-gray-300 hover:text-white peer-focus:text-gray-400 peer-focus:hover:text-gray-600" type="button" data-action="password-visibility#toggle">
<%= inline_svg_tag("icons/eye-empty.svg", size: "22", data: { "password-visibility-target": "icon" }) %>
<%= inline_svg_tag("icons/eye-off.svg", size: "22", class: "hidden", data: { "password-visibility-target": "icon" }) %>
</button>
</div>
</div>
</div>

Expand Down
1 change: 1 addition & 0 deletions config/importmap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
pin_all_from "app/javascript/custom", under: "custom"
pin "trix"
pin "@rails/actiontext", to: "actiontext.esm.js"
pin "@stimulus-components/password-visibility", to: "@stimulus-components--password-visibility.js" # @3.0.0

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 00e18c9

Please sign in to comment.