hx (work in progress): start with login form

This commit is contained in:
Helmut Merz 2024-07-22 19:48:42 +02:00
parent 3fbe4d8d8b
commit 3cd7ec3706
8 changed files with 54 additions and 1 deletions

View file

@ -0,0 +1 @@
<button type="{{ .type }}" name="{{ .name }}">{{.label}}</button>

View file

@ -0,0 +1,6 @@
{{- $type := .Get "type" | default "button" -}}
{{- $name := .Get "name" | default "submit" -}}
{{- $label := .Get "label" | default (title $name) -}}
{{- $params := dict "type" $type "name" $name "label" $label -}}
{{ partial "hx/button" $params }}

View file

@ -0,0 +1,6 @@
{{- $type := .Get "type" | default "text" -}}
{{- $name := .Get "name" | default "textline" -}}
<div>
<input type="{{ $type }}" name="{{ $name }}"
{{- with .Get "attrs" }} {{ . }}{{ end }}>
</div>

View file

@ -0,0 +1,11 @@
{{- $root := .Site.Params.Api.Root -}}
{{- $name := .Get "name" | default "data" -}}
{{- $action := .Get "action" | default "data" -}}
{{- $domain := .Get "domain" | default $.Page.Params.api.domain -}}
{{- $target := .Get "target" | default "#debug" -}}
{{- $label := "Submit" -}}
<form name="{{ $name }}" hx-target="{{ $target }}"
hx-post="{{ $root }}/{{ $domain }}/{{ $action }}">
{{ .Inner }}
<button>{{ $label }}</button>
</form>

View file

@ -0,0 +1 @@
<div id="debug" />

View file

@ -3,7 +3,7 @@
Hello World!
</button>
<form hx-post="api/test/data" hx-target="#output">
<form hx-post="hx/test/data" hx-target="#output">
<input name="info">
<button>Post to API</button>
</form>

View file

@ -27,6 +27,7 @@ params:
api:
module: main-htmx.ts
root: /hx
taxonomies:
domain: domains

View file

@ -0,0 +1,27 @@
---
title: Login
summary: Login Page
img:
pageid: login
domains: []
topics: []
date: 2024-07-22
author: helmutm
draft: false
weight: 900
api:
domain: auth
---
Please enter login data:
{{< hx/data-form name="login" action="login" >}}
Login: {{< hx/data-field-line name="login" attrs="autofocus" >}}
Password: {{< hx/data-field-line type="password" name="password" >}}
{{< /hx/data-form >}}
---
{{< hx/debug >}}