feat: add /plants page

This commit is contained in:
Jef Roosens 2025-01-24 21:49:46 +01:00
parent 18499631ea
commit dce23599ef
Signed by: Jef Roosens
GPG key ID: 21FD3D77D56BAF49
4 changed files with 51 additions and 17 deletions

View file

@ -8,9 +8,13 @@
</div>
{% endmacro info %}
{% macro name(plant) %}
<a hx-get="/plants/{{ plant.id }}" hx-target="#content" hx-push-url="true">{{ plant.name }} (<em>{{ plant.species }}</em>)</a>
{% endmacro %}
{% macro li(plant) %}
<li>
<a hx-get="/plants/{{ plant.id }}" hx-target="#content" hx-push-url="true">{{ plant.name }}</a> ({{ plant.species }})
{{ self::name(plant=plant) }}
</li>
{% endmacro li %}
@ -26,16 +30,9 @@
{% macro form(target="#plants > ul") %}
<form hx-post="/plants" hx-target="{{ target }}" hx-swap="beforeend">
<label for="name">Name:</label>
<input type="text" id="name" name="name"></br>
<label for="species">Species:</label>
<input type="text" id="species" name="species"></br>
<label for="description">Description:</label>
<textarea id="description" name="description" rows=4></textarea></br>
<input type="submit">
<input type="text" id="name" name="name" placeholder="My super cool plant"></br>
<input type="text" id="species" name="species" placeholder="Philodendron Candens"></br>
<textarea id="description" name="description" rows=2 placeholder="An additional description"></textarea></br>
<input type="submit" value="Add plant">
</form>
{% endmacro %}
{% macro name(plant) %}
<a hx-get="/plants/{{ plant.id }}" hx-target="#content" hx-push-url="true">{{ plant.name }} (<em>{{ plant.species }}</em>)</a>
{% endmacro %}

View file

@ -0,0 +1,9 @@
{% import "components/plant.html" as comp_plant %}
<h1>Plants</h1>
<ul>
{% for plant in plants %}
{{ comp_plant::li(plant=plant) }}
{% endfor %}
</ul>