Add feedback components 106-130; inert scope, focus return, two-step deploy

This commit is contained in:
ZacharyZhang-NY committed 2026-10-11 20:58:30 -04:00
1 parent bce416182e
commit bd3877e1b1
87 files changed
+2492 -147

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
package feedback
import (
"github.com/egoist/mygo/ui"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
)
type ShakeOptions struct {
// Cue shakes the child each time it changes.
Cue int
}
// shakes are the child's offsets in dots, a step each.
var shakes = [...]int{2, -2, 2, -2, 1, -1, 0}
// Shake jolts its child side to side briefly.
func Shake(c *ui.Context, o ShakeOptions, content func()) *ui.Element {
k := pixel.K(c)
e := ui.Box(c)
dx := 0
if step := since(c, k, cue(e, k, o.Cue), 20, len(shakes)-1); !k.Reduce() {
dx = shakes[step]
}
return e.Padding(0, k.D(2-dx), 0, k.D(2+dx)).Children(content)
}