- Fix potential nil file.Close() panic in devModePersist/devModeRemovePersisted
by extracting loadDevModeMap/saveDevModeMap helpers with proper defer
- Remove tracked binaries (pathparams 10.8 MB, shake.db 22 MB) and consolidate
.gitignore with a wildcard pattern covering all 19 examples
- Remove stale reaper reference in README (removed in dc56261), update example
count from 14 to 19, fix OnChange debounce claim in docs
- Fix typos: "percist"→"persist", "percisted"→"persisted", "tmplates"→"templates"
- Remove dead code: commented import in signal_test.go, unnecessary fmt.Sprintf
in computed.go, commented picocss imports and no-op Config calls in examples
- Replace go fmt with gofmt -l check in ci-check.sh to fail on unformatted code
instead of silently reformatting
43 lines
770 B
Go
43 lines
770 B
Go
package main
|
|
|
|
import (
|
|
"github.com/ryanhamamura/via"
|
|
"github.com/ryanhamamura/via/h"
|
|
)
|
|
|
|
type Counter struct{ Count int }
|
|
|
|
func main() {
|
|
v := via.New()
|
|
|
|
v.Config(via.Options{
|
|
DocumentTitle: "Via Counter",
|
|
})
|
|
|
|
v.Page("/", func(c *via.Context) {
|
|
data := Counter{Count: 0}
|
|
step := c.Signal(1)
|
|
|
|
increment := c.Action(func() {
|
|
data.Count += step.Int()
|
|
c.Sync()
|
|
})
|
|
|
|
c.View(func() h.H {
|
|
return h.Main(h.Class("container"), h.Br(),
|
|
h.H1(h.Text("⚡ Via Counter")), h.Hr(),
|
|
h.Div(
|
|
h.H2(h.Textf("Count - %d", data.Count)),
|
|
h.H5(h.Text("Step - "), step.Text()),
|
|
h.Div(h.Role("group"),
|
|
h.Input(h.Type("number"), step.Bind()),
|
|
h.Button(h.Text("Increment"), increment.OnClick()),
|
|
),
|
|
),
|
|
)
|
|
})
|
|
})
|
|
|
|
v.Start()
|
|
}
|