Loaders
Some checks failed
Rust / Test (push) Has been cancelled
Rust / Rustfmt (push) Has been cancelled
Rust / Clippy (push) Has been cancelled
Rust / Code coverage (push) Has been cancelled

This commit is contained in:
Alphonse Paix
2025-09-23 23:47:30 +02:00
parent b1e315921e
commit 3153b99d94
7 changed files with 72 additions and 31 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
<div class="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-md mb-4"> <div class="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-md">
<div class="flex items-center"> <div class="flex items-center">
<svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 20 20"> <svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z" clip-rule="evenodd"> <path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z" clip-rule="evenodd">

View File

@@ -1,6 +1,24 @@
@import "tailwindcss"; @import "tailwindcss";
@plugin "@tailwindcss/typography"; @plugin "@tailwindcss/typography";
@layer utilities {
.htmx-indicator {
@apply hidden;
}
.htmx-request .htmx-indicator {
@apply inline-flex items-center ml-2;
}
#load-more .htmx-indicator {
@apply block;
}
.htmx-request .continue-text {
@apply hidden;
}
}
@layer components { @layer components {
.prose-compact { .prose-compact {
@apply prose prose-slate max-w-none; @apply prose prose-slate max-w-none;

View File

@@ -1,4 +1,5 @@
{% extends "base.html" %} {% extends "base.html" %}
{%- import "macros.html" as macros -%}
{% block title %}Login - zero2prod{% endblock %} {% block title %}Login - zero2prod{% endblock %}
{% block content %} {% block content %}
<div class="flex-1 flex items-center justify-center"> <div class="flex-1 flex items-center justify-center">
@@ -28,13 +29,15 @@
required required
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500" /> class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500" />
</div> </div>
<div>
<button type="submit" <button type="submit"
hx-indicator="this"
class="w-full flex justify-center py-3 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors"> class="w-full flex justify-center py-3 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors">
Continue <span class="continue-text">Continue</span>
<span class="htmx-indicator">
{% call macros::spinner(class="text-white", highlight_class="text-gray-500", size=20) %}
</span>
</button> </button>
</div> <div id="login-messages" class="empty:hidden"></div>
<div id="login-messages" class="mt-4"></div>
</form> </form>
</div> </div>
<div class="text-center"> <div class="text-center">

13
templates/macros.html Normal file
View File

@@ -0,0 +1,13 @@
{% macro spinner(class = "text-blue-600", highlight_class = "text-blue-700", size="24") %}
<svg class="{{ class }} animate-spin"
viewBox="0 0 64 64"
fill="none"
xmlns="http://www.w3.org/2000/svg"
width="{{ size }}"
height="{{ size }}">
<path d="M32 3C35.8083 3 39.5794 3.75011 43.0978 5.20749C46.6163 6.66488 49.8132 8.80101 52.5061 11.4939C55.199 14.1868 57.3351 17.3837 58.7925 20.9022C60.2499 24.4206 61 28.1917 61 32C61 35.8083 60.2499 39.5794 58.7925 43.0978C57.3351 46.6163 55.199 49.8132 52.5061 52.5061C49.8132 55.199 46.6163 57.3351 43.0978 58.7925C39.5794 60.2499 35.8083 61 32 61C28.1917 61 24.4206 60.2499 20.9022 58.7925C17.3837 57.3351 14.1868 55.199 11.4939 52.5061C8.801 49.8132 6.66487 46.6163 5.20749 43.0978C3.7501 39.5794 3 35.8083 3 32C3 28.1917 3.75011 24.4206 5.2075 20.9022C6.66489 17.3837 8.80101 14.1868 11.4939 11.4939C14.1868 8.80099 17.3838 6.66487 20.9022 5.20749C24.4206 3.7501 28.1917 3 32 3L32 3Z" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-linejoin="round">
</path>
<path d="M32 3C36.5778 3 41.0906 4.08374 45.1692 6.16256C49.2477 8.24138 52.7762 11.2562 55.466 14.9605C58.1558 18.6647 59.9304 22.9531 60.6448 27.4748C61.3591 31.9965 60.9928 36.6232 59.5759 40.9762" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-linejoin="round" class="{{ highlight_class }}">
</path>
</svg>
{% endmacro %}

View File

@@ -1,4 +1,5 @@
{% extends "base.html" %} {% extends "base.html" %}
{%- import "macros.html" as macros -%}
{% block title %}Posts{% endblock %} {% block title %}Posts{% endblock %}
{% block content %} {% block content %}
<div class="max-w-4xl mx-auto"> <div class="max-w-4xl mx-auto">
@@ -27,12 +28,18 @@
{% endfor %} {% endfor %}
<div id="load-more" class="text-center"> <div id="load-more" class="text-center">
{% if let Some(n) = next_page %} {% if let Some(n) = next_page %}
<div class="flex flex-col items-center space-y-6">
<button hx-get="/posts/load_more?page={{ n }}" <button hx-get="/posts/load_more?page={{ n }}"
hx-target="#load-more" hx-target="#load-more"
hx-swap="outerHTML" hx-swap="outerHTML"
hx-indicator="#indicator"
class="text-center bg-blue-600 text-white hover:bg-blue-700 font-medium py-3 px-6 rounded-md transition-colors"> class="text-center bg-blue-600 text-white hover:bg-blue-700 font-medium py-3 px-6 rounded-md transition-colors">
Load more Load more
</button> </button>
<span id="indicator" class="htmx-indicator">
{% call macros::spinner(class="text-blue-300 w-8 h-8", highlight_class="text-blue-700", size=30) %}
</span>
</div>
{% else %} {% else %}
<p class="text-gray-600">No more posts. Check back later for more!</p> <p class="text-gray-600">No more posts. Check back later for more!</p>
{% endif %} {% endif %}

View File

@@ -1,4 +1,4 @@
<div class="bg-green-50 border border-green-200 text-green-700 px-4 py-3 rounded-md mb-4"> <div class="bg-green-50 border border-green-200 text-green-700 px-4 py-3 rounded-md">
<div class="flex items-center"> <div class="flex items-center">
<svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 20 20"> <svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"> <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd">