Remove internal package import from todo example
All checks were successful
CI / build (push) Successful in 27s
All checks were successful
CI / build (push) Successful in 27s
Replace direct internal/element usage with public ui package components to ensure examples only use the public API: - Add ui.RawCheckbox for plain checkbox without label wrapper - Add ui.Span for span elements with text content - Add View.TextDecoration modifier for strikethrough styling - Update todo example to use these public components Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit was merged in pull request #16.
This commit is contained in:
21
ui/input.go
21
ui/input.go
@@ -205,4 +205,23 @@ func NumberInput(value *reactive.Signal[float64], placeholder string) View {
|
||||
})
|
||||
|
||||
return View{input}
|
||||
}
|
||||
}
|
||||
// RawCheckbox creates a plain checkbox input without a label wrapper.
|
||||
// The onChange callback is called with the new checked state when the user clicks.
|
||||
func RawCheckbox(checked bool, onChange func(bool)) View {
|
||||
checkbox := element.NewElement("input")
|
||||
checkbox.Attr("type", "checkbox")
|
||||
|
||||
// Set initial state
|
||||
if checked {
|
||||
checkbox.Set("checked", true)
|
||||
}
|
||||
|
||||
// Call onChange when user clicks
|
||||
checkbox.On("change", func() {
|
||||
newValue := checkbox.Get("checked").Bool()
|
||||
onChange(newValue)
|
||||
})
|
||||
|
||||
return View{checkbox}
|
||||
}
|
||||
|
||||
@@ -170,3 +170,8 @@ func (v View) PointerEvents(value string) View {
|
||||
v.e.PointerEvents(value)
|
||||
return v
|
||||
}
|
||||
|
||||
func (v View) TextDecoration(value string) View {
|
||||
v.e.Get("style").Call("setProperty", "text-decoration", value)
|
||||
return v
|
||||
}
|
||||
|
||||
@@ -21,3 +21,10 @@ func TextFromFunction(fn func() string) View {
|
||||
|
||||
return View{textNode}
|
||||
}
|
||||
|
||||
// Span creates a span element with the given text content.
|
||||
func Span(text string) View {
|
||||
v := View{element.NewElement("span")}
|
||||
v.e.Set("textContent", text)
|
||||
return v
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user