From 98c83916708fbf92e82220e04410ca9e4b6c4df4 Mon Sep 17 00:00:00 2001 From: Jon Seager Date: Wed, 4 Feb 2026 16:01:57 +0000 Subject: [PATCH] refactor(templates): extract shared bag card partial for open bags - Create bag_card.html macro used by both home page and bags page - Replace divergent card styles with consistent amber-themed design - Add closeBag() JS to bags page for closing bags with confirmation - Use "Close" button with cross icon consistently across both pages --- templates/bags.html | 25 +++++++++- templates/home.html | 33 +----------- templates/partials/bag_card.html | 32 ++++++++++++ templates/partials/bag_list.html | 86 ++------------------------------ 4 files changed, 62 insertions(+), 114 deletions(-) create mode 100644 templates/partials/bag_card.html diff --git a/templates/bags.html b/templates/bags.html index c859198..38cb351 100644 --- a/templates/bags.html +++ b/templates/bags.html @@ -1,4 +1,27 @@ -{% extends "base.html" %} {% block title %}Brewlog · Bags{% endblock %} {% block content %} +{% extends "base.html" %} {% block title %}Brewlog · Bags{% endblock %} + +{% block head %} + +{% endblock %} + +{% block content %}
diff --git a/templates/home.html b/templates/home.html index 828c697..aa3c5c0 100644 --- a/templates/home.html +++ b/templates/home.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} {% block title %}Brewlog{% endblock %} +{% extends "base.html" %} {% import "partials/bag_card.html" as bag_card %} {% block title %}Brewlog{% endblock %} {% block head %} {% if is_authenticated %} @@ -276,36 +276,7 @@
{% for bag in open_bags %} -
-
- {{ bag.roast_name }} -

{{ bag.roaster_name }}

-
-

- {{ bag.remaining }}g - of {{ bag.amount }}g remaining -

- {% if is_authenticated %} -
- - - Brew - - -
- {% endif %} -
+ {% call bag_card::card(bag, is_authenticated) %} {% endfor %}
diff --git a/templates/partials/bag_card.html b/templates/partials/bag_card.html new file mode 100644 index 0000000..5be5825 --- /dev/null +++ b/templates/partials/bag_card.html @@ -0,0 +1,32 @@ +{% macro card(bag, is_authenticated) %} +
+
+ {{ bag.roast_name }} +

{{ bag.roaster_name }}

+
+

+ {{ bag.remaining }}g + of {{ bag.amount }}g remaining +

+ {% if is_authenticated %} +
+ + + Brew + + +
+ {% endif %} +
+{% endmacro %} diff --git a/templates/partials/bag_list.html b/templates/partials/bag_list.html index 45af68f..e013b7b 100644 --- a/templates/partials/bag_list.html +++ b/templates/partials/bag_list.html @@ -1,91 +1,13 @@ {% import "partials/table.html" as table %} +{% import "partials/bag_card.html" as bag_card %}
{% if !open_bags.is_empty() %}
-

Open Bags

-
+

Open Bags

+
{% for bag in open_bags %} -
-
- - -
-
- - - - {{ bag.remaining }} / {{ bag.amount }}g -
- -
- - - - {% if let Some(roast_date) = bag.roast_date %} - Roasted {{ roast_date }} - {% else %} - Added {{ bag.created_at }} - {% endif %} -
-
- - {% if is_authenticated %} -
- -
- {% endif %} -
-
+ {% call bag_card::card(bag, is_authenticated) %} {% endfor %}