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

merging two style instance should give a style instance #4706

Merged
merged 3 commits into from
Jan 28, 2025
Merged
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
12 changes: 12 additions & 0 deletions reflex/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,18 @@ def __setitem__(self, key: str, value: Any):
)
super().__setitem__(key, value)

def __or__(self, other: Style | dict) -> Style:
"""Combine two styles.

Args:
other: The other style to combine.

Returns:
The combined style.
"""
_var_data = VarData.merge(self._var_data, getattr(other, "_var_data", None))
return Style(super().__or__(self, other), _var_data=_var_data) # pyright: ignore [reportGeneralTypeIssues, reportCallIssue]


def _format_emotion_style_pseudo_selector(key: str) -> str:
"""Format a pseudo selector for emotion CSS-in-JS.
Expand Down