Stack through StickyHeader, with behavior tests and gallery demos. kit gains Arrive, Settle (paint-time layout check) and Shade. Several actions return named ui.Element results; mygo vet forbids elements in structs. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
23 lines
667 B
Go
23 lines
667 B
Go
package layout
|
|
|
|
import "github.com/egoist/mygo/ui"
|
|
|
|
// ContainerOptions tune a Container.
|
|
type ContainerOptions struct {
|
|
// MaxWidth is 64 rem when zero.
|
|
MaxWidth float32
|
|
}
|
|
|
|
// Container is a centered, padded page column; its width animates.
|
|
func Container(c *ui.Context, o ContainerOptions, content func()) ui.Element {
|
|
t := c.Theme()
|
|
if o.MaxWidth == 0 {
|
|
o.MaxWidth = t.Rem(64)
|
|
}
|
|
if !finite(o.MaxWidth) || o.MaxWidth < 0 {
|
|
panic("layout: Container MaxWidth must be finite and non-negative")
|
|
}
|
|
return ui.Column(c).FillWidth().MaxWidth(o.MaxWidth).Margin(0, ui.Auto).Padding(t.Space(6)).
|
|
Transition(ui.ElementTransition{Size: true}).Children(content)
|
|
}
|