Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pcweb/pages/docs/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def render_select(prop: PropDocumentation, component: type[Component], prop_dict
for arg in type_.__args__
if get_origin(arg) is Literal
for lit_arg in arg.__args__
if str(lit_arg) != ""
]
option = literal_values[0]
name = get_id(f"{component.__qualname__}_{prop.name}")
Expand All @@ -144,8 +145,9 @@ def render_select(prop: PropDocumentation, component: type[Component], prop_dict
value=var,
on_change=setter,
)
# Get the first option.
option = type_.__args__[0]
# Get the first non-empty option.
non_empty_args = [a for a in type_.__args__ if str(a) != ""]
option = non_empty_args[0] if non_empty_args else type_.__args__[0]
name = get_id(f"{component.__qualname__}_{prop.name}")
PropDocsState.add_var(name, str, option)
var = getattr(PropDocsState, name)
Expand Down Expand Up @@ -186,6 +188,7 @@ def render_select(prop: PropDocumentation, component: type[Component], prop_dict
class_name="relative shrink-0 rounded-md size-8 cursor-pointer",
)
for color in list(map(str, type_.__args__))
if color != ""
],
columns="6",
spacing="3",
Expand All @@ -208,6 +211,7 @@ def render_select(prop: PropDocumentation, component: type[Component], prop_dict
),
)
for item in list(map(str, type_.__args__))
if item != ""
]
),
),
Expand Down
Loading
Loading