Fixed some layout

This commit is contained in:
DutchEllie 2022-03-16 12:49:52 +01:00
parent 44da256e10
commit 858abd350e
Signed by: DutchEllie
SSH Key Fingerprint: SHA256:dKq6ZSgN5E3Viqrw/+xAdf2VdR6hdRGNyrYqXXwfjTY
5 changed files with 2 additions and 258 deletions

View File

@ -1,13 +0,0 @@
package main
import "github.com/maxence-charriere/go-app/v9/pkg/app"
type bannerPanel struct {
app.Compo
}
func (b *bannerPanel) Render() app.UI {
return app.Div().
Class("leftbar").
Body()
}

View File

@ -1,105 +0,0 @@
package main
import (
"fmt"
"github.com/maxence-charriere/go-app/v9/pkg/app"
)
type guestbookForm struct {
app.Compo
name string
message string
gbModalOpen bool
OnSubmit func(
ctx app.Context,
name string,
message string,
) // Handler to implement which calls the api
}
func (g *guestbookForm) Render() app.UI {
return app.Div().Body(
app.Form().Body(
app.Input().
Type("text").
Name("name").
Placeholder("Name").
Required(true).
OnChange(g.ValueTo(&g.name)).
Value(g.name),
app.Input().
Type("text").
Name("message").
Placeholder("Message").
Required(true).
OnChange(g.ValueTo(&g.message)).
Value(g.message),
app.Input().
Type("submit").
Name("submit"),
).ID("form").
OnSubmit(func(ctx app.Context, e app.Event) {
// This was to prevent the page from reloading
e.PreventDefault()
if g.name == "" || g.message == "" {
fmt.Printf("Error: one or more field(s) are empty. For now unhandled\n")
return
}
if len(g.name) > 40 || len(g.message) > 360 {
fmt.Printf("Error: Your message is too long fucker\n")
g.gbModalOpen = true
return
}
g.OnSubmit(ctx, g.name, g.message)
g.clear()
}),
app.If(
g.gbModalOpen,
&guestbookAlertModal{
OnClose: func() {
g.gbModalOpen = false
g.Update()
},
},
),
)
}
func (g *guestbookForm) clear() {
g.name = ""
g.message = ""
}
/*
type guestbookAlertModal struct {
app.Compo
PreviousAttempts int
OnClose func() // For when we close the modal
}
func (g *guestbookAlertModal) Render() app.UI {
return app.Div().
Class("gb-modal").
ID("gbModal").
OnClick(func(ctx app.Context, e app.Event) {
g.OnClose()
}).
Body(
app.Div().
Class("gb-modal-content").
Body(
app.Span().Class("close").Text("X").
OnClick(func(ctx app.Context, e app.Event) {
//modal := app.Window().GetElementByID("gbModal")
//modal.Set("style", "none")
g.OnClose()
}),
app.P().Text("Your name must be <= 40 and your message must be <= 360 characters"),
),
)
}
*/

View File

@ -1,100 +0,0 @@
package main
import (
"encoding/json"
"io"
"net/http"
"dutchellie.nl/DutchEllie/proper-website-2/entity"
"github.com/maxence-charriere/go-app/v9/pkg/app"
)
/*
What is this supposed to do:
- It should call on the API to give it a certain number of comments, in the range x to y (this has to be implemented in the api)
- When it has called that, it should display those
- Dynamic links are there to navigate the user along the pages
- Comments are shown dynamically
- This panel can be shown or hidden (maybe)
AND VERY IMPORTANT!
- If a user submits a new comment, automatically put it on the page, no reloading
*/
type guestbookPanel struct {
app.Compo
comments []entity.Comment
}
func (g *guestbookPanel) OnMount(ctx app.Context) {
g.LoadComments(ctx)
}
func (g *guestbookPanel) OnNav(ctx app.Context) {
g.LoadComments(ctx)
}
func (g *guestbookPanel) OnUpdate(ctx app.Context) {
g.LoadComments(ctx)
}
func (g *guestbookPanel) Render() app.UI {
return app.Div().Body(
app.Range(g.comments).Slice(func(i int) app.UI {
return &guestbookComment{
Comment: g.comments[i],
}
},
),
).OnSubmit(func(ctx app.Context, e app.Event) {
g.LoadComments(ctx)
})
}
func (g *guestbookPanel) LoadComments(ctx app.Context) {
// TODO: maybe you can put this in a localbrowser storage?
url := ApiURL
ctx.Async(func() {
res, err := http.Get(url)
if err != nil {
app.Log(err)
return
}
defer res.Body.Close()
jsondata, err := io.ReadAll(res.Body)
if err != nil {
app.Log(err)
return
}
ctx.Dispatch(func(ctx app.Context) {
err = json.Unmarshal(jsondata, &g.comments)
if err != nil {
app.Log(err)
return
}
})
})
}
/*type guestbookComment struct {
app.Compo
Comment entity.Comment
time string
}
func (c *guestbookComment) Render() app.UI {
c.time = c.Comment.PostDate.Format(time.RFC1123)
return app.Div().Body(
app.Div().Class().Body(
app.P().Text(c.Comment.Name).Class("name"),
app.P().Text(c.time).Class("date"),
).Class("comment-header"),
app.Div().Class("comment-message").Body(
app.P().Text(c.Comment.Message),
),
).Class("comment")
}
*/

View File

@ -1,38 +0,0 @@
package main
import "github.com/maxence-charriere/go-app/v9/pkg/app"
type updater struct {
app.Compo
updateAvailable bool
}
func (u *updater) OnAppUpdate(ctx app.Context) {
u.updateAvailable = ctx.AppUpdateAvailable()
}
func (u *updater) Render() app.UI {
return app.Div().Body(
app.If(u.updateAvailable,
app.Div().
Class("update-box").
Body(
app.Img().
Class("pulsing").
Height(50).
Src("/web/static/images/hot1.gif"),
app.P().
Class("update-message").
Text("An update is available! Click here to reload!"),
).
OnClick(func(ctx app.Context, e app.Event) {
u.onUpdateClick(ctx, e)
}),
),
)
}
func (u *updater) onUpdateClick(ctx app.Context, e app.Event) {
ctx.Reload()
}

View File

@ -20,9 +20,9 @@
</p> </p>
<br> <br>
<p class="content-text"> <p class="content-text">
<img src="/web/static/images/rin-2.gif" alt="Kagamine Rin drawing" style="float:left; width:100px; margin-right: 10px;"> <img src="/web/static/images/rin-2.gif" alt="Kagamine Rin drawing" style="float:left; width:100px; margin-right: 20px;">
There is a lot of stuff I want to add to this website! In fact, there is also a "staging" website, which might There is a lot of stuff I want to add to this website! In fact, there is also a "staging" website, which might
contain contain
new features! It can be found at <a href="https://staging.newsite.dutchellie.nl">staging.newsite.dutchellie.nl</a>. new features! It can be found at <a href="https://newsite.staging.dutchellie.nl">newsite.staging.dutchellie.nl</a>.
Don't worry about the invalid SSL certificate, that's normal! Don't worry about the invalid SSL certificate, that's normal!
</p> </p>