Skip to content

Commit

Permalink
enable css props via wrapperStyle for recharts components (#4447)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lendemor authored Dec 2, 2024
1 parent 39cdce6 commit a320d06
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
16 changes: 2 additions & 14 deletions reflex/components/recharts/recharts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,15 @@
from typing import Dict, Literal

from reflex.components.component import Component, MemoizationLeaf, NoSSRComponent
from reflex.utils import console


class Recharts(Component):
"""A component that wraps a recharts lib."""

library = "[email protected]"

def render(self) -> Dict:
"""Render the tag.
Returns:
The rendered tag.
"""
tag = super().render()
if any(p.startswith("css") for p in tag["props"]):
console.warn(
f"CSS props do not work for {self.__class__.__name__}. Consult docs to style it with its own prop."
)
tag["props"] = [p for p in tag["props"] if not p.startswith("css")]
return tag
def _get_style(self) -> Dict:
return {"wrapperStyle": self.style}


class RechartsCharts(NoSSRComponent, MemoizationLeaf):
Expand Down
1 change: 0 additions & 1 deletion reflex/components/recharts/recharts.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ from reflex.style import Style
from reflex.vars.base import Var

class Recharts(Component):
def render(self) -> Dict: ...
@overload
@classmethod
def create( # type: ignore
Expand Down

0 comments on commit a320d06

Please sign in to comment.