-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable css props via wrapperStyle for recharts components (#4447)
- Loading branch information
Showing
2 changed files
with
2 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters