Skip to content

Commit 66de6bb

Browse files
authored
Merge pull request #73 from admin-golang/infinity-scrolling-initial-template
templates: Infinity scrolling initial template
2 parents fa4d88c + 11dbc97 commit 66de6bb

File tree

5 files changed

+92
-0
lines changed

5 files changed

+92
-0
lines changed

admin.go

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type UITheme int8
3232
const (
3333
MaterialUI UITheme = iota + 1
3434
AntDesignUI
35+
VueUI
3536
)
3637

3738
type FieldType uint
@@ -671,6 +672,7 @@ func (ad *admin) ServeHTTP(w http.ResponseWriter, r *http.Request) {
671672
UITheme UITheme
672673
MaterialUI UITheme
673674
AntDesignUI UITheme
675+
VueUI UITheme
674676
}{
675677
Debug: ad.debugMode,
676678
ThemeJS: template.JS(indexJSMinified.Code),
@@ -679,6 +681,7 @@ func (ad *admin) ServeHTTP(w http.ResponseWriter, r *http.Request) {
679681
UITheme: ad.uiTheme,
680682
MaterialUI: MaterialUI,
681683
AntDesignUI: AntDesignUI,
684+
VueUI: VueUI,
682685
}
683686

684687
adminTemplate, err := newTemplate("Admin").Parse(ad.adminTemplateText)
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
go install github.com/cespare/reflex@latest
4+
reflex -s -g reflex.conf -- reflex -c reflex.conf
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
# pushd examples/infinity-scrolling
4+
5+
# if [ -e ./bin/on_reload.sh ]
6+
# then
7+
# ./bin/on_reload.sh
8+
# fi
9+
10+
go run main.go

examples/infinity-scrolling/main.go

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package main
2+
3+
import (
4+
"log"
5+
"net/http"
6+
"net/url"
7+
8+
"github.com/admin-golang/admin"
9+
"github.com/admin-golang/admin/icon"
10+
"github.com/admin-golang/admin/layout"
11+
)
12+
13+
func NewSubscribeFormPage() (admin.Pager, error) {
14+
sideFormBackgroundImage, err := url.Parse("https://source.unsplash.com/random/?golang")
15+
if err != nil {
16+
return nil, err
17+
}
18+
19+
return admin.NewSideFormPage(admin.SideFormPageConfig{
20+
BackgroundImage: sideFormBackgroundImage,
21+
PageConfig: admin.PageConfig{
22+
Icon: icon.Icon{
23+
Type: icon.Email,
24+
},
25+
IsDefault: true,
26+
ID: "Subscribe",
27+
URL: "/subscribe",
28+
Type: admin.SideFormPage,
29+
},
30+
Form: admin.Form{
31+
ID: "subscribe",
32+
Fields: admin.Fields{
33+
admin.Field{
34+
ID: "email",
35+
Type: admin.InputText,
36+
Label: "Email",
37+
IsRequired: true,
38+
Value: "",
39+
FullWidth: true,
40+
},
41+
},
42+
Submit: admin.Submit{
43+
Label: "Subscribe",
44+
URL: "/subscribe",
45+
Method: "POST",
46+
},
47+
},
48+
}), nil
49+
}
50+
51+
func main() {
52+
subscribeFormPage, err := NewSubscribeFormPage()
53+
if err != nil {
54+
log.Fatal(err)
55+
}
56+
57+
pages := admin.Pages{
58+
subscribeFormPage,
59+
}
60+
61+
admin := admin.New(&admin.Config{
62+
DebugMode: false,
63+
UITheme: admin.MaterialUI,
64+
Pages: pages,
65+
Layout: layout.New(&layout.Config{}),
66+
})
67+
68+
mux := http.NewServeMux()
69+
70+
mux.Handle("/", admin)
71+
72+
log.Println("[admin-golang] running on port :8080 path: /admin")
73+
log.Fatal(http.ListenAndServe(":8080", mux))
74+
}
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-sr '(.go$)|(.tsx$)' -- ./bin/watch.sh

0 commit comments

Comments
 (0)