Okay this is based
This commit is contained in:
parent
e92d0f2c26
commit
c10a995b63
@ -15,10 +15,8 @@ func NewAboutPage() *AboutPage {
|
|||||||
func (a *AboutPage) Render() app.UI {
|
func (a *AboutPage) Render() app.UI {
|
||||||
return app.Div().Body(
|
return app.Div().Body(
|
||||||
&header{},
|
&header{},
|
||||||
app.Div().Body(
|
&navbar{},
|
||||||
newNavbar(),
|
|
||||||
&aboutPanel{},
|
&aboutPanel{},
|
||||||
).Class("main"),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
38
components/friendspage.go
Normal file
38
components/friendspage.go
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package components
|
||||||
|
|
||||||
|
import "github.com/maxence-charriere/go-app/v9/pkg/app"
|
||||||
|
|
||||||
|
type FriendsPage struct {
|
||||||
|
app.Compo
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewFriendsPage() *FriendsPage {
|
||||||
|
return &FriendsPage{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FriendsPage) Render() app.UI {
|
||||||
|
return app.Div().Body(
|
||||||
|
&header{},
|
||||||
|
&navbar{},
|
||||||
|
&friendsPanel{},
|
||||||
|
).Class("main")
|
||||||
|
}
|
||||||
|
|
||||||
|
type friendsPanel struct {
|
||||||
|
app.Compo
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *friendsPanel) Render() app.UI {
|
||||||
|
return app.Div().Body(
|
||||||
|
app.P().
|
||||||
|
Text(`My friends!`).
|
||||||
|
Class("p-h1"),
|
||||||
|
app.Ul().Body(
|
||||||
|
app.Li().Body(
|
||||||
|
app.IFrame().
|
||||||
|
Src("forestofunix.xyz").
|
||||||
|
Class("friend-iframe"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).Class("content")
|
||||||
|
}
|
@ -47,7 +47,6 @@ func (g *guestbookForm) Render() app.UI {
|
|||||||
}
|
}
|
||||||
g.OnSubmit(g.name, g.message)
|
g.OnSubmit(g.name, g.message)
|
||||||
g.clear()
|
g.clear()
|
||||||
g.Update()
|
|
||||||
}),
|
}),
|
||||||
).Class("content")
|
).Class("content")
|
||||||
}
|
}
|
||||||
|
@ -65,18 +65,6 @@ func (g *guestbookPanel) LoadComments() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *guestbookPanel) OnMount(ctx app.Context) {
|
|
||||||
//g.LoadComments()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *guestbookPanel) OnUpdate(ctx app.Context) {
|
|
||||||
if g.CommentUpdate {
|
|
||||||
g.LoadComments()
|
|
||||||
g.Update()
|
|
||||||
g.CommentUpdate = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type guestbookComment struct {
|
type guestbookComment struct {
|
||||||
app.Compo
|
app.Compo
|
||||||
|
|
||||||
|
@ -15,18 +15,19 @@ type Homepage struct {
|
|||||||
|
|
||||||
showGuestbook bool
|
showGuestbook bool
|
||||||
guestbookUpdated bool
|
guestbookUpdated bool
|
||||||
|
|
||||||
|
page string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHomepage() *Homepage {
|
func NewHomepage() *Homepage {
|
||||||
return &Homepage{showGuestbook: true, guestbookUpdated: false}
|
return &Homepage{showGuestbook: true, guestbookUpdated: false, page: "home"}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Homepage) Render() app.UI {
|
func (p *Homepage) Render() app.UI {
|
||||||
gbp := newGuestbookPanel()
|
gbp := newGuestbookPanel()
|
||||||
return app.Div().Body(
|
return app.Div().Body(
|
||||||
&header{},
|
&header{},
|
||||||
app.Div().Body(
|
&navbar{},
|
||||||
newNavbar(),
|
|
||||||
&homePanel{
|
&homePanel{
|
||||||
onShowClick: func() {
|
onShowClick: func() {
|
||||||
p.showGuestbook = !p.showGuestbook
|
p.showGuestbook = !p.showGuestbook
|
||||||
@ -50,11 +51,12 @@ func (p *Homepage) Render() app.UI {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if req.StatusCode == 200 {
|
if req.StatusCode == 200 {
|
||||||
|
p.Update()
|
||||||
}
|
}
|
||||||
defer req.Body.Close()
|
defer req.Body.Close()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
app.If(p.showGuestbook, gbp),
|
//app.If(p.showGuestbook, gbp),
|
||||||
).Class("main"),
|
gbp.Render(),
|
||||||
)
|
).Class("main")
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,8 @@ import "github.com/maxence-charriere/go-app/v9/pkg/app"
|
|||||||
|
|
||||||
type navbar struct {
|
type navbar struct {
|
||||||
app.Compo
|
app.Compo
|
||||||
}
|
|
||||||
|
|
||||||
func newNavbar() *navbar {
|
OnClickButton func(page string)
|
||||||
return &navbar{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *navbar) Render() app.UI {
|
func (n *navbar) Render() app.UI {
|
||||||
@ -19,6 +17,9 @@ func (n *navbar) Render() app.UI {
|
|||||||
app.Li().Body(
|
app.Li().Body(
|
||||||
app.A().Href("/about").Text("About"),
|
app.A().Href("/about").Text("About"),
|
||||||
),
|
),
|
||||||
|
app.Li().Body(
|
||||||
|
app.A().Href("/friends").Text("Friends"),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
).Class("navbar")
|
).Class("navbar")
|
||||||
}
|
}
|
||||||
|
2
main.go
2
main.go
@ -22,8 +22,10 @@ type application struct {
|
|||||||
func main() {
|
func main() {
|
||||||
homepage := components.NewHomepage()
|
homepage := components.NewHomepage()
|
||||||
aboutpage := components.NewAboutPage()
|
aboutpage := components.NewAboutPage()
|
||||||
|
friendspage := components.NewFriendsPage()
|
||||||
app.Route("/", homepage)
|
app.Route("/", homepage)
|
||||||
app.Route("/about", aboutpage)
|
app.Route("/about", aboutpage)
|
||||||
|
app.Route("/friends", friendspage)
|
||||||
|
|
||||||
// This is executed on the client side only.
|
// This is executed on the client side only.
|
||||||
// It handles client side stuff
|
// It handles client side stuff
|
||||||
|
@ -69,6 +69,21 @@ body {
|
|||||||
padding: 5px;
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.friend-frame {
|
||||||
|
width: 290px;
|
||||||
|
height: 200px;
|
||||||
|
overflow: hidden;
|
||||||
|
list-style: none;
|
||||||
|
text-decoration: none;
|
||||||
|
-ms-zoom: 0.75;
|
||||||
|
-moz-transform: scale(0.75);
|
||||||
|
-moz-transform-origin: 0 0;
|
||||||
|
-o-transform: scale(0.75);
|
||||||
|
-o-transform-origin: 0 0;
|
||||||
|
-webkit-transform: scale(0.75);
|
||||||
|
-webkit-transform-origin: 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
.p-h1 {
|
.p-h1 {
|
||||||
font-family: anisha;
|
font-family: anisha;
|
||||||
font-size: 3em;
|
font-size: 3em;
|
||||||
|
Loading…
Reference in New Issue
Block a user