From 73442b212cf6fcf2d2efa892567bd4323a27589a Mon Sep 17 00:00:00 2001 From: DutchEllie Date: Tue, 15 Mar 2022 14:12:15 +0100 Subject: [PATCH] Updater --- src/header.go | 7 ++++++- src/updater.go | 19 +++++++++++++++---- test-website/base.html | 8 +++++++- web/static/images/hot1.gif | Bin 0 -> 384 bytes web/static/style.css | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 web/static/images/hot1.gif diff --git a/src/header.go b/src/header.go index af6edd7..1a1e590 100644 --- a/src/header.go +++ b/src/header.go @@ -7,5 +7,10 @@ type header struct { } func (h *header) Render() app.UI { - return app.Div().Text("Internetica Galactica").Class("header") + return app.Div(). + Class("header"). + Body( + app.Text("Internetica Galactica"), + &updater{}, + ) } diff --git a/src/updater.go b/src/updater.go index c721ef4..445767c 100644 --- a/src/updater.go +++ b/src/updater.go @@ -8,16 +8,27 @@ type updater struct { updateAvailable bool } -func (u *updater) onAppUpdate(ctx app.Context) { +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().Body( - app.P().Text("An update for this website is available! Please click here to reload!"), - ).Styles(map[string]string{"position": "absolute", "width": "100px", "bottom": "10px", "right": "10px"}).OnClick(u.onUpdateClick), + 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) + }), ), ) } diff --git a/test-website/base.html b/test-website/base.html index 4658f71..db0adac 100644 --- a/test-website/base.html +++ b/test-website/base.html @@ -4,7 +4,7 @@ - + @@ -13,6 +13,12 @@
Internetica Galactica +
+ +

+ An update is available! Click here to reload! +

+