gromer
git clone https://git.pyrossh.dev/gromer
gromer is a framework and cli to build multipage web apps in golang using htmx and alpinejs.
5d23ed7
— pyros2097
2020-12-02T23:00:17+05:30
add example
- example/.gitignore +23 -0
- example/assets/icon.png +0 -0
- example/assets/manifest.json +21 -0
- example/atoms/atoms.go +15 -0
- example/main.go +9 -0
- example/makefile +1 -0
- example/pages/about/main.go +13 -0
- example/pages/clock/main.go +53 -0
- example/pages/container/main.go +42 -0
- example/pages/index/main.go +35 -0
- example/readme.md +7 -0
- example/styles.css +3 -0
example/.gitignore
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Binaries for programs and plugins
|
|
2
|
+
*.exe
|
|
3
|
+
*.exe~
|
|
4
|
+
*.dll
|
|
5
|
+
*.so
|
|
6
|
+
*.dylib
|
|
7
|
+
*.app
|
|
8
|
+
|
|
9
|
+
# Test binary, build with `go test -c`
|
|
10
|
+
*.test
|
|
11
|
+
test
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# Output of the go coverage tool, specifically when used with LiteIDE
|
|
15
|
+
*.out
|
|
16
|
+
|
|
17
|
+
# Static generated files
|
|
18
|
+
*.gz
|
|
19
|
+
*.gcloudignore
|
|
20
|
+
*.wasm
|
|
21
|
+
main
|
|
22
|
+
build
|
|
23
|
+
vendor
|
example/assets/icon.png
ADDED
|
Binary file
|
example/assets/manifest.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"short_name": "{{.ShortName}}",
|
|
3
|
+
"name": "{{.Name}}",
|
|
4
|
+
"icons": [
|
|
5
|
+
{
|
|
6
|
+
"src": "{{.DefaultIcon}}",
|
|
7
|
+
"type": "image/png",
|
|
8
|
+
"sizes": "192x192"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"src": "{{.LargeIcon}}",
|
|
12
|
+
"type": "image/png",
|
|
13
|
+
"sizes": "512x512"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"scope": "{{.Scope}}",
|
|
17
|
+
"start_url": "{{.StartURL}}",
|
|
18
|
+
"background_color": "{{.BackgroundColor}}",
|
|
19
|
+
"display": "standalone",
|
|
20
|
+
"theme_color": "{{.ThemeColor}}"
|
|
21
|
+
}
|
example/atoms/atoms.go
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
package atoms
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
app "github.com/pyros2097/wapp"
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
var CountAtom = app.NewAtom(0)
|
|
8
|
+
|
|
9
|
+
func IncCount() {
|
|
10
|
+
CountAtom.Set(CountAtom.Get().(int) + 1)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
func DecCount() {
|
|
14
|
+
CountAtom.Set(CountAtom.Get().(int) - 1)
|
|
15
|
+
}
|
example/main.go
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"github.com/pyros2097/wapp/cli"
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
func main() {
|
|
8
|
+
cli.Watch()
|
|
9
|
+
}
|
example/makefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npx tailwindcss-cli@latest build -o assets/styles.css
|
example/pages/about/main.go
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
. "github.com/pyros2097/wapp"
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
func Route(c *RenderContext) UI {
|
|
8
|
+
return Div(Text("About Me"))
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
func main() {
|
|
12
|
+
Run(Route)
|
|
13
|
+
}
|
example/pages/clock/main.go
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"time"
|
|
5
|
+
|
|
6
|
+
. "github.com/pyros2097/wapp"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
func Route(c *RenderContext) UI {
|
|
10
|
+
timeValue, setTime := c.UseState(time.Now())
|
|
11
|
+
running, setRunning := c.UseState(false)
|
|
12
|
+
startTimer := func() {
|
|
13
|
+
setRunning(true)
|
|
14
|
+
go func() {
|
|
15
|
+
for running().(bool) {
|
|
16
|
+
setTime(time.Now())
|
|
17
|
+
time.Sleep(time.Second * 1)
|
|
18
|
+
}
|
|
19
|
+
}()
|
|
20
|
+
}
|
|
21
|
+
stopTimer := func() {
|
|
22
|
+
setRunning(false)
|
|
23
|
+
}
|
|
24
|
+
c.UseEffect(func() func() {
|
|
25
|
+
startTimer()
|
|
26
|
+
return stopTimer
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
return Col(
|
|
30
|
+
Row(
|
|
31
|
+
Div(Css("text-6xl"),
|
|
32
|
+
Text("Clock"),
|
|
33
|
+
),
|
|
34
|
+
),
|
|
35
|
+
Row(
|
|
36
|
+
Div(Css("mt-10"),
|
|
37
|
+
Text(timeValue().(time.Time).Format("15:04:05")),
|
|
38
|
+
),
|
|
39
|
+
),
|
|
40
|
+
Row(
|
|
41
|
+
Div(Css("text-6xl m-20 cursor-pointer select-none"), OnClick(startTimer),
|
|
42
|
+
Text("Start"),
|
|
43
|
+
),
|
|
44
|
+
Div(Css("text-6xl m-20 cursor-pointer select-none"), OnClick(stopTimer),
|
|
45
|
+
Text("Stop"),
|
|
46
|
+
),
|
|
47
|
+
),
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
func main() {
|
|
52
|
+
Run(Route)
|
|
53
|
+
}
|
example/pages/container/main.go
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"strconv"
|
|
5
|
+
|
|
6
|
+
. "github.com/pyros2097/wapp"
|
|
7
|
+
. "github.com/pyros2097/wapp/example/atoms"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
func Counter(c *RenderContext, no string) UI {
|
|
11
|
+
count := c.UseAtom(CountAtom)
|
|
12
|
+
return Col(
|
|
13
|
+
Row(
|
|
14
|
+
Row(Css("text-2xl"),
|
|
15
|
+
Text("Counter - "+no),
|
|
16
|
+
),
|
|
17
|
+
),
|
|
18
|
+
Row(
|
|
19
|
+
Row(Css("text-2xl m-20 cursor-pointer select-none"), OnClick(DecCount),
|
|
20
|
+
Text("-"),
|
|
21
|
+
),
|
|
22
|
+
Row(Css("text-2xl m-20"),
|
|
23
|
+
Text(strconv.Itoa(count.(int))),
|
|
24
|
+
),
|
|
25
|
+
Row(Css("text-2xl m-20 cursor-pointer select-none"), OnClick(IncCount),
|
|
26
|
+
Text("+"),
|
|
27
|
+
),
|
|
28
|
+
),
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
func Route(c *RenderContext) UI {
|
|
33
|
+
return Col(
|
|
34
|
+
Counter(c, "1"),
|
|
35
|
+
Counter(c, "2"),
|
|
36
|
+
Counter(c, "3"),
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
func main() {
|
|
41
|
+
Run(Route)
|
|
42
|
+
}
|
example/pages/index/main.go
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"strconv"
|
|
5
|
+
|
|
6
|
+
. "github.com/pyros2097/wapp"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
func Route(c *RenderContext) UI {
|
|
10
|
+
count, setCount := c.UseInt(0)
|
|
11
|
+
inc := func() { setCount(count() + 1) }
|
|
12
|
+
dec := func() { setCount(count() - 1) }
|
|
13
|
+
return Col(
|
|
14
|
+
Row(
|
|
15
|
+
Row(Css("text-6xl"),
|
|
16
|
+
Text("Counter"),
|
|
17
|
+
),
|
|
18
|
+
),
|
|
19
|
+
Row(
|
|
20
|
+
Row(Css("text-6xl m-20 cursor-pointer select-none"), OnClick(dec),
|
|
21
|
+
Text("-"),
|
|
22
|
+
),
|
|
23
|
+
Row(Css("text-6xl m-20"),
|
|
24
|
+
Text(strconv.Itoa(count())),
|
|
25
|
+
),
|
|
26
|
+
Row(Css("text-6xl m-20 cursor-pointer select-none"), OnClick(inc),
|
|
27
|
+
Text("+"),
|
|
28
|
+
),
|
|
29
|
+
),
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
func main() {
|
|
34
|
+
Run(Route)
|
|
35
|
+
}
|
example/readme.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# wapp-example
|
|
2
|
+
|
|
3
|
+
An example to demostrate the wapp framework
|
|
4
|
+
|
|
5
|
+
Just run,
|
|
6
|
+
|
|
7
|
+
`go run main.go`
|
example/styles.css
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
@tailwind base;
|
|
2
|
+
@tailwind components;
|
|
3
|
+
@tailwind utilities;
|