diff --git a/projects/templates/projects/project_members_invite.html b/projects/templates/projects/project_members_invite.html index 9f0a406..506c7c2 100644 --- a/projects/templates/projects/project_members_invite.html +++ b/projects/templates/projects/project_members_invite.html @@ -1,12 +1,11 @@ {% extends "base.html" %} {% load static %} +{% load tailwind_forms %} {% block title %}Invite Members · {{ project.name }} · {{ site_title }}{% endblock %} {% block content %} - -
@@ -30,16 +29,7 @@ Invite a member to join the project "{{ project.name }}". They will receive an email with a link to join.
-
- - {% if form.email.errors %} - {% for error in form.email.errors %} -
{{ error }}
- {% endfor %} - {% elif form.email.help_text %} -
{{ form.email.help_text|safe }}
- {% endif %} -
+ {% tailwind_formfield form.email %}
{# ml-1 is strictly speaking not aligned, but visually it looks better "to me"; perhaps because of all of the round elements? #}
{{ form.role.label }}
diff --git a/teams/templates/teams/team_members_invite.html b/teams/templates/teams/team_members_invite.html index 705fef3..193ab82 100644 --- a/teams/templates/teams/team_members_invite.html +++ b/teams/templates/teams/team_members_invite.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load static %} +{% load tailwind_forms %} {% block title %}Invite Members · {{ team.name }} · {{ site_title }}{% endblock %} @@ -30,16 +31,7 @@ Invite a member to join the team "{{ team.name }}". They will receive an email with a link to join.
-
- - {% if form.email.errors %} - {% for error in form.email.errors %} -
{{ error }}
- {% endfor %} - {% elif form.email.help_text %} -
{{ form.email.help_text|safe }}
- {% endif %} -
+ {% tailwind_formfield form.email %}
{# ml-1 is strictly speaking not aligned, but visually it looks better "to me"; perhaps because of all of the round elements? #}
{{ form.role.label }}
diff --git a/templates/signup.html b/templates/signup.html index 456a4ba..0dbf9b3 100644 --- a/templates/signup.html +++ b/templates/signup.html @@ -1,5 +1,6 @@ {% extends "barest_base.html" %} {% load static %} +{% load tailwind_forms %} {% block title %}Sign up · {{ site_title }}{% endblock %} @@ -16,38 +17,9 @@
{% csrf_token %} -
- - {% if form.username.errors %} - {% for error in form.username.errors %} -
{{ error }}
- {% endfor %} - {% elif form.username.help_text %} -
{{ form.username.help_text|safe }}
- {% endif %} -
- -
- - {% if form.password1.errors %} - {% for error in form.password1.errors %} -
{{ error }}
- {% endfor %} - {% elif form.password1.help_text %} -
{{ form.password1.help_text|safe }}
- {% endif %} -
- -
- - {% if form.password2.errors %} - {% for error in form.password2.errors %} -
{{ error }}
- {% endfor %} - {% elif form.password2.help_text %} -
{{ form.password2.help_text|safe }}
- {% endif %} -
+ {% tailwind_formfield form.user %} + {% tailwind_formfield form.password1 %} + {% tailwind_formfield form.password2 %} diff --git a/theme/templates/tailwind_forms/formfield.html b/theme/templates/tailwind_forms/formfield.html new file mode 100644 index 0000000..2a62bf9 --- /dev/null +++ b/theme/templates/tailwind_forms/formfield.html @@ -0,0 +1,12 @@ +{% if formfield %} +
+ + {% if formfield.errors %} + {% for error in formfield.errors %} +
{{ error }}
+ {% endfor %} + {% elif formfield.help_text %} +
{{ formfield.help_text|safe }}
+ {% endif %} +
+{% endif %} diff --git a/theme/templatetags/tailwind_forms.py b/theme/templatetags/tailwind_forms.py new file mode 100644 index 0000000..f5f9cb4 --- /dev/null +++ b/theme/templatetags/tailwind_forms.py @@ -0,0 +1,9 @@ +from django import template + + +register = template.Library() + + +@register.inclusion_tag('tailwind_forms/formfield.html') +def tailwind_formfield(formfield): + return {'formfield': formfield} diff --git a/users/templates/users/request_reset_password.html b/users/templates/users/request_reset_password.html index 540ea46..cc2c231 100644 --- a/users/templates/users/request_reset_password.html +++ b/users/templates/users/request_reset_password.html @@ -1,5 +1,6 @@ {% extends "barest_base.html" %} {% load static %} +{% load tailwind_forms %} {% block title %}Resend confirmation · {{ site_title }}{% endblock %} @@ -16,16 +17,7 @@ {% csrf_token %} -
- - {% if form.email.errors %} - {% for error in form.email.errors %} -
{{ error }}
- {% endfor %} - {% elif form.email.help_text %} -
{{ form.email.help_text|safe }}
- {% endif %} -
+ {% tailwind_formfield form.email %}
diff --git a/users/templates/users/resend_confirmation.html b/users/templates/users/resend_confirmation.html index 5299d0f..fc63213 100644 --- a/users/templates/users/resend_confirmation.html +++ b/users/templates/users/resend_confirmation.html @@ -1,5 +1,6 @@ {% extends "barest_base.html" %} {% load static %} +{% load tailwind_forms %} {% block title %}Resend confirmation · {{ site_title }}{% endblock %} @@ -16,16 +17,7 @@
{% csrf_token %} -
- - {% if form.email.errors %} - {% for error in form.email.errors %} -
{{ error }}
- {% endfor %} - {% elif form.email.help_text %} -
{{ form.email.help_text|safe }}
- {% endif %} -
+ {% tailwind_formfield form.email %}
diff --git a/users/templates/users/reset_password.html b/users/templates/users/reset_password.html index 4d91d5e..c837c5a 100644 --- a/users/templates/users/reset_password.html +++ b/users/templates/users/reset_password.html @@ -1,5 +1,6 @@ {% extends "barest_base.html" %} {% load static %} +{% load tailwind_forms %} {% block title %}Reset password · {{ site_title }}{% endblock %} @@ -16,27 +17,8 @@
{% csrf_token %} -
- - {% if form.new_password1.errors %} - {% for error in form.new_password1.errors %} -
{{ error }}
- {% endfor %} - {% elif form.new_password1.help_text %} -
{{ form.new_password1.help_text|safe }}
- {% endif %} -
- -
- - {% if form.new_password2.errors %} - {% for error in form.new_password2.errors %} -
{{ error }}
- {% endfor %} - {% elif form.new_password2.help_text %} -
{{ form.new_password2.help_text|safe }}
- {% endif %} -
+ {% tailwind_formfield form.new_password1 %} + {% tailwind_formfield form.new_password2 %}