features/templ-components #3
34
internal/views/bulma/button.templ
Normal file
34
internal/views/bulma/button.templ
Normal 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>
|
||||
}
|
8
internal/views/bulma/form/control.templ
Normal file
8
internal/views/bulma/form/control.templ
Normal file
@ -0,0 +1,8 @@
|
||||
package form
|
||||
|
||||
// Div container to add a input field to.
|
||||
templ Control() {
|
||||
<div class="control">
|
||||
{ children... }
|
||||
</div>
|
||||
}
|
8
internal/views/bulma/form/field.templ
Normal file
8
internal/views/bulma/form/field.templ
Normal 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>
|
||||
}
|
9
internal/views/bulma/form/input.templ
Normal file
9
internal/views/bulma/form/input.templ
Normal 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 }/>
|
||||
}
|
||||
}
|
6
internal/views/bulma/form/label.templ
Normal file
6
internal/views/bulma/form/label.templ
Normal 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>
|
||||
}
|
7
internal/views/bulma/form/new.templ
Normal file
7
internal/views/bulma/form/new.templ
Normal file
@ -0,0 +1,7 @@
|
||||
package form
|
||||
|
||||
templ New(postUrl string) {
|
||||
<form hx-post={ postUrl }>
|
||||
{ children... }
|
||||
</form>
|
||||
}
|
5
internal/views/bulma/form/submit.templ
Normal file
5
internal/views/bulma/form/submit.templ
Normal file
@ -0,0 +1,5 @@
|
||||
package form
|
||||
|
||||
templ Submit(text, color string) {
|
||||
<button type="submit" class={ "button", color }>{ text }</button>
|
||||
}
|
6
internal/views/bulma/form/util.go
Normal file
6
internal/views/bulma/form/util.go
Normal file
@ -0,0 +1,6 @@
|
||||
package form
|
||||
|
||||
const (
|
||||
InputTypeText = "text"
|
||||
InputTypePassword = "password"
|
||||
)
|
10
internal/views/bulma/util.go
Normal file
10
internal/views/bulma/util.go
Normal 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"
|
||||
)
|
Loading…
Reference in New Issue
Block a user