Layout and refactoring

This commit is contained in:
DutchEllie 2022-03-15 13:22:59 +01:00
parent 03a09fc452
commit 0ca691e3ae
Signed by: DutchEllie
SSH Key Fingerprint: SHA256:dKq6ZSgN5E3Viqrw/+xAdf2VdR6hdRGNyrYqXXwfjTY
7 changed files with 65 additions and 36 deletions

View File

@ -16,11 +16,15 @@ func (a *AboutPage) Render() app.UI {
return newPage().
Title("About me").
LeftBar(
&bannerPanel{},
newHTMLBlock().
Class("left").
Class("leftbarblock").
Src("/web/blocks/snippets/bannerpanel.html"),
).
Main(
newHTMLBlock().
Class("right").
Class("contentblock").
Src("/web/blocks/pages/about.html"),
)
}

View File

@ -14,11 +14,15 @@ func (f *GalaxiesPage) Render() app.UI {
return newPage().
Title("Galaxies").
LeftBar(
&bannerPanel{},
newHTMLBlock().
Class("left").
Class("leftbarblock").
Src("/web/blocks/snippets/bannerpanel.html"),
).
Main(
newHTMLBlock().
Class("right").
Class("contentblock").
Src("/web/blocks/pages/galaxies.html"),
)
}

View File

@ -64,7 +64,7 @@ func (g *guestbookForm) Render() app.UI {
},
},
),
).Class("content")
)
}
func (g *guestbookForm) clear() {

View File

@ -35,15 +35,12 @@ func newGuestbookPanel() *guestbookPanel {
}
func (g *guestbookPanel) Render() app.UI {
return newUIBlock().
Class("right").
UI(
app.Range(g.comments).Slice(func(i int) app.UI {
return &guestbookComment{
Comment: g.comments[i],
}
}),
)
return app.Range(g.comments).Slice(func(i int) app.UI {
return &guestbookComment{
Comment: g.comments[i],
}
},
)
}
func (g *guestbookPanel) LoadComments() {

View File

@ -27,36 +27,50 @@ func (p *Homepage) Render() app.UI {
return newPage().
Title("Homepage").
LeftBar(
&bannerPanel{},
newHTMLBlock().
Class("left").
Class("leftbarblock").
Src("/web/blocks/snippets/bannerpanel.html"),
).
Main(
newHTMLBlock().
Class("right").
Class("contentblock").
Src("/web/blocks/pages/intro.html"),
&guestbookForm{
OnSubmit: func(name, message string) {
var comment entity.Comment
comment.Name = name
comment.Message = message
newUIBlock().
Class("right").
Class("contentblock").
UI(
&guestbookForm{
OnSubmit: func(name, message string) {
var comment entity.Comment
comment.Name = name
comment.Message = message
jsondata, err := json.Marshal(comment)
if err != nil {
fmt.Printf("err: %v\n", err)
return
}
url := ApiURL
jsondata, err := json.Marshal(comment)
if err != nil {
fmt.Printf("err: %v\n", err)
return
}
url := ApiURL
req, err := http.Post(url, "application/json", bytes.NewBuffer(jsondata))
if err != nil {
fmt.Printf("err: %v\n", err)
return
}
if req.StatusCode == 200 {
p.Update()
}
defer req.Body.Close()
},
},
gbp.Render(),
req, err := http.Post(url, "application/json", bytes.NewBuffer(jsondata))
if err != nil {
fmt.Printf("err: %v\n", err)
return
}
if req.StatusCode == 200 {
p.Update()
}
defer req.Body.Close()
},
},
),
newUIBlock().
Class("right").
Class("contentblock").
UI(
gbp.Render(),
),
)
}

View File

View File

@ -74,6 +74,16 @@ body {
background-color: rgb(54, 39, 48);
margin-bottom: 5px;
position: relative;
}
.leftbarblock {
float:left;
width: 250px;
padding: 5px 0px;
}
.contentblock {
float:right;
width: 614px;
padding: 10px;
}