Skip to content

Commit

Permalink
🧱template: add reveal password to login template
Browse files Browse the repository at this point in the history
  • Loading branch information
kaufon committed Jun 26, 2024
1 parent 8e8945d commit 41b0631
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/ui/templates/pages/login/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{% extends "layouts/root.html" %}

{% from "components/logo.html" import logo %}

{% block body %}
<body
class="flex items-center justify-center min-h-screen"
Expand All @@ -22,7 +21,7 @@
hx-swap="innerHTML">
<div id="login-form-fields">
{% include "pages/login/login_form.html" %}
</div>
</div>
</form>

</div>
Expand Down
33 changes: 23 additions & 10 deletions src/ui/templates/pages/login/login_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
{% endif %}

{% set input_container_class =
"flex items-center justify-center w-full gap-1 p-3 mt-1 border rounded-lg focus-within:ring-2 focus-within:ring-green-500"
"flex items-center justify-center w-full gap-1 p-3 mt-1 border rounded-lg focus-within:ring-2
focus-within:ring-green-500"
%}

{% set input_class =
Expand All @@ -32,8 +33,7 @@
class="block text-gray-700",
)
}}
<div
class="{{ input_container_class }}">
<div class="{{ input_container_class }}">
<i class="ph-bold ph-user"></i>
{{
login_form.email(
Expand All @@ -51,10 +51,11 @@
class="block text-gray-700",
)
}}
<div
class="{{ input_container_class }}">
<div class="{{ input_container_class }}">
<i class="ph-bold ph-lock"></i>
{{ login_form.password(class=input_class, placeholder="****") }}
{{ login_form.password(class=input_class, placeholder="****",id ="password") }}

<i class="ph-bold ph-eye-closed" id="eyeicon"></i>
</div>
{{ error_messages(login_form.password.errors[0]) }}
</div>
Expand All @@ -65,15 +66,13 @@
</div>

<div class="flex justify-between mb-6">
<a
href="{{ url_for('authentication_views.request_password_reset_page_view') }}"
<a href="{{ url_for('authentication_views.request_password_reset_page_view') }}"
class="text-sm text-green-500 hover:underline">
Esqueceu a senha?
</a>
</div>

<button
type="submit"
<button type="submit"
class="grid place-content-center w-full p-3 text-white bg-green-500 rounded-lg hover:bg-green-600">
<span data-loading-class="hidden">
Login
Expand All @@ -82,3 +81,17 @@
{{ loading("size-6 fill-green-600") }}
</div>
</button>
<script src="{{ url_for('static', filename='scripts/reveal_password.js') }}"></script>
<script>
window.onload = function () {
RevealPassword("password", "eyeicon");
}


document.querySelectorAll('[hx-trigger]').forEach(function(element) {
element.addEventListener('htmx:afterSwap', function(event) {
RevealPassword("password","eyeicon")
});
});

</script>

0 comments on commit 41b0631

Please sign in to comment.