From acba8179fba18d3c0e004cb252ccce9b1eab7588 Mon Sep 17 00:00:00 2001 From: DutchEllie Date: Tue, 31 May 2022 10:22:29 +0200 Subject: [PATCH] Add update button --- src/navbar.go | 21 +++++++++++++++++++++ web/static/style.css | 20 +++++++++++++++----- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/navbar.go b/src/navbar.go index bb15476..a320e89 100644 --- a/src/navbar.go +++ b/src/navbar.go @@ -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() +} diff --git a/web/static/style.css b/web/static/style.css index 76d221c..8b942ad 100644 --- a/web/static/style.css +++ b/web/static/style.css @@ -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 {