Pass down themes for rx.cond
and rx.match
(#2432)
This commit is contained in:
parent
11f6d7ccef
commit
3a97a10d92
@ -59,10 +59,10 @@ class Cond(MemoizationLeaf):
|
||||
)
|
||||
|
||||
def _get_props_imports(self):
|
||||
"""Get the imports needed for components props.
|
||||
"""Get the imports needed for component's props.
|
||||
|
||||
Returns:
|
||||
The imports for the components props of the component.
|
||||
The imports for the component's props of the component.
|
||||
"""
|
||||
return []
|
||||
|
||||
@ -100,6 +100,15 @@ class Cond(MemoizationLeaf):
|
||||
_IS_TRUE_IMPORT,
|
||||
)
|
||||
|
||||
def _apply_theme(self, theme: Component):
|
||||
"""Apply the theme to this component.
|
||||
|
||||
Args:
|
||||
theme: The theme to apply.
|
||||
"""
|
||||
self.comp1.apply_theme(theme) # type: ignore
|
||||
self.comp2.apply_theme(theme) # type: ignore
|
||||
|
||||
|
||||
@overload
|
||||
def cond(condition: Any, c1: Component, c2: Any) -> Component:
|
||||
|
@ -270,3 +270,18 @@ class Match(MemoizationLeaf):
|
||||
super()._get_imports(),
|
||||
getattr(self.cond._var_data, "imports", {}),
|
||||
)
|
||||
|
||||
def _apply_theme(self, theme: Component):
|
||||
"""Apply the theme to this component.
|
||||
|
||||
Args:
|
||||
theme: The theme to apply.
|
||||
"""
|
||||
# apply theme to return components.
|
||||
for match_case in self.match_cases:
|
||||
if isinstance(match_case[-1], Component):
|
||||
match_case[-1].apply_theme(theme)
|
||||
|
||||
# apply theme to default component
|
||||
if isinstance(self.default, Component):
|
||||
self.default.apply_theme(theme)
|
||||
|
Loading…
Reference in New Issue
Block a user