react-aim icon indicating copy to clipboard operation
react-aim copied to clipboard

Distinguish first source in a component tree with nested sources

Open sseppola opened this issue 8 years ago • 6 comments

Hi, I have multiple nested react-aim sources in a component tree and I'm trying to pass an "over = true" prop to the first react-aim source under the cursor. By first I mean the element deepest in the DOM.

I'm not sure if this is currently possible, although I'm still wrapping my head around the code. Is there a simple way to accomplish this?

sseppola avatar Dec 12 '16 22:12 sseppola

It is not possible to do without making changes to the library.

gabrielbull avatar Dec 13 '16 14:12 gabrielbull

Thank you. Is a feature like this something that is in the scope of this module?

sseppola avatar Dec 13 '16 15:12 sseppola

Yes, it sounds like a good idea to have.

gabrielbull avatar Dec 13 '16 15:12 gabrielbull

Cool. I'll have a look at how I'd extend this library to accomplish it. As the author, do you consider this a straightforward task to write?

sseppola avatar Dec 13 '16 15:12 sseppola

It shouldn't be too hard. What needs more thinking is how would you expose the API to the user. Currently, we use this type of API:

@source(
  {
    mouseEnter: (props, component) => {
      component.setState({ over: true });
    },
    mouseLeave: (props, component) => {
      component.setState({ over: false });
    }
  }
)

Which I'm not a fan of because it rely on having a state for the component. If it was mapping props to the component that would be better and could be used with stateless components as well.

gabrielbull avatar Dec 13 '16 15:12 gabrielbull

I agree and will keep it in mind as I go, however my first goal is to reach parity with the current api.

sseppola avatar Dec 13 '16 15:12 sseppola