Skip to content

Commit

Permalink
add tooltips for easier first time use (#51)
Browse files Browse the repository at this point in the history
* add tooltips for easier first time use

* change typing to bool or str

* change type hint and simplify code for adding tooltip
  • Loading branch information
rmblau authored Dec 31, 2024
1 parent c5a1e4f commit a674446
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions beaverhabits/frontend/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ def compat_menu(name: str, callback: Callable):
return ui.menu_item(name, callback).props("dense").classes("items-center")


def menu_icon_button(icon_name: str, click: Optional[Callable] = None) -> Button:
def menu_icon_button(icon_name: str, click: Optional[Callable] = None, tooltip: str | None = None) -> Button:
button_props = "flat=true unelevated=true padding=xs backgroup=none"
return ui.button(icon=icon_name, color=None, on_click=click).props(button_props)
button = ui.button(icon=icon_name, color=None, on_click=click).props(button_props)
if tooltip:
button = button.tooltip(tooltip)
return button


class HabitCheckBox(ui.checkbox):
Expand Down
4 changes: 2 additions & 2 deletions beaverhabits/frontend/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def layout(title: str | None = None, with_menu: bool = True):
if with_menu:
ui.space()
if "order" in path:
menu_icon_button(icons.ADD, click=lambda: redirect("add"))
menu_icon_button(icons.ADD, click=lambda: redirect("add"), tooltip="Add Habits")
if "add" in path:
menu_icon_button("drag_indicator", click=lambda: redirect("order"))
menu_icon_button("drag_indicator", click=lambda: redirect("order"), tooltip="Reorder habits")
with menu_icon_button(icons.MENU):
menu_component(root_path)

Expand Down

0 comments on commit a674446

Please sign in to comment.