|
@@ -2,7 +2,6 @@
|
|
|
|
|
|
from code import styles
|
|
from code import styles
|
|
from code.components.sidebar import sidebar
|
|
from code.components.sidebar import sidebar
|
|
-from code.state import State
|
|
|
|
from typing import Callable
|
|
from typing import Callable
|
|
|
|
|
|
import reflex as rx
|
|
import reflex as rx
|
|
@@ -22,6 +21,8 @@ def menu_button() -> rx.Component:
|
|
Returns:
|
|
Returns:
|
|
The menu button component.
|
|
The menu button component.
|
|
"""
|
|
"""
|
|
|
|
+ from reflex.page import get_decorated_pages
|
|
|
|
+
|
|
return rx.box(
|
|
return rx.box(
|
|
rx.menu(
|
|
rx.menu(
|
|
rx.menu_button(
|
|
rx.menu_button(
|
|
@@ -32,7 +33,16 @@ def menu_button() -> rx.Component:
|
|
),
|
|
),
|
|
),
|
|
),
|
|
rx.menu_list(
|
|
rx.menu_list(
|
|
- rx.menu_item(rx.link("Home", href="/", width="100%")),
|
|
|
|
|
|
+ *[
|
|
|
|
+ rx.menu_item(
|
|
|
|
+ rx.link(
|
|
|
|
+ page["title"],
|
|
|
|
+ href=page["route"],
|
|
|
|
+ width="100%",
|
|
|
|
+ )
|
|
|
|
+ )
|
|
|
|
+ for page in get_decorated_pages()
|
|
|
|
+ ],
|
|
rx.menu_divider(),
|
|
rx.menu_divider(),
|
|
rx.menu_item(
|
|
rx.menu_item(
|
|
rx.link("About", href="https://github.com/reflex-dev", width="100%")
|
|
rx.link("About", href="https://github.com/reflex-dev", width="100%")
|
|
@@ -50,12 +60,24 @@ def menu_button() -> rx.Component:
|
|
|
|
|
|
|
|
|
|
def template(
|
|
def template(
|
|
- **page_kwargs: dict,
|
|
|
|
|
|
+ route: str | None = None,
|
|
|
|
+ title: str | None = None,
|
|
|
|
+ image: str | None = None,
|
|
|
|
+ description: str | None = None,
|
|
|
|
+ meta: str | None = None,
|
|
|
|
+ script_tags: list[rx.Component] | None = None,
|
|
|
|
+ on_load: rx.event.EventHandler | list[rx.event.EventHandler] | None = None,
|
|
) -> Callable[[Callable[[], rx.Component]], rx.Component]:
|
|
) -> Callable[[Callable[[], rx.Component]], rx.Component]:
|
|
"""The template for each page of the app.
|
|
"""The template for each page of the app.
|
|
|
|
|
|
Args:
|
|
Args:
|
|
- page_kwargs: Keyword arguments to pass to the page.
|
|
|
|
|
|
+ route: The route to reach the page.
|
|
|
|
+ title: The title of the page.
|
|
|
|
+ image: The favicon of the page.
|
|
|
|
+ description: The description of the page.
|
|
|
|
+ meta: Additionnal meta to add to the page.
|
|
|
|
+ on_load: The event handler(s) called when the page load.
|
|
|
|
+ script_tags: Scripts to attach to the page.
|
|
|
|
|
|
Returns:
|
|
Returns:
|
|
The template with the page content.
|
|
The template with the page content.
|
|
@@ -71,9 +93,17 @@ def template(
|
|
The template with the page content.
|
|
The template with the page content.
|
|
"""
|
|
"""
|
|
# Get the meta tags for the page.
|
|
# Get the meta tags for the page.
|
|
- page_kwargs["meta"] = [*default_meta, *page_kwargs.get("meta", [])]
|
|
|
|
-
|
|
|
|
- @rx.page(**page_kwargs)
|
|
|
|
|
|
+ all_meta = [*default_meta, *(meta or [])]
|
|
|
|
+
|
|
|
|
+ @rx.page(
|
|
|
|
+ route=route,
|
|
|
|
+ title=title,
|
|
|
|
+ image=image,
|
|
|
|
+ description=description,
|
|
|
|
+ meta=all_meta,
|
|
|
|
+ script_tags=script_tags,
|
|
|
|
+ on_load=on_load,
|
|
|
|
+ )
|
|
def templated_page():
|
|
def templated_page():
|
|
return rx.hstack(
|
|
return rx.hstack(
|
|
sidebar(),
|
|
sidebar(),
|
|
@@ -89,9 +119,6 @@ def template(
|
|
align_items="flex-start",
|
|
align_items="flex-start",
|
|
transition="left 0.5s, width 0.5s",
|
|
transition="left 0.5s, width 0.5s",
|
|
position="relative",
|
|
position="relative",
|
|
- left=rx.cond(
|
|
|
|
- State.sidebar_displayed, "0px", f"-{styles.sidebar_width}"
|
|
|
|
- ),
|
|
|
|
)
|
|
)
|
|
|
|
|
|
return templated_page
|
|
return templated_page
|