Skip to content

Commit 7d0052a

Browse files
author
Piotr Gulbinowicz
committed
add burger menu in root
1 parent 4cd407a commit 7d0052a

File tree

1 file changed

+37
-12
lines changed

1 file changed

+37
-12
lines changed

pwa/flush/components.go

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@ import (
1313
)
1414

1515
const (
16-
YellowButtonCss = "font-bold bg-amber-600 p-2 rounded mx-1"
17-
ErrorDivCss = "flex flex-row fixed bottom-4 left-4 bg-red-500 p-4 text-xl rounded-lg"
18-
CenteringDivCss = "flex flex-row min-h-screen justify-center items-center"
19-
WindowDivCss = "p-4 text-center text-xl shadow-lg bg-zinc-800 rounded-lg mx-10"
20-
InviCss = "fixed invisible"
21-
RootContainerCss = "shadow-lg bg-zinc-800 rounded-lg p-6 min-h-72 relative"
22-
LoadingCss = "flex flex-row justify-center items-center"
23-
RemoveButtonCss = "font-bold bg-red-500 p-2 rounded hover:bg-red-700 m-1"
24-
LogoutButtonCss = "font-bold bg-amber-700 p-2 rounded mx-1 hover:bg-amber-900"
25-
UpdateButtonCss = "bg-green-600 hover:bg-green-800 text-xl p-2 rounded bottom-4 right-4 fixed"
26-
InstallButtonCss = "bg-green-600 hover:bg-green-800 p-2 rounded m-2"
16+
YellowButtonCss = "font-bold bg-amber-600 p-2 rounded mx-1"
17+
ErrorDivCss = "flex flex-row fixed bottom-4 left-4 bg-red-500 p-4 text-xl rounded-lg"
18+
CenteringDivCss = "flex flex-row min-h-screen justify-center items-center"
19+
WindowDivCss = "p-4 text-center text-xl shadow-lg bg-zinc-800 rounded-lg mx-10"
20+
InviCss = "fixed invisible"
21+
RootContainerCss = "shadow-lg bg-zinc-800 rounded-lg p-6 min-h-72 relative"
22+
LoadingCss = "flex flex-row justify-center items-center"
23+
RemoveButtonCss = "font-bold bg-red-500 p-2 rounded hover:bg-red-700 m-1"
24+
LogoutButtonCss = "font-bold bg-orange-600 p-2 rounded mx-1 hover:bg-orange-800"
25+
UpdateButtonCss = "bg-green-600 hover:bg-green-800 text-xl p-2 rounded bottom-4 right-4 fixed"
26+
InstallButtonCss = "bg-green-600 hover:bg-green-800 p-2 rounded m-2"
27+
BurgerMenuButtonCss = "text-xl fixed top-4 right-4"
28+
RootButtonsCss = "flex flex-col absolute top-12 right-4"
2729
)
2830

2931
type ErrorContainer struct {
@@ -132,6 +134,7 @@ func (b *RootContainer) Render() app.UI {
132134
&UpdateButton{},
133135
app.Div().Body(
134136
app.H1().Text("Flush Log").Class("text-2xl"),
137+
&BurgerMenuButton{},
135138
app.Div().Body(
136139
&buttonLogout{},
137140
&LinkButton{
@@ -145,7 +148,7 @@ func (b *RootContainer) Render() app.UI {
145148
AdditionalCss: "hover:bg-amber-800",
146149
},
147150
&InstallButton{},
148-
).ID("root-buttons-container").Class("flex flex-col absolute top-4 right-4"),
151+
).ID("root-buttons-container").Class(InviCss),
149152
app.P().Text("Tracked flushes:").Class("py-2"),
150153
&LoadingWidget{id: "flushes-loading"},
151154
b.FlushList,
@@ -962,3 +965,25 @@ func (b *InstallButton) Render() app.UI {
962965
func (b *InstallButton) onInstallButtonClicked(ctx app.Context, e app.Event) {
963966
ctx.ShowAppInstallPrompt()
964967
}
968+
969+
type BurgerMenuButton struct {
970+
app.Compo
971+
alreadyClicked bool
972+
}
973+
974+
func (b *BurgerMenuButton) Render() app.UI {
975+
return app.Button().
976+
Text("☰").
977+
Class(BurgerMenuButtonCss).
978+
OnClick(b.OnClick).
979+
ID("burger-menu-button")
980+
}
981+
func (b *BurgerMenuButton) OnClick(ctx app.Context, e app.Event) {
982+
if b.alreadyClicked {
983+
b.alreadyClicked = false
984+
app.Window().GetElementByID("root-buttons-container").Set("className", InviCss)
985+
} else {
986+
b.alreadyClicked = true
987+
app.Window().GetElementByID("root-buttons-container").Set("className", RootButtonsCss)
988+
}
989+
}

0 commit comments

Comments
 (0)