# check out https://solara.dev/ for documentation
# or https://github.com/widgetti/solara/
# And check out https://py.cafe/maartenbreddels for more examples
# based on https://vuejs.org/guide/built-ins/transition
import solara
from pathlib import Path
clicks = solara.reactive(0)
@solara.component_vue("transition.vue")
def Transition(show_first=True, children=[], name="", mode="out-in"):
pass # just a dummy function
@solara.component
def Page():
print("The component render function gets called")
# change this code, and see the output refresh
color = "green"
if clicks.value >= 5:
color = "red"
def increment():
clicks.value += 1
print("clicks", clicks) # noqa
solara.Button(label=f"Clicked: {clicks}", on_click=increment, color=color)
solara.Style(Path("fade.css"))
with Transition(show_first=(clicks.value % 2) == 0, name="slide-fade"):
solara.Success("Even")
solara.Error("Odd")