Add update button
continuous-integration/drone/push Build is passing Details
continuous-integration/drone Build is passing Details

This commit is contained in:
DutchEllie 2022-05-31 10:22:29 +02:00
parent 67358d1616
commit acba8179fb
Signed by: DutchEllie
SSH Key Fingerprint: SHA256:dKq6ZSgN5E3Viqrw/+xAdf2VdR6hdRGNyrYqXXwfjTY
2 changed files with 36 additions and 5 deletions

View File

@ -4,10 +4,15 @@ import "github.com/maxence-charriere/go-app/v9/pkg/app"
type navbar struct {
app.Compo
updateAvailable bool
OnClickButton func(page string)
}
func (n *navbar) OnAppUpdate(ctx app.Context) {
n.updateAvailable = ctx.AppUpdateAvailable()
}
func (n *navbar) Render() app.UI {
return app.Div().Body(
app.Ul().Body(
@ -28,5 +33,21 @@ func (n *navbar) Render() app.UI {
app.A().Href("/blog").Text("Blog"),
).Style("display", "none"),
),
app.If(n.updateAvailable,
app.Div().Body(
app.Img().
Src("/web/static/images/hot1.gif").
Class("update-img"),
app.Span().
Text("Update available! Click here to update!").
Class("update-text"),
).
Class("update-div").
OnClick(n.onUpdateClick),
),
).Class("navbar")
}
func (n *navbar) onUpdateClick(ctx app.Context, e app.Event) {
ctx.Reload()
}

View File

@ -35,12 +35,22 @@ body {
height: 100%;
}
.update-box {
position:absolute;
max-width: 100px;
top: 0px;
right: 0px;
.update-div {
font-size: 0.8rem;
display: flex;
}
.update-div:hover {
cursor: pointer;
}
.update-text {
align-self: center;
flex: 70%;
}
.update-img {
flex: 30%;
}
.main {