From c93b5c2a50ee708dd60f7ead4cbf78243b3ced63 Mon Sep 17 00:00:00 2001 From: Elijah Date: Tue, 24 Oct 2023 16:30:50 +0000 Subject: [PATCH 1/2] Radix Themes style notation fix --- reflex/components/component.py | 10 +++++++++- reflex/components/radix/themes/base.py | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/reflex/components/component.py b/reflex/components/component.py index b9f4ec82e1..ac7e159f9a 100644 --- a/reflex/components/component.py +++ b/reflex/components/component.py @@ -456,6 +456,14 @@ def add_style(self, style: ComponentStyle) -> Component: child.add_style(style) return self + def _get_style(self) -> dict: + """Get the style for the component. + + Returns: + The dictionary of the component style as value and the style notation as key. + """ + return {"sx": self.style} + def render(self) -> Dict: """Render the component. @@ -467,10 +475,10 @@ def render(self) -> Dict: tag.add_props( **self.event_triggers, key=self.key, - sx=self.style, id=self.id, class_name=self.class_name, **self.custom_attrs, + **self._get_style(), ).set( children=[child.render() for child in self.children], contents=str(tag.contents), diff --git a/reflex/components/radix/themes/base.py b/reflex/components/radix/themes/base.py index 07595fe197..d6b1b20859 100644 --- a/reflex/components/radix/themes/base.py +++ b/reflex/components/radix/themes/base.py @@ -65,6 +65,9 @@ def _get_app_wrap_components(self) -> dict[tuple[int, str], Component]: (45, "RadixThemesColorModeProvider"): RadixThemesColorModeProvider.create(), } + def _get_style(self) -> dict: + return {"style": self.style} + class Theme(RadixThemesComponent): """A theme provider for radix components. From 47932f9484dc55779fe782e2b2a1994452b579f8 Mon Sep 17 00:00:00 2001 From: Elijah Ahianyo Date: Tue, 24 Oct 2023 16:52:05 +0000 Subject: [PATCH 2/2] Update reflex/components/component.py Co-authored-by: Masen Furer --- reflex/components/component.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reflex/components/component.py b/reflex/components/component.py index ac7e159f9a..146635e970 100644 --- a/reflex/components/component.py +++ b/reflex/components/component.py @@ -477,8 +477,8 @@ def render(self) -> Dict: key=self.key, id=self.id, class_name=self.class_name, - **self.custom_attrs, **self._get_style(), + **self.custom_attrs, ).set( children=[child.render() for child in self.children], contents=str(tag.contents),