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

styles from local css class instead of inline styles or global overrides #2169

Open
gaurav5430 opened this issue Jun 14, 2020 · 3 comments
Open
Labels
bug General bug label enhancement Enhancement to a current API

Comments

@gaurav5430
Copy link

What works:

What does not work:

if at all Recharts can forward the className to the underlying component, a lot of these problems would be solved.
This kind of api is already supported by a lot of libraries. Here is an example of how it could be supported:

then the developer are free to use css-modules or any other setup to create this className, and recharts can just apply this class on the container element of the Line (This would be the same element where "recharts-layer recharts-line line" class in being applied right now.

This kind of requirement was also discussed in #210 (comment)
but the issue was closed without a definitive solution.

It seems that the developers did not want to add css-modules inside recharts. The solution or the setup that I am suggesting does not need css-modules inside Recharts, all that setup can still be in user land. Recharts just has to add the passed in class to the className for the rendered element

@DesignByOnyx
Copy link

Came here looking for a similar thing, but discovered that classes are attached on some of the elements: BarChart, Label and Bar get class names. The xAxis and yAxis already get classNames that you can target. You can also render a <style> tag inside of BarChart, and for "ticks" you can render custom svg elements and give them class names too.

@gaurav5430
Copy link
Author

gaurav5430 commented Jun 16, 2020

oh ok, good to see that some components accept className.

The xAxis and yAxis already get classNames that you can target

Yes, but these need to be too specific to target and can't be scoped with something like css-modules

You can also render a <style> tag inside of BarChart

That would still be inline css, but good to know.

and for "ticks" you can render custom svg elements and give them class names too

Agreed, it is possible to do this for any elements we can/ want to customize, Labels/Tooltips/shape etc.

All in all, what i want to do is possible in some cases, either because Recharts supports that api for some components, or because we can pass in a custom component, but this is still not possible to style a lot of existing components using scoped classNames

@timtucker timtucker mentioned this issue Mar 17, 2021
1 task
@ckifer ckifer added bug General bug label enhancement Enhancement to a current API labels Mar 28, 2024
@ckifer
Copy link
Member

ckifer commented Mar 28, 2024

There's been quite a few fixes of these since last post here. I think next patch release should update another ~3 as well just for an update. There still are probably some hiding

renovate bot added a commit to SAP/ui5-webcomponents-react that referenced this issue Apr 8, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [recharts](https://togithub.com/recharts/recharts) | [`2.12.3` ->
`2.12.4`](https://renovatebot.com/diffs/npm/recharts/2.12.3/2.12.4) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/recharts/2.12.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/recharts/2.12.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/recharts/2.12.3/2.12.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/recharts/2.12.3/2.12.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>recharts/recharts (recharts)</summary>

###
[`v2.12.4`](https://togithub.com/recharts/recharts/releases/tag/v2.12.4)

[Compare
Source](https://togithub.com/recharts/recharts/compare/v2.12.3...v2.12.4)

#### What's Changed

Small fixes while working on v3 continued...

##### Fix

- `Accessibility`: remove role attribute from recharts-wrapper which
caused an accessibility violation with > 1 chart on the same page by
[@&#8203;julianna-langston](https://togithub.com/julianna-langston) in
[recharts/recharts#4386,
fixes [#&#8203;4384](https://togithub.com/recharts/recharts/issues/4384)
- `X/YAxis`: fix incorrect padding calculation when there is 1 datapoint
or less by [@&#8203;graup](https://togithub.com/graup) in
[recharts/recharts#4314
closes
[#&#8203;4313](https://togithub.com/recharts/recharts/issues/4313)

`className` fixes - helps slowly address
[recharts/recharts#2169:

- `Tooltip`: allow custom `className` on `cursor` by
[@&#8203;108yen](https://togithub.com/108yen) in
[recharts/recharts#4306
- `RadarChart/RadialBarChart`: allow custom `className` on
`PolarRadiusAxis`, `PolarAngleAxis`, and `Radar` dot by
[@&#8203;108yen](https://togithub.com/108yen) in
[recharts/recharts#4335
- `Pie`: allow custom `className` on `label` and `labelLine` of `Pie` by
[@&#8203;108yen](https://togithub.com/108yen) in
[recharts/recharts#4381

**Full Changelog**:
recharts/recharts@v2.12.3...v2.12.4

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/SAP/ui5-webcomponents-react).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjkuMiIsInVwZGF0ZWRJblZlciI6IjM3LjI2OS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Lukas Harbarth <lukas.harbarth@sap.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug General bug label enhancement Enhancement to a current API
Projects
None yet
Development

No branches or pull requests

3 participants