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(). return newPage().
Title("About me"). Title("About me").
LeftBar( LeftBar(
&bannerPanel{}, newHTMLBlock().
Class("left").
Class("leftbarblock").
Src("/web/blocks/snippets/bannerpanel.html"),
). ).
Main( Main(
newHTMLBlock(). newHTMLBlock().
Class("right"). Class("right").
Class("contentblock").
Src("/web/blocks/pages/about.html"), Src("/web/blocks/pages/about.html"),
) )
} }

View File

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

View File

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

View File

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

View File

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

View File

View File

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