WASM reactive UI framework for Go: - reactive/ - Signal[T], Effect, Runtime - ui/ - Button, Text, Input, View, Canvas, SVG components - navigation/ - Router, guards, history management - auth/ - OIDC client for WASM applications - host/ - Static file server Extracted from arcadia as open-source component. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
23
ui/text.go
Normal file
23
ui/text.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"git.flowmade.one/flowmade-one/iris/internal/element"
|
||||
"git.flowmade.one/flowmade-one/iris/reactive"
|
||||
)
|
||||
|
||||
func TextFromString(text string) View {
|
||||
v := View{element.NewElement("p")}
|
||||
v.e.Set("textContent", text)
|
||||
return v
|
||||
}
|
||||
|
||||
func TextFromFunction(fn func() string) View {
|
||||
textNode := element.NewElement("p")
|
||||
|
||||
reactive.NewEffect(func() {
|
||||
value := fn()
|
||||
textNode.Set("textContent", value)
|
||||
})
|
||||
|
||||
return View{textNode}
|
||||
}
|
||||
Reference in New Issue
Block a user