Skip to content

Commit

Permalink
Estados por componente
Browse files Browse the repository at this point in the history
  • Loading branch information
mouredev committed Feb 23, 2024
1 parent 7601e04 commit dfe52c4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 28 deletions.
8 changes: 2 additions & 6 deletions link_bio/link_bio/pages/courses.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,15 @@
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(
utils.lang(),
navbar(),
rx.center(
rx.vstack(
header(
False,
live_status=PageState.live_status
),
header(False),
courses_links(),
sponsors(),
max_width=styles.MAX_WIDTH,
Expand Down
13 changes: 3 additions & 10 deletions link_bio/link_bio/pages/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,22 @@
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(
utils.lang(),
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%",
Expand Down
18 changes: 10 additions & 8 deletions link_bio/link_bio/views/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
)


Expand Down
10 changes: 6 additions & 4 deletions link_bio/link_bio/views/index_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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"],
Expand Down Expand Up @@ -107,4 +108,5 @@ def index_links(featured: list[Featured]) -> rx.Component:
),
width="100%",
spacing=Spacing.DEFAULT.value,
on_mount=PageState.featured_links
)

0 comments on commit dfe52c4

Please sign in to comment.