state.py 510 B

12345678910111213141516171819202122
  1. """Base state for the app."""
  2. import reflex as rx
  3. class State(rx.State):
  4. """State for the app."""
  5. sidebar_displayed: bool = True
  6. @rx.var
  7. def origin_url(self) -> str:
  8. """Get the url of the current page.
  9. Returns:
  10. str: The url of the current page.
  11. """
  12. return self.router_data.get("asPath", "")
  13. def toggle_sidebar_displayed(self) -> None:
  14. """Toggle the sidebar displayed."""
  15. self.sidebar_displayed = not self.sidebar_displayed