Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radix Themes style notation fix #2025

Merged
merged 2 commits into from
Oct 24, 2023
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
10 changes: 9 additions & 1 deletion reflex/components/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -467,9 +475,9 @@ 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._get_style(),
**self.custom_attrs,
).set(
children=[child.render() for child in self.children],
Expand Down
3 changes: 3 additions & 0 deletions reflex/components/radix/themes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading