Closed angelod1as closed 2 years ago
The preferred way to do this would be to use renderMark
and/or renderThumb
to add your own custom data attributes rather than hard-code them into the library. Here is an example:
You can also use markClassName
and/or thumbClassName
for targeting purposes.
renderThumb works because it gets the label. RenderMark doesn't, and markClassName adds the same class for every mark. My intention was adding a difference between marks, mainly. I added the thumb version for convenience. There's no way to set a mark different from the other at the library current version.
I see -- it would make sense then to add a state param to the renderMark
callback like we do for renderThumb
:
https://github.com/zillow/react-slider/blob/master/src/components/ReactSlider/ReactSlider.jsx#L1016-L1020
Is this something you would like to add?
I could do that, yes. That would indeed solve my issue and add to the library.
Purpose
This PR adds
data-label
anddata-mark-label
to thumbs and marks respectively. They can be used in order to customize thumbs and marks further.This minor addition makes working with custom marks and labels easier and, as it's a
data
attribute, won't impact rendering in any way.(ps: I've never worked with styleguidist so please let me know if I've missed something).
This fixes #239 as using these labels I can target specific thumbs and marks for customization.