diff --git a/link_bio/link_bio/pages/courses.py b/link_bio/link_bio/pages/courses.py index 47fa5af7..974c05f0 100644 --- a/link_bio/link_bio/pages/courses.py +++ b/link_bio/link_bio/pages/courses.py @@ -16,8 +16,7 @@ title=utils.courses_title, description=utils.courses_description, image=utils.preview, - meta=utils.courses_meta, - on_load=PageState.check_live + meta=utils.courses_meta ) def courses() -> rx.Component: return rx.box( @@ -25,10 +24,7 @@ def courses() -> rx.Component: navbar(), rx.center( rx.vstack( - header( - False, - live_status=PageState.live_status - ), + header(False), courses_links(), sponsors(), max_width=styles.MAX_WIDTH, diff --git a/link_bio/link_bio/pages/index.py b/link_bio/link_bio/pages/index.py index 87cb0349..55cf035a 100644 --- a/link_bio/link_bio/pages/index.py +++ b/link_bio/link_bio/pages/index.py @@ -7,15 +7,13 @@ from link_bio.views.index_links import index_links from link_bio.views.sponsors import sponsors from link_bio.styles.styles import Size -from link_bio.state.PageState import PageState @rx.page( title=utils.index_title, description=utils.index_description, image=utils.preview, - meta=utils.index_meta, - # on_load=[PageState.featured_links] + meta=utils.index_meta ) def index() -> rx.Component: return rx.box( @@ -23,13 +21,8 @@ def index() -> rx.Component: navbar(), rx.center( rx.vstack( - header( - live_status=PageState.live_status, - next_live=PageState.next_live - ), - rx.button("Prueba", on_mount=PageState.check_live), - rx.button("Prueba2", on_mount=PageState.featured_links), - index_links(PageState.featured_info), + header(), + index_links(), sponsors(), max_width=styles.MAX_WIDTH, width="100%", diff --git a/link_bio/link_bio/views/header.py b/link_bio/link_bio/views/header.py index 2c6691a4..a957d348 100644 --- a/link_bio/link_bio/views/header.py +++ b/link_bio/link_bio/views/header.py @@ -8,19 +8,20 @@ from link_bio.components.link_icon import link_icon from link_bio.components.info_text import info_text from link_bio.components.link_button import link_button +from link_bio.state.PageState import PageState -def header(details=True, live_status=Live(live=False, title=""), next_live="") -> rx.Component: +def header(details=True) -> rx.Component: return rx.vstack( rx.hstack( rx.box( rx.cond( - live_status.live, + PageState.live_status.live, rx.link( rx.image( src="/icons/twitch.svg", - height=Size.LARGE.value, - width=Size.LARGE.value + height=Size.DEFAULT.value, + width=Size.DEFAULT.value ), href=const.TWITCH_URL, is_external=True, @@ -114,19 +115,19 @@ def header(details=True, live_status=Live(live=False, title=""), next_live="") - width="100%" ), rx.cond( - live_status.live, + PageState.live_status.live, link_button( "En directo", - live_status.title, + PageState.live_status.title, "/icons/twitch.svg", const.TWITCH_URL, highlight_color=Color.PURPLE.value ), rx.cond( - next_live, + PageState.next_live, link_button( "Próximo directo", - next_live, + PageState.next_live, "/icons/twitch.svg", const.TWITCH_URL, highlight_color=Color.PURPLE.value @@ -150,6 +151,7 @@ def header(details=True, live_status=Live(live=False, title=""), next_live="") - width="100%", spacing=Spacing.BIG.value, align_items="start", + on_mount=PageState.check_live ) diff --git a/link_bio/link_bio/views/index_links.py b/link_bio/link_bio/views/index_links.py index fdf1fde7..5f35552a 100644 --- a/link_bio/link_bio/views/index_links.py +++ b/link_bio/link_bio/views/index_links.py @@ -5,10 +5,11 @@ from link_bio.routes import Route from link_bio.components.link_button import link_button from link_bio.components.title import title -from link_bio.styles.styles import Size, Color, Spacing +from link_bio.styles.styles import Color, Spacing +from link_bio.state.PageState import PageState -def index_links(featured: list[Featured]) -> rx.Component: +def index_links() -> rx.Component: return rx.vstack( title("Comunidad"), link_button( @@ -45,12 +46,12 @@ def index_links(featured: list[Featured]) -> rx.Component: ), rx.cond( - featured, + PageState.featured_info, rx.vstack( title("Destacado"), rx.flex( rx.foreach( - featured, + PageState.featured_info, featured_link ), flex_direction=["column", "row"], @@ -107,4 +108,5 @@ def index_links(featured: list[Featured]) -> rx.Component: ), width="100%", spacing=Spacing.DEFAULT.value, + on_mount=PageState.featured_links )