Support multiple styles for components ()

This commit is contained in:
Dong-hyeon Shin 2023-01-29 02:21:36 +09:00 committed by GitHub
parent f22c67e48c
commit 5427dd0f5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -130,9 +130,14 @@ class Component(Base, ABC):
del kwargs[key]
# Add style props to the component.
style = kwargs.get("style", {})
if isinstance(style, List):
# Merge styles, the later ones overriding keys in the earlier ones.
style = {k: v for style_dict in style for k, v in style_dict.items()}
kwargs["style"] = Style(
{
**kwargs.get("style", {}),
**style,
**{attr: value for attr, value in kwargs.items() if attr not in fields},
}
)