Updater
continuous-integration/drone/push Build is passing Details

This commit is contained in:
DutchEllie 2022-03-15 14:12:15 +01:00
parent 0ca691e3ae
commit 73442b212c
Signed by: DutchEllie
SSH Key Fingerprint: SHA256:dKq6ZSgN5E3Viqrw/+xAdf2VdR6hdRGNyrYqXXwfjTY
5 changed files with 64 additions and 6 deletions

View File

@ -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{},
)
}

View File

@ -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)
}),
),
)
}

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="static/style.css">
<link rel="stylesheet" href="../web/static/style.css">
<link rel="stylesheet" href="static/anisha.css?family=anisha">
<link rel="stylesheet" href="static/adreena.css?family=adreena">
<link rel="stylesheet" href="static/havakana.css?family=havakana">
@ -13,6 +13,12 @@
<body>
<div class="header">
Internetica Galactica
<div class="update-box">
<img src="/web/static/images/hot1.gif" alt="" height="50px" style="" class="pulsing">
<p class="update-message">
An update is available! Click here to reload!
</p>
</div>
</div>
<div class="main">
<div class="navbar">

BIN
web/static/images/hot1.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 B

View File

@ -22,6 +22,15 @@ body {
font-size: 5em;
font-family: anisha;
text-align: center;
height: 100%;
}
.update-box {
position:absolute;
max-width: 100px;
top: 0px;
right: 0px;
font-size: 0.8rem;
}
.main {
@ -246,6 +255,33 @@ div.comment-message p{
margin-bottom: 5px;
}
.update-message {
font-family: havakana;
margin-top: 0px;
}
.pulsing {
animation-name: pulsing;
animation-duration: 0.4s;
animation-timing-function: ease-out;
animation-direction: alternate;
animation-iteration-count: infinite;
animation-play-state: running;
}
@keyframes pulsing {
0% {
transform: scale(.7);
}
50% {
}
100% {
transform: scale(1.5);
}
}
/*Margin top 5px*/
.m-t5 {
margin-top: 5px;