features/templ-components #3

Merged
jtom38 merged 17 commits from features/templ-components into main 2024-07-13 10:40:28 -07:00
9 changed files with 93 additions and 0 deletions
Showing only changes of commit 0206d84894 - Show all commits

View File

@ -0,0 +1,34 @@
package bulma
templ Button(color string, isLight, isDark bool) {
if isLight {
<button type="button" class={ "button", "is-light", color }>
{ children... }
</button>
}
if isDark {
<button type="button" class={ "button", "is-dark", color }>
{ children... }
</button>
}
if !isLight && !isDark {
<button type="button" class={ "button", color }>
{ children... }
</button>
}
}
templ ButtonNewTab(url, text string) {
<button type="button" class="button">
<a href={ templ.SafeURL(url) } target="_blank" rel="noopener noreferrer">{ text }</a>
</button>
}
templ ALink(url, title string) {
<a href={ templ.SafeURL(url) }>{ title }</a>
}
templ ANewTab(url, text string) {
<a href={ templ.SafeURL(url) } target="_blank" rel="noopener noreferrer">{ text }</a>
}

View File

@ -0,0 +1,8 @@
package form
// Div container to add a input field to.
templ Control() {
<div class="control">
{ children... }
</div>
}

View File

@ -0,0 +1,8 @@
package form
// This creates a field that you can add a Label, Control or Input object.
templ Field() {
<div class="field">
{ children... }
</div>
}

View File

@ -0,0 +1,9 @@
package form
templ Input(color, id, fieldType string) {
if color == "" {
<input class={ "input" } id={ id } type={ fieldType }/>
} else {
<input class={ "input", color } id={ id } type={ fieldType }/>
}
}

View File

@ -0,0 +1,6 @@
package form
// This will create a small bit of text to add context to the form.
templ Label(text string) {
<label class="label">{ text }</label>
}

View File

@ -0,0 +1,7 @@
package form
templ New(postUrl string) {
<form hx-post={ postUrl }>
{ children... }
</form>
}

View File

@ -0,0 +1,5 @@
package form
templ Submit(text, color string) {
<button type="submit" class={ "button", color }>{ text }</button>
}

View File

@ -0,0 +1,6 @@
package form
const (
InputTypeText = "text"
InputTypePassword = "password"
)

View File

@ -0,0 +1,10 @@
package bulma
const (
ColorPrimary = "is-primary"
ColorInfo = "is-info"
ColorLink = "is-link"
ColorWarning = "is-warning"
ColorSuccess = "is-success"
ColorError = "is-error"
)