From 83c634c2b9c574f6a30d7357f167551804c7507b Mon Sep 17 00:00:00 2001 From: efim Date: Sun, 5 Nov 2023 04:14:36 +0000 Subject: [PATCH] feat: disabling auth submit on empty names https://htmx.org/attributes/hx-validate/ for 'non form submittions' to trigger validation custom check, because 'required' marks fields red immediately and this js does only on attempted submittion, not sure i want it, but seems better right now. also - such a good argument for hyperscript --- routes/static/out.css | 5 +++ routes/templates/login.gohtml | 68 ++++++++++++++++++++++++++++++----- 2 files changed, 65 insertions(+), 8 deletions(-) diff --git a/routes/static/out.css b/routes/static/out.css index 50b85fe..3f5d1b9 100644 --- a/routes/static/out.css +++ b/routes/static/out.css @@ -612,3 +612,8 @@ video { font-size: 1.25rem; line-height: 1.75rem; } + +.invalid\:bg-red-700:invalid { + --tw-bg-opacity: 1; + background-color: rgb(185 28 28 / var(--tw-bg-opacity)); +} diff --git a/routes/templates/login.gohtml b/routes/templates/login.gohtml index 7ca604a..209e2fe 100644 --- a/routes/templates/login.gohtml +++ b/routes/templates/login.gohtml @@ -49,6 +49,7 @@ hx-post="/login/room-name-check" hx-target="#formButton" hx-swap="outerHTML" + class="invalid:bg-red-700" /> - {{ block "formButton" .IsRoomExisting }} - {{ if not . }} - + {{ block "formButton" .IsRoomExisting }} {{ if not . }} + {{ else }} - - {{ end }} - {{ end }} + + {{ end }} {{ end }}