WIP components (as built)

This commit is contained in:
ZacharyZhang-NY committed 2026-10-05 15:51:57 -04:00
1 parent 299e5fe720
commit 4b8fdf8df7
71 files changed
+3241 -468

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
package mujica
import (
"testing"
"time"
"github.com/egoist/mygo/ui"
)
func TestLayoutTransitionResizes(t *testing.T) {
wide := false
var w float32
tt, n := motionFrames(func(c *ui.Context) {
ui.Column(c).AlignItems(ui.Start).Children(func() {
box := LayoutTransition(c, LayoutTransitionOptions{Clip: true}, func() {
width := float32(100)
if wide {
width = 300
}
ui.Box(c).Size(width, 40)
})
w = box.Bounds().W
})
}, 400, 120)
wide = true
before := *n
tt.Frame()
if *n-before < 3 {
t.Fatal("resize did not animate")
}
time.Sleep(260 * time.Millisecond)
tt.Frame()
if motionBusy(tt, n) || w != 300 {
t.Fatalf("settled width %v", w)
}
defer func() {
if recover() == nil {
t.Fatal("negative duration did not panic")
}
}()
ui.Render(func(c *ui.Context) {
Use(c, Settings{})
LayoutTransition(c, LayoutTransitionOptions{Duration: -1}, nil)
}, 100, 50, 1)
}
func TestLayoutTransitionSnapshot(t *testing.T) {
snapshot(t, "layout_transition", 300, 100, func(c *ui.Context) {
ui.Column(c).Padding(16).AlignItems(ui.Start).Children(func() {
LayoutTransition(c, LayoutTransitionOptions{}, func() {
ui.Text(c, "A panel that grows").Padding(12).Background(Tokens(c).Surface).Radius(4)
})
})
})
}