hx (work in progress): start with login form
This commit is contained in:
parent
3fbe4d8d8b
commit
3cd7ec3706
8 changed files with 54 additions and 1 deletions
1
layouts/partials/hx/button.html
Normal file
1
layouts/partials/hx/button.html
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<button type="{{ .type }}" name="{{ .name }}">{{.label}}</button>
|
6
layouts/shortcodes/hx/button.html
Normal file
6
layouts/shortcodes/hx/button.html
Normal 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 }}
|
6
layouts/shortcodes/hx/data-field-line.html
Normal file
6
layouts/shortcodes/hx/data-field-line.html
Normal 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>
|
11
layouts/shortcodes/hx/data-form.html
Normal file
11
layouts/shortcodes/hx/data-form.html
Normal 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>
|
1
layouts/shortcodes/hx/debug.html
Normal file
1
layouts/shortcodes/hx/debug.html
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<div id="debug" />
|
|
@ -3,7 +3,7 @@
|
||||||
Hello World!
|
Hello World!
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<form hx-post="api/test/data" hx-target="#output">
|
<form hx-post="hx/test/data" hx-target="#output">
|
||||||
<input name="info">
|
<input name="info">
|
||||||
<button>Post to API</button>
|
<button>Post to API</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -27,6 +27,7 @@ params:
|
||||||
|
|
||||||
api:
|
api:
|
||||||
module: main-htmx.ts
|
module: main-htmx.ts
|
||||||
|
root: /hx
|
||||||
|
|
||||||
taxonomies:
|
taxonomies:
|
||||||
domain: domains
|
domain: domains
|
||||||
|
|
27
sites/hx/content/app/login.md
Normal file
27
sites/hx/content/app/login.md
Normal 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 >}}
|
Loading…
Add table
Reference in a new issue