Put icons in the login fields and drop their labels

The entrance forms lose their visible field labels and gain an icon inside each
field (mail, lock), and allauth's "Forgot your password?" link -- which is the
password field's help_text -- is spaced away from the input instead of sitting
flush against it.

Three things this depends on:

- allauth already passes `unlabeled=True` on the entrance forms and already sets
  a placeholder on every field there, so the visible label was redundant. The
  label is still emitted sr-only: a placeholder is not a label, and it vanishes
  as soon as you type.
- daisyUI's icon-in-field layout puts the `input` class on the *wrapping label*,
  so the input itself must carry only `grow` -- hence the optional css override on
  the daisy filter. `input` on both draws a box inside a box, and the error state
  belongs on the wrapper for the same reason.
- The help text now carries id="<auto_id>_helptext". Django points the input's
  aria-describedby at exactly that id, so without it the reference dangled and a
  screen reader never announced the password-reset link.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-13 22:43:44 +02:00
parent e44933330d
commit 7b18b39f49
5 changed files with 4025 additions and 18 deletions

View File

@@ -1,4 +1,16 @@
{% load ui %}
{% load lucide ui %}
{% comment %}
allauth passes `unlabeled=True` on the entrance forms (login, signup, reset) and
already sets a placeholder on each of their fields ("Email address", "Password"),
so dropping the visible label loses nothing on screen. The label is still emitted
sr-only inside the wrapper: a placeholder is not a label, and it disappears the
moment you start typing.
Fields with an icon use daisyUI's icon-in-field layout, where the `input` class
goes on the *wrapping label* and the input itself carries only `grow`. Putting
`input` on both draws a box inside a box.
{% endcomment %}
{% for field in attrs.form.hidden_fields %}{{ field }}{% endfor %}
{% for error in attrs.form.non_field_errors %}
<div class="alert alert-error my-2">
@@ -13,12 +25,30 @@
<span class="label-text">{{ field.label }}</span>
</label>
{% else %}
<label class="label" for="{{ field.id_for_label }}">
<span class="label-text">{{ field.label }}</span>
</label>
{{ field|daisy }}
{% if not attrs.unlabeled %}
<label class="label" for="{{ field.id_for_label }}">
<span class="label-text">{{ field.label }}</span>
</label>
{% endif %}
{% with icon=field|field_icon %}
{% if icon %}
<label class="input flex w-full items-center gap-2 {% if field.errors %}input-error{% endif %}" for="{{ field.id_for_label }}">
<span class="opacity-50">{% lucide icon size=16 %}</span>
{% if attrs.unlabeled %}<span class="sr-only">{{ field.label }}</span>{% endif %}
{{ field|daisy:"grow" }}
</label>
{% else %}
{{ field|daisy }}
{% endif %}
{% endwith %}
{% endif %}
{% if field.help_text %}<span class="label-text-alt mt-1 text-base-content/70">{{ field.help_text }}</span>{% endif %}
{% comment %}
The password field's help_text is allauth's "Forgot your password?" link, so it
gets room to breathe. The id is not decorative: Django points the input's
aria-describedby at `<auto_id>_helptext`, and without it that reference dangles
and the link is never announced.
{% endcomment %}
{% if field.help_text %}<span id="{{ field.auto_id }}_helptext" class="label-text-alt mt-3 block text-base-content/70">{{ field.help_text }}</span>{% endif %}
{% for error in field.errors %}<span class="label-text-alt mt-1 text-error">{{ error }}</span>{% endfor %}
</div>
{% endfor %}

View File

@@ -11,7 +11,7 @@
{% block main %}
<div class="flex justify-center">
<div class="card w-full max-w-xl bg-base-100 shadow">
<div class="card w-full max-w-xl bg-base-100 border-2 border-base-content/20 shadow-xl">
<div class="card-body prose max-w-none">
{% block content %}{% endblock content %}
</div>