feat: prefer errors over button disables

This commit is contained in:
Robert Perce 2026-06-15 06:59:04 -05:00
parent 66a45a2e16
commit 4a9733c432
2 changed files with 7 additions and 8 deletions

View file

@ -93,13 +93,13 @@ mod get {
body hx-ext="response-targets" { body hx-ext="response-targets" {
h1 { "Entretien" } h1 { "Entretien" }
main { main {
form hx-post=(post_url) hx-target-error="#error" x-data=(json!({"user": state.autologin_user, "pass": state.autologin_pass, "htmx": false})) "x-on:htmx:load.document"="htmx = true" hx-trigger=(if state.autologin_pass.is_empty() { "submit" } else { "load" }) { form hx-post=(post_url) hx-target-error="#error" x-data=(json!({"htmx": false})) "x-on:htmx:load.document"="htmx = true" hx-trigger=(if state.autologin_pass.is_empty() { "submit" } else { "load" }) {
label for="username" { "username" } label for="username" { "username" }
input name="username" #username autofocus x-model="user" x-cloak; input name="username" #username autofocus value=(state.autologin_user);
label for="password" { "password" } label for="password" { "password" }
input name="password" #password type="password" x-model="pass" x-cloak; input name="password" #password type="password" value=(state.autologin_pass);
input type="submit" value="login" x-bind:disabled="!(user.length && pass.length && htmx)" hx-disabled-elt; button type="submit" value="login" x-bind:disabled="!htmx" hx-disabled-elt;
#error {} #error {}
} }
#blurb { #blurb {

View file

@ -79,15 +79,14 @@ mod get {
hx-target="#completions" hx-target="#completions"
hx-target-error="find .errors" hx-target-error="find .errors"
hx-on::after-request="console.log(event)" hx-on::after-request="console.log(event)"
hx-swap="afterbegin" hx-swap="afterbegin"
x-data=(json!({ "when": "" }))
{ {
.col { .col {
label for="when" { "when" } label for="when" { "when" }
input id="when" name="datestamp" type="date" x-bind="when"; input id="when" name="datestamp" type="date";
.errors {} .errors {}
} }
button x-bind:disabled="when.length == 0" { "add completion" } button { "add completion" }
} }
#completions { #completions {
@if completions.is_empty() { @if completions.is_empty() {