From 221dbb196eed5894be78b86ec13c9fadd892a4fd Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Wed, 1 Jan 2025 14:56:29 +0100 Subject: [PATCH] Improve form style --- .pre-commit-config.yaml | 2 +- nummi/main/static/main/css/form.css | 67 ++++++++++++++----- nummi/main/templates/main/form/form_base.html | 58 ++++++---------- nummi/transaction/forms.py | 3 + .../transaction/forms/widgets/datalist.html | 9 +-- 5 files changed, 77 insertions(+), 62 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 68993c2..b84af83 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: rev: v1.23.3 hooks: - id: djlint-django - args: ["--reformat"] + args: ["--reformat", "--lint", "--quiet"] - repo: https://github.com/pre-commit/mirrors-prettier rev: "v3.0.0-alpha.6" hooks: diff --git a/nummi/main/static/main/css/form.css b/nummi/main/static/main/css/form.css index 470220a..066ce9b 100644 --- a/nummi/main/static/main/css/form.css +++ b/nummi/main/static/main/css/form.css @@ -6,23 +6,43 @@ form ul.errorlist { } form { - > table > tbody > tr > th { - background: var(--bg-01); - border-right: 1px solid var(--gray); - } - tbody :is(input, select, textarea) { - font: inherit; - border: none; - background: transparent; - width: 100%; - height: 100%; - line-height: 1.5; - } - input[type="checkbox"] { - width: initial; - } - tfoot { - text-align: right; + max-width: 32rem; + display: grid; + grid-gap: var(--gap); + + p.field { + display: grid; + grid-auto-rows: min-content; + border: 1px solid var(--gray); + padding: 0.5rem; + margin: 0; + + &:has(> input, > select, > textarea) > label { + font-size: 0.8rem; + line-height: 0.8rem; + z-index: 10; + } + + > input, + > select, + > textarea { + font: inherit; + line-height: initial; + border: none; + border-bottom: 1px solid var(--gray); + background: none; + z-index: 1; + + &[name="value"] { + font-size: 1.5rem; + text-align: right; + } + + &:focus { + outline: none; + background: var(--bg-01); + } + } } } table.file-input { @@ -42,10 +62,18 @@ table.file-input { } .buttons { + display: grid; + grid-auto-columns: min-content; + grid-gap: var(--gap); + align-items: baseline; + + & > * { + grid-row: 1; + } + input { font: inherit; line-height: 1.5; - margin-left: var(--gap); border-radius: var(--radius); padding: 0 var(--gap); cursor: pointer; @@ -56,13 +84,16 @@ table.file-input { &[type="submit"] { border: 0.1rem solid var(--green); background: var(--green-1); + grid-column: 1; } &[type="reset"] { border: 0.1rem solid var(--red); background: var(--red-1); + grid-column: 2; } } a.del { color: var(--red); + grid-column: 3; } } diff --git a/nummi/main/templates/main/form/form_base.html b/nummi/main/templates/main/form/form_base.html index d206bbd..8ac1839 100644 --- a/nummi/main/templates/main/form/form_base.html +++ b/nummi/main/templates/main/form/form_base.html @@ -2,42 +2,28 @@ {% load main_extras %} {% block fields %} {% if form.non_field_errors %} -