Skip to content

Commit

Permalink
improves hamburger menu
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangFahl committed Nov 15, 2024
1 parent 5aac2f7 commit f67c8a2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ngwidgets/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.19.2"
__version__ = "0.19.3"
2 changes: 1 addition & 1 deletion ngwidgets/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Version:
name = "ngwidgets"
version = ngwidgets.__version__
date = "2023-09-10"
updated = "2024-10-13"
updated = "2024-11-15"
description = "NiceGUI widgets"

authors = "Wolfgang Fahl"
Expand Down
27 changes: 26 additions & 1 deletion ngwidgets/webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,26 +410,51 @@ def do_read_input(self, input_str: str) -> str:
else:
raise Exception(f"File does not exist: {input_str}")

async def toogle_hamburger(self):
"""
toggle the hamburger menu
"""
if not self.header:
return

self.header.toggle()
self.footer.toggle()
self.hamburger_button1.visible=not self.hamburger_button1.visible

def setup_menu(self, detailed: bool = None):
"""
set up the default menu home/settings and about
Args:
detailed(bool): if True add github,chat and help links
"""
self.header=None
version = self.config.version
if detailed is None:
detailed = self.config.detailed_menu
self.config.color_schema.apply()
# parent element for hamburger menu
with ui.element("div").classes("top-0 left-0 z-50 bg-transparent") as self.hamburger_container:
self.hamburger_button1=ui.button(icon="menu", on_click=self.toogle_hamburger)
self.hamburger_button1.visible=False
with ui.header() as self.header:
self.hamburger_button=ui.button(icon="menu", on_click=self.toogle_hamburger)
self.link_button("home", "/", "home", new_tab=False)
self.link_button("settings", "/settings", "settings", new_tab=False)
self.configure_menu()
if detailed:
self.link_button("github", version.cm_url, "bug_report")
self.link_button("chat", version.chat_url, "chat")
self.link_button("help", version.doc_url, "help")
self.link_button("about", "/about", "info", new_tab=False)
self.link_button("about", "/about", "info", new_tab=False)
self.link_button("home", "/", "home", new_tab=False)
self.link_button("settings", "/settings", "settings", new_tab=False)
self.configure_menu()
if detailed:
self.link_button("github", version.cm_url, "bug_report")
self.link_button("chat", version.chat_url, "chat")
self.link_button("help", version.doc_url, "help")
self.link_button("about", "/about", "info", new_tab=False)

async def setup_footer(self):
"""
Expand Down

0 comments on commit f67c8a2

Please sign in to comment.