Accordion Root Exclude color_scheme and variant props in tag (#2664)

* Accordion Root Exclude `color_scheme` and `variant` props in tag

* colorScheme -> color for radix primitives

* remove _rename_props based on pr comments

* lint

* pyi fix

* pop instead of del
This commit is contained in:
Elijah Ahianyo 2024-02-20 17:57:01 +00:00 committed by GitHub
parent 6384c62e51
commit eeff4142ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 0 deletions

View File

@ -502,6 +502,14 @@ class Component(BaseComponent, ABC):
if isinstance(child, Component):
child.apply_theme(theme)
def _exclude_props(self) -> list[str]:
"""Props to exclude when adding the component props to the Tag.
Returns:
A list of component props to exclude.
"""
return []
def _render(self, props: dict[str, Any] | None = None) -> Tag:
"""Define how to render the component in React.
@ -544,6 +552,10 @@ class Component(BaseComponent, ABC):
props.update(self._get_style())
props.update(self.custom_attrs)
# remove excluded props from prop dict before adding to tag.
for prop_to_exclude in self._exclude_props():
props.pop(prop_to_exclude, None)
return tag.add_props(**props)
@classmethod

View File

@ -463,6 +463,9 @@ to {
`
"""
def _exclude_props(self) -> list[str]:
return ["color_scheme", "variant"]
class AccordionItem(AccordionComponent):
"""An accordion component."""