xtablo-source/backend/internal/web/ui/form_field.templ
Arthur Belleville 52fb77d4f8
feat(13-03): port select + form-field components with CSS and helpers (GREEN)
- select_helpers.go: 9 helper functions verbatim from go-backend
- select.templ: SelectProps/SelectOption structs, inline JS with __uiSelectInitAll
  and htmx:afterSwap re-init listener (Pitfall 6)
- select.css: .ui-select-control (min-height 44px), .ui-select-menu (max-height 16rem)
- form_field.templ: FormFieldProps with Label/For/Field/Error/Hint; conditional regions
- form-field.css: .ui-form-field/.ui-form-label/.ui-form-hint/.ui-form-error
- tailwind.input.css: add @import for select.css and form-field.css
- All 6 TestSelect/TestFormField tests passing; full go test ./... is green
2026-05-16 14:00:51 +02:00

26 lines
502 B
Text

package ui
type FormFieldProps struct {
Label string
For string
Field templ.Component
Error string
Hint string
}
templ FormField(props FormFieldProps) {
<div class="ui-form-field">
if props.Label != "" {
<label for={ props.For } class="ui-form-label">{ props.Label }</label>
}
if props.Field != nil {
@props.Field
}
if props.Hint != "" {
<p class="ui-form-hint">{ props.Hint }</p>
}
if props.Error != "" {
<p class="ui-form-error">{ props.Error }</p>
}
</div>
}