- button.templ: Button(ButtonProps) renders <button type=...> with class from ui.ButtonClass(); Attrs spread for hx-* pass-through - button.css: .ui-button base + .ui-button-solid-default-md variant with non-nested :hover and :focus-visible (Codex concern #7) - card.templ: Card(attrs) accepts children via templ child syntax - card.css: slate-50 panel, slate-200 border - badge.templ: Badge(BadgeProps) renders <span class=...> - badge.css: info / success / danger variants (warning deferred)
23 lines
611 B
Text
23 lines
611 B
Text
package ui
|
|
|
|
// ButtonProps is the input to the Button templ component.
|
|
//
|
|
// Type defaults to "button" when empty. Attrs is a pass-through for arbitrary
|
|
// attributes (notably hx-* HTMX attributes).
|
|
type ButtonProps struct {
|
|
Label string
|
|
Variant ButtonVariant
|
|
Tone ButtonTone
|
|
Size Size
|
|
Type string
|
|
Attrs templ.Attributes
|
|
}
|
|
|
|
templ Button(props ButtonProps) {
|
|
{{ btnType := props.Type }}
|
|
if btnType == "" {
|
|
{{ btnType = "button" }}
|
|
}
|
|
{{ class := ButtonClass(props.Variant, props.Tone, props.Size) }}
|
|
<button type={ btnType } class={ class } { props.Attrs... }>{ props.Label }</button>
|
|
}
|