Initial iris repository structure
Some checks failed
CI / build (push) Failing after 36s

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:
2026-01-08 19:23:49 +01:00
commit 00d98879d3
36 changed files with 4181 additions and 0 deletions

90
navigation/components.go Normal file
View File

@@ -0,0 +1,90 @@
package navigation
import (
"git.flowmade.one/flowmade-one/iris/reactive"
"git.flowmade.one/flowmade-one/iris/ui"
)
var globalRouter *Router
var globalHistory *HistoryManager
func SetGlobalRouter(router *Router) {
globalRouter = router
globalHistory = NewHistoryManager(router)
globalHistory.Start()
}
func GetGlobalRouter() *Router {
return globalRouter
}
// RouterView renders the current route's view
func RouterView() ui.View {
if globalRouter == nil {
return ui.TextFromString("Router not initialized").Color("#ff4444")
}
// Create a view that updates when the route changes
view := ui.NewView()
reactive.NewEffect(func() {
currentView := globalRouter.GetCurrentView()
// Clear previous content and add new view
// Note: This is a simplified approach - in a real implementation
// we'd need better DOM diffing
view = currentView
})
return view
}
// Link creates a navigational link that updates the route
func Link(path string, content ui.View) ui.View {
if globalHistory == nil {
return content
}
// Create a simple clickable element that navigates with proper styling for horizontal layout
button := ui.Button(func() {
globalHistory.PushState(path)
}, content)
// Style the button to look like a link and work in horizontal layouts
return button.Padding("8px 12px").Background("transparent").Border("none")
}
// Navigate programmatically navigates to a path
func Navigate(path string) {
if globalHistory != nil {
globalHistory.PushState(path)
}
}
// Replace programmatically replaces current path
func Replace(path string) {
if globalHistory != nil {
globalHistory.ReplaceState(path)
}
}
// Back navigates back in history
func Back() {
if globalHistory != nil {
globalHistory.Back()
}
}
// Forward navigates forward in history
func Forward() {
if globalHistory != nil {
globalHistory.Forward()
}
}
// GetCurrentPath returns the current route path
func GetCurrentPath() string {
if globalRouter != nil {
return globalRouter.GetCurrentPath()
}
return ""
}