package views import ( "strconv" "hearthforge/internal/config" g "maragu.dev/gomponents" . "maragu.dev/gomponents/html" ) // EditableTitle renders a title with a CSS-only inline edit form. // bodyFieldName and bodyValue resubmit the unchanged body with the title. func EditableTitle(cfg *config.Config, title string, canEdit bool, editAction, bodyFieldName, bodyValue string) g.Node { return g.Group{ g.If(canEdit, Input(Type("checkbox"), ID("title-edit-toggle"), Class("title-edit-toggle"))), Div(Class("title-with-edit"), H2(Class("issue-detail-title"), g.Text(title)), g.If(canEdit, g.Group{ Div(Class("title-edit-form-area"), Form(Method("POST"), Action(editAction), Class("title-edit-form"), Input(Class("form-input"), Name("title"), Value(title), Required(), MaxLength(strconv.Itoa(cfg.MaxTitleBytes))), Input(Type("hidden"), Name(bodyFieldName), Value(bodyValue)), Div(Class("title-edit-actions"), Button(Type("submit"), Class("btn btn-sm btn-primary"), g.Text("Save")), Label(For("title-edit-toggle"), Class("btn btn-sm"), g.Text("Cancel")), ), ), ), Label(For("title-edit-toggle"), Class("btn btn-xs title-edit-open"), g.Text("Edit title")), }), ), } }