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:
29
ui/app_router.go
Normal file
29
ui/app_router.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"git.flowmade.one/flowmade-one/iris/internal/element"
|
||||
"git.flowmade.one/flowmade-one/iris/reactive"
|
||||
)
|
||||
|
||||
// Router interface to avoid import cycle
|
||||
type Router interface {
|
||||
GetCurrentView() View
|
||||
}
|
||||
|
||||
// NewAppWithRouter creates a new app with navigation support
|
||||
func NewAppWithRouter(router Router) {
|
||||
app := NewView()
|
||||
app.e.Grid()
|
||||
app.MinHeight("100vh")
|
||||
|
||||
// Create a reactive view that updates when routes change
|
||||
reactive.NewEffect(func() {
|
||||
currentView := router.GetCurrentView()
|
||||
// Clear the app and add the current view
|
||||
// Note: In a production implementation, we'd want better DOM diffing
|
||||
app.e.Set("innerHTML", "")
|
||||
app.Child(currentView)
|
||||
})
|
||||
|
||||
element.Mount(app.e)
|
||||
}
|
||||
Reference in New Issue
Block a user