refactor: move cation trigger logic to its own file; separate conter and greeter examples

This commit is contained in:
Joao Goncalves
2025-11-02 02:44:27 -01:00
parent a265f537a6
commit 3d09b3110d
3 changed files with 52 additions and 13 deletions

18
actiontrigger.go Normal file
View File

@@ -0,0 +1,18 @@
package via
import (
"fmt"
"github.com/go-via/via/h"
)
// actionTrigger represents a trigger to an event handler fn
type actionTrigger struct {
id string
}
// OnClick returns a via.h DOM node that triggers on click. It can be added
// to other nodes in a view.
func (a *actionTrigger) OnClick() h.H {
return h.Data("on:click", fmt.Sprintf("@get('/_action/%s')", a.id))
}