Add gallery core and command: routes, sidebar, search, code panel, browser hook

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-17 01:55:25 -04:00
1 parent 727de5f110
commit ff50f9b35a
10 files changed
+750 -2

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
//go:build !(js && wasm)
package main
import "git.zacharyzhang.com/ZacharyZhang-NY/CrychicUI/gallery"
func hook(*gallery.App) {}
+30
View File
@@ -0,0 +1,30 @@
//go:build js && wasm
package main
import (
"syscall/js"
"git.zacharyzhang.com/ZacharyZhang-NY/CrychicUI/gallery"
"git.zacharyzhang.com/ZacharyZhang-NY/CrychicUI/sound"
)
// hook exports window.__crychic for Playwright.
func hook(app *gallery.App) {
obj := js.Global().Get("Object").New()
js.Global().Get("Object").Call("defineProperty", obj, "ready", map[string]any{
"get": js.FuncOf(func(js.Value, []js.Value) any { return app.Snapshot().Built }),
})
obj.Set("page", js.FuncOf(func(js.Value, []js.Value) any { return app.Snapshot().Page }))
obj.Set("stats", js.FuncOf(func(js.Value, []js.Value) any {
return map[string]any{"components": len(gallery.Entries()), "categories": len(gallery.Categories)}
}))
obj.Set("recent", js.FuncOf(func(js.Value, []js.Value) any {
var out []any
for _, c := range sound.Recent() {
out = append(out, c.String())
}
return out
}))
js.Global().Set("__crychic", obj)
}
+28
View File
@@ -0,0 +1,28 @@
// Command gallery opens the CrychicUI gallery on desktops and browsers.
package main
import (
"log"
"git.zacharyzhang.com/ZacharyZhang-NY/CrychicUI/gallery"
"github.com/egoist/mygo"
"github.com/egoist/mygo/ui"
)
func main() {
app := gallery.New("/")
hook(app)
mygo.App.WhenReady(func() {
mygo.NewWindow(mygo.WindowOptions{
Title: "CrychicUI",
Width: 1280,
Height: 820,
MinWidth: 720,
MinHeight: 480,
Content: ui.View(app.View),
})
})
if err := mygo.App.Run(); err != nil {
log.Fatal(err)
}
}