airbnb / visx

🐯 visx | visualization components
https://airbnb.io/visx
MIT License
19.4k stars 712 forks source link

feat(annotation): Add the ability to override pointerEvents on Annotations #1879

Open TSIA-SN opened 1 week ago

TSIA-SN commented 1 week ago

:rocket: Enhancements

As discussed in https://github.com/airbnb/visx/issues/1433, it may be desirable to have pointer events enabled on Annotations. This PR exposes the pointerEvents attribute of the underlying elements while leaving the default as "none" to maintain the current behavior.

Note: I was not able to get the demo project to run locally, so this PR could probably use some testing code. However, I was able to take the built package and use it successfully in my personal project on an HTMLLabel as a smoke test.

Regarding SVGProps vs SVGAttributes (see packages/visx-annotation/src/components/Connector.tsx), I decided to use SVGAttributes since the pointerEvent attribute is set on a standard element as opposed to a custom element. Additionally, tracing the types through, SVGProps extends SVGAttributes, which is where pointerEvents is defined, so it seemed like the better option.

:memo: Documentation

I'm guessing the docs are in a separate repo, but https://airbnb.io/visx/docs/annotation could be updated to reference the new props. I added JSLint comments to the new props so they will be visible to developers.