From 67bfe97dfe2ce86bb4c0ce6504ed438379f25a6d Mon Sep 17 00:00:00 2001 From: Christian Heller <c.heller@plomlompom.de> Date: Tue, 28 Jan 2025 13:03:28 +0100 Subject: [PATCH] Improve /balance layout. --- templates/balance.tmpl | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/templates/balance.tmpl b/templates/balance.tmpl index 6110654..14878c9 100644 --- a/templates/balance.tmpl +++ b/templates/balance.tmpl @@ -1,28 +1,30 @@ {% extends '_base.tmpl' %} +{% macro tr_money(amt, curr) %} +<tr> +<td class="amt">{{amt}}</td> +<td class="curr">{{curr|truncate(4,true,"â¦")}}</td> +</tr> +{% endmacro %} + + {% macro account_with_children(account, indent) %} <tr class="alternating"> <td class="money"> {% if account.wealth.moneys|length == 1 %} <table> {% for curr, amt in account.wealth.moneys.items() %} - <tr> - <td class="amt">{{amt}}</td> - <td class="curr">{{curr|truncate(4,true,"â¦")}}</td> - </tr> + {{ tr_money(amt, curr) }} {% endfor %} </table> {% else %} <details> <summary> - <table class="summary"> + <table> {% for curr, amt in account.wealth.moneys.items() %} {% if 1 == loop.index %} - <tr> - <td class="amt">{{amt}}</td> - <td class="curr">{{curr|truncate(4,true,"â¦")}}</td> - </tr> + {{ tr_money(amt, curr) }} {% endif %} {% endfor %} </table> @@ -30,17 +32,14 @@ <table> {% for curr, amt in account.wealth.moneys.items() %} {% if 1 < loop.index %} - <tr> - <td class="amt">{{amt}}</td> - <td class="curr">{{curr|truncate(4,true,"â¦")}}</td> - </tr> + {{ tr_money(amt, curr) }} {% endif %} {% endfor %} </table> </details> {% endif %} </td> - <td class="acc">{% for i in range(indent) %} {% endfor %}{% if account.parent %}:{% endif %}{{account.basename}}{% if account.children %}:{% endif %}</td> + <td class="acc"><span class="indent">{% for i in range(indent) %} {% endfor %}</span>{% if account.parent %}:{% endif %}{{account.basename}}{% if account.children %}:{% endif %}</td> </tr> {% for child in account.children %} {{ account_with_children(child, indent=indent+1) }} @@ -50,10 +49,16 @@ {% block css %} {{ macros.css_td_money() }} + +td.money table { float: left; } td.amt { width: 10em; } td.curr { width: 3em; } -table.summary { float: left; } -td.money { padding-right: 1em; } +summary::marker { font-family: monospace; font-size: 1.2em; } +summary { list-style-type: "[â¦]"; } +details[open] > summary { list-style-type: "[^]"; } + +span.indent { letter-spacing: 3em; } + {% endblock css %} {% block content %} -- 2.30.2