class Billing(PageState):
period: str = field(default="yearly")
def period_changed(billing: Billing) -> None:
"""The typed parameter receives the picked period; the price follows."""
@refreshable(deps=[Billing])
def plan_price() -> None:
period = Billing().period
with ui.hstack(gap="sm", align="end"):
ui.heading(f"€{PRICES[period]}", level=3, size="3xl")
ui.text("per seat / month", color="muted")
if period == "yearly":
ui.badge("You save €60 per seat each year", color="success", variant="soft")
else:
ui.badge("Cancel any time", color="secondary", variant="soft")
def billing_period() -> None:
with ui.card(padding="md", classes="w-full max-w-sm"), ui.vstack(gap="md"):
ui.heading("Team plan", level=3, size="md")
with ui.radio_group(value=Billing().period, on_change=period_changed,
direction="row"):
ui.radio("monthly", label="Monthly")
ui.radio("yearly", label="Yearly")
plan_price()
ui.button("Start free trial", classes="w-full")