xtablo-source/backend/internal/web/ui/button.templ
Arthur Belleville d056b33241 feat(01-02): add Button, Card, Badge templ components + CSS
- 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)
2026-05-14 18:46:42 +02:00

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>
}