mirror of
https://github.com/mwisnowski/mtg_python_deckbuilder.git
synced 2025-12-17 08:00:13 +01:00
web: DRY Step 5 and alternatives (partial+macro), centralize start_ctx/owned_set, adopt builder_*
This commit is contained in:
parent
fe9aabbce9
commit
014bcc37b7
24 changed files with 1200 additions and 766 deletions
13
code/web/templates/partials/_macros.html
Normal file
13
code/web/templates/partials/_macros.html
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{# Reusable Jinja macros for UI elements #}
|
||||
|
||||
{% macro lock_button(name, locked=False, from_list=False, target_selector='closest .lock-box') -%}
|
||||
{# Emits a lock/unlock button with correct hx-vals and aria state. #}
|
||||
<button type="button" class="btn-lock"
|
||||
title="{{ 'Unlock this card (kept across reruns)' if locked else 'Lock this card (keep across reruns)' }}"
|
||||
aria-pressed="{{ 'true' if locked else 'false' }}"
|
||||
data-locked="{{ '1' if locked else '0' }}"
|
||||
hx-post="/build/lock" hx-target="{{ target_selector }}" hx-swap="innerHTML"
|
||||
hx-vals='{"name": "{{ name }}", "locked": "{{ '0' if locked else '1' }}"{% if from_list %}, "from_list": "1"{% endif %}}'>
|
||||
{{ '🔒 Unlock' if locked else '🔓 Lock' }}
|
||||
</button>
|
||||
{%- endmacro %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue