Skip to content

Commit

Permalink
fix interactive demo (#831)
Browse files Browse the repository at this point in the history
* fix interactive demo

* simplify
  • Loading branch information
carlosabadia authored Jul 29, 2024
1 parent 35cf11a commit 135cd70
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions pcweb/pages/docs/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,11 +794,9 @@ def generate_props(src, component, comp):
padding_left = "1em"

prop_dict = {}
try:
if f"{component.__name__}" in comp.metadata:
comp = eval(comp.metadata[component.__name__])(**prop_dict)

elif not rx.utils.types._issubclass(
is_interactive = True
if not rx.utils.types._issubclass(
component, (RadixThemesComponent, RadixPrimitiveComponent)
) or component.__name__ in [
"Theme",
Expand All @@ -810,6 +808,23 @@ def generate_props(src, component, comp):
"DrawerContent",
"DrawerClose",
]:
is_interactive = False

body = rx.table.body(
*[
rx.table.row(
*prop_docs(prop, prop_dict, component, is_interactive), align="center"
)
for prop in src.get_props()
if not prop.name.startswith("on_") # ignore event trigger props
]
)

try:
if f"{component.__name__}" in comp.metadata:
comp = eval(comp.metadata[component.__name__])(**prop_dict)

elif not is_interactive:
comp = rx.fragment()

else:
Expand All @@ -823,17 +838,6 @@ def generate_props(src, component, comp):
print(f"Failed to create component {component.__name__}, error: {e}")
comp = rx.fragment()

is_interactive = True
if isinstance(comp, Fragment):
is_interactive = False

body = rx.table.body(
*[
rx.table.row(*prop_docs(prop, prop_dict, component, is_interactive), align="center")
for prop in src.get_props()
if not prop.name.startswith("on_") # ignore event trigger props
]
)
return rx.vstack(
docdemobox(comp) if not isinstance(comp, Fragment) else "",
rx.scroll_area(
Expand Down

0 comments on commit 135cd70

Please sign in to comment.