proper-website-2/src/navbar.go

54 lines
1.1 KiB
Go
Raw Normal View History

2022-03-15 12:48:47 +01:00
package main
2022-03-01 17:07:33 +01:00
import "github.com/maxence-charriere/go-app/v9/pkg/app"
type navbar struct {
app.Compo
2022-05-31 10:22:29 +02:00
updateAvailable bool
2022-03-01 17:07:33 +01:00
2022-03-07 13:05:33 +01:00
OnClickButton func(page string)
2022-03-01 17:07:33 +01:00
}
2022-05-31 10:22:29 +02:00
func (n *navbar) OnAppUpdate(ctx app.Context) {
n.updateAvailable = ctx.AppUpdateAvailable()
}
2022-03-01 17:07:33 +01:00
func (n *navbar) Render() app.UI {
return app.Div().Body(
app.Ul().Body(
app.Li().Body(
app.A().Href("/").Text("Home"),
),
app.Li().Body(
app.A().Href("/about").Text("About"),
),
2022-03-07 13:05:33 +01:00
app.Li().Body(
app.A().Href("/galaxies").Text("Galaxies"),
2022-03-07 13:05:33 +01:00
),
2022-04-19 22:30:47 +02:00
app.Li().Body(
app.A().Href("/music").Text("Music"),
),
2022-03-27 16:50:48 +02:00
// Disabled for now since there are none anyway
2022-03-24 13:25:07 +01:00
app.Li().Body(
app.A().Href("/blog").Text("Blog"),
2022-03-27 16:50:48 +02:00
).Style("display", "none"),
2022-03-01 17:07:33 +01:00
),
2022-05-31 10:22:29 +02:00
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),
),
2022-03-01 17:07:33 +01:00
).Class("navbar")
}
2022-05-31 10:22:29 +02:00
func (n *navbar) onUpdateClick(ctx app.Context, e app.Event) {
ctx.Reload()
}