xtablo-source/backend/internal/web/ui/button.templ
Arthur Belleville 66f23bba77
feat(13-02): multi-class ButtonClass() + Icon field + buttonType helper in button.templ
- ButtonClass() now emits "ui-button ui-button-solid ui-button-default ui-button-md"
- Ghost variant special case: "ui-button ui-button-ghost ui-button-md" (tone omitted)
- button.templ: added Icon string field to ButtonProps, replaced inline btnType with buttonType() helper
- ui_test.go: updated TestButton_DefaultSolidMD to multi-class slice assertions
- ui_test.go: updated TestButtonClass_String and TestButtonClass_GhostVariant expectations
- All 18 ui package tests pass
2026-05-16 13:52:01 +02:00

23 lines
736 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). Icon is a named icon key that
// will be rendered via UIIcon when Plan 04 wires up icon_button.templ.
type ButtonProps struct {
Label string
Variant ButtonVariant
Tone ButtonTone
Size Size
Type string
Icon string
Attrs templ.Attributes
}
templ Button(props ButtonProps) {
<button type={ buttonType(props.Type) } class={ ButtonClass(props.Variant, props.Tone, props.Size) } { props.Attrs... }>
// UIIcon added in Plan 04 — Icon field present, rendering wired when UIIcon exists
{ props.Label }
</button>
}