fable-compiler / fable-react

Fable bindings and helpers for React and React Native
MIT License
273 stars 67 forks source link

Add Pointer Events #237

Closed cr3wdayt5p closed 1 year ago

cr3wdayt5p commented 1 year ago

Feature request: Add pointer events to Fable.React.Props.DOMAttr.

Pointer Events were added to React DOM in v16.4 back in 2018: https://reactjs.org/blog/2018/05/23/react-v-16-4.html

There is now full browser support (even back to IE11 from 2013): https://caniuse.com/?search=PointerEvent%20API

They already work fine with DOMAttr.Custom, e.g. DOMAttr.Custom ("onPointerDown", handler).

The PointerEvent type is available in Browser.Types.

alfonsogarciacaro commented 1 year ago

I think that'd be fine. Would it be possible for you to send a PR? Many Fable projects have moved to Feliz so there are not many maintainers for this repo now.

cr3wdayt5p commented 1 year ago

Sure, I would like to start to contribute to the Fable community. I am coming from Elm so I actually prefer the Fable.React syntax over Feliz.

But I am new to the dotnet and Fable ecosystems, so I am having trouble testing my changes to Fable.React in my project. I have changed <PackageReference Include="Fable.React" Version="9.2.0"/> to <ProjectReference Include="../../../fable-react/src/Fable.React/Fable.React.fsproj"/>

The Fable compiler finds my local copy of Fable.React but it appears to try to compile my other dependencies first. I get a bunch of errors indicating the order is wrong, e.g.: Fable.Elmish.React.4.0.0/common.fs(3,12): (3,17) error FSHARP: The namespace 'React' is not defined. (code 39)

Can you point me in the direction of a good blog post explaining how to test local changes to a Fable package?

EDIT: Never mind. I found this: https://stackoverflow.com/questions/43400069/add-a-package-with-a-local-package-file-in-dotnet

alfonsogarciacaro commented 1 year ago

Yes, this is quite a pain with Nuget. AFAIK there's no built in solution to test local packages, so you need to create the package locally and add the local sources in the Nuget.config (and make sure the package is not cached every time you change it).

To make this easier for Fable I added a --replace option that can replace a package with a local project. Example:

dotnet fable watch src --replace Fable.React:path/to/you/local/Fable.React.fsproj

The only problem is this is a Fable-only mechanism. So it will work for Fable compilation but your IDE will still complain the new Props don't exist.