Skip to content

Commit

Permalink
implement number-keys to navigate all over the site
Browse files Browse the repository at this point in the history
  • Loading branch information
krustowski committed Aug 28, 2024
1 parent d6f806d commit c0e0338
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
#

APP_NAME=litter-go
APP_VERSION=0.38.7
APP_VERSION=0.38.8
GOLANG_VERSION=1.23
2 changes: 1 addition & 1 deletion api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"name": "MIT",
"url": "https://github.com/krustowski/litter-go/blob/master/LICENSE"
},
"version": "0.38.7"
"version": "0.38.8"
},
"host": "littr.eu",
"basePath": "/api/v1",
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/router.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @title litter-go
// @version 0.38.7
// @version 0.38.8
// @description nanoblogging platform as PWA built on go-app framework
// @termsOfService https://littr.eu/tos

Expand Down
2 changes: 1 addition & 1 deletion pkg/frontend/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ func (c *flowContent) Render() app.UI {
),

app.Div().Class("small-padding").Body(
app.Button().Class("border black white-text bold").Style("border-radius", "8px").OnClick(c.onClickRefresh).Disabled(c.postButtonsDisabled).Body(
app.Button().Title("refresh flow [r]").Class("border black white-text bold").Style("border-radius", "8px").OnClick(c.onClickRefresh).Disabled(c.postButtonsDisabled).Body(
app.If(c.refreshClicked,
app.Progress().Class("circle deep-orange-border small"),
),
Expand Down
34 changes: 28 additions & 6 deletions pkg/frontend/navbars.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,28 @@ func (h *header) onKeyDown(ctx app.Context, e app.Event) {
ctx.NewAction("dismiss-general")
return
}

var authGranted bool
ctx.LocalStorage().Get("authGranted", &authGranted)

if !authGranted {
return
}

switch e.Get("key").String() {
case "1":
ctx.Navigate("/stats")
case "2":
ctx.Navigate("/users")
case "3":
ctx.Navigate("/post")
case "4":
ctx.Navigate("/polls")
case "5":
ctx.Navigate("/flow")
case "6":
ctx.Navigate("/settings")
}
}

func (h *header) onMessage(ctx app.Context, e app.Event) {
Expand Down Expand Up @@ -353,7 +375,7 @@ func (h *header) Render() app.UI {
return app.Nav().ID("nav-top").Class("top fixed-top center-align").Style("opacity", "1.0").
//Style("background-color", navbarColor).
Body(
app.A().Href(settingsHref).Text("settings").Class("max").Title("settings").Aria("label", "settings").Body(
app.A().Href(settingsHref).Text("settings").Class("max").Title("settings [6]").Aria("label", "settings").Body(
app.I().Class("large").Class("deep-orange-text").Body(
app.Text("build")),
),
Expand Down Expand Up @@ -527,27 +549,27 @@ func (f *footer) Render() app.UI {

return app.Nav().ID("nav-top").Class("bottom fixed-top center-align").Style("opacity", "1.0").
Body(
app.A().Href(statsHref).Text("stats").Class("max").Title("stats").Aria("label", "stats").Body(
app.A().Href(statsHref).Text("stats").Class("max").Title("stats [1]").Aria("label", "stats").Body(
app.I().Class("large deep-orange-text").Body(
app.Text("query_stats")),
),

app.A().Href(usersHref).Text("users").Class("max").Title("users").Aria("label", "users").Body(
app.A().Href(usersHref).Text("users").Class("max").Title("users [2]").Aria("label", "users").Body(
app.I().Class("large deep-orange-text").Body(
app.Text("group")),
),

app.A().Href(postHref).Text("post").Class("max").Title("new post/poll").Aria("label", "new post/poll").Body(
app.A().Href(postHref).Text("post").Class("max").Title("new post/poll [3]").Aria("label", "new post/poll").Body(
app.I().Class("large deep-orange-text").Body(
app.Text("add")),
),

app.A().Href(pollsHref).Text("polls").Class("max").Title("polls").Aria("label", "polls").Body(
app.A().Href(pollsHref).Text("polls").Class("max").Title("polls [4]").Aria("label", "polls").Body(
app.I().Class("large deep-orange-text").Body(
app.Text("equalizer")),
),

app.A().Href(flowHref).Text("flow").Class("max").Title("flow").Aria("label", "flow").Body(
app.A().Href(flowHref).Text("flow").Class("max").Title("flow [5]").Aria("label", "flow").Body(
app.I().Class("large deep-orange-text").Body(
app.Text("tsunami")),
),
Expand Down

0 comments on commit c0e0338

Please sign in to comment.