Added support for custom dragging and dragged class names#178
Added support for custom dragging and dragged class names#178STRML merged 4 commits intoreact-grid-layout:masterfrom
Conversation
|
Thanks @bvaughn. Will review shortly. Re: Your |
lib/Draggable.es6
Outdated
|
|
||
| // Mark with class while dragging | ||
| const className = classNames((this.props.children.props.className || ''), 'react-draggable', { | ||
| const className = classNames(childProps.className, 'react-draggable', { |
There was a problem hiding this comment.
How about we make classNameDragging and classNameDragged's value in defaultProps equal to react-draggable-dragging and react-draggable-dragged.
There was a problem hiding this comment.
By propTypes do you mean the dontSetMe warning?
|
Sure thing on values overriding the default. I thought you specifically didn't want that approach since you weren't doing that with I can't set them in |
|
Ah no, don't set them on the children. You'll get a React 15.2 warning about undefined properties anyhow. Set them on the Draggable itself. |
…class names now override default instead of add to them.
|
FYI, updating |
|
I'm not doing it with I still don't really see a good reason to do this - why would you need it? Why not just set a |
|
Re: Flow errors rebase this on |
Seems like folks could set |
|
Using a "global" classname is a very common thing to do in many libs. I still don't see the utility but if the patch is very small I will still consider it. |
specs/draggable.spec.jsx
Outdated
|
|
||
| it('should set the appropriate custom className when dragging or dragged', function () { | ||
| drag = TestUtils.renderIntoDocument( | ||
| <Draggable> |
There was a problem hiding this comment.
So this should be <Draggable classNameDragging="foo">. Don't set it on the child.
There was a problem hiding this comment.
Happy to make this change, but considering this and this it seemed inconsistent to require className to be a child property but classNameDragged and classNameDragging to be self properties.
I'm not sure why className was ever a child property anyway, but I didn't want to suggest a non-backwards-compatible Api change.
|
Now I'm a bit confused. You suggested default, overridable values for the dragging and dragged variants, but not for the default class. Why the inconsistency? :) Yes, using global class names is very common. But so are CSS modules. Seems like if a user specifies a custom class name there's no reason to also tack on a default. But again- this change was your suggestion initially, no? I didn't propose it with my initial PR. The only reason for this PR is so that applications using CSS modules can avoid having to add |
|
Ah okay, that makes sense re I'd propose this API for draggable with their values in defaultProps:
Then we just reference those when building the final name. |
…NameDragged properties to Draggable. Updated docs and tests
|
Sure! Sounds reasonable. Please let me know if the updated PR matches your expectations. :) |
|
👍 Great! |
|
Thanks for talking through things @STRML :) |
|
Np. Very simple in the merged commit, which I like. Appreciate the contribution |
Nifty library! Thanks for creating it. :)
I noticed that
classNamecan be used to specify a custom class (eg for CSS modules) but there is no way to specify a custom is-dragging or is-dragged class. This PR adds that functionality (and tests).Note that
npm testis broken in master (and won't pass until PR #176 is merged).Note that
npm run lintalso fails in master: