Shmew / Feliz.MaterialUI

Feliz-style Fable bindings for Material-UI
https://shmew.github.io/Feliz.MaterialUI/
MIT License
70 stars 19 forks source link

Cannot use theme in `makeStyles` in Fable 3 #59

Closed ameier38 closed 3 years ago

ameier38 commented 3 years ago

First, thanks for this library. Really makes my life much easier.

I am trying out Fable 3 but I can't seem to use the theme argument of Styles.makeStyles.

let useStyles = Styles.makeStyles(fun styles theme ->
    {|
        root = styles.create [
            style.backgroundColor theme.palette.primary.dark // causes 'arg.Feliz.MaterialUI.Theme.get_palette is not a function'
        ]
    |}
)

I am having trouble figuring out how where the get_pallete is coming from. I feel like it should just be pallet. image

Here is a reproduceable example: https://github.com/ameier38/feliz-material-ui-fable-3

cmeeren commented 3 years ago

Hi, thanks for the report! Unfortunately I have limited resources to spend on maintaining Feliz.MaterialUI at the moment, so I'm unsure when I'll be able to have a look at it. Please let me know if you are able to figure out what's wrong or how to fix it in the meantime.

ameier38 commented 3 years ago

No problem! I'll keep digging and create a PR if I find a fix.

cmeeren commented 3 years ago

Thanks! If there's a problem in generated code, you don't have to learn my custom generator to create a PR, just let me know what's wrong and it's probably an easy fix for me.

atheck commented 3 years ago

Hi, I have a similar issue with theme.spacing, theme.mixins and theme.zIndex.

Log output:

Uncaught TypeError: arg.Feliz.MaterialUI.Theme.get_mixins is not a function
at
Object.entries(arg["Feliz.MaterialUI.Theme.get_mixins"]()
cmeeren commented 3 years ago

Thanks. Unfortunately I still have my hands too full to investigate an issue with no immediately discernible root cause. Particularly if this was something that changed between Fable 2 and Fable 3. Please let me know should you manage to figure out what needs fixing.

alfonsogarciacaro commented 3 years ago

Sorry, I didn't know about this issue. Seems to be caused by how Fable 2 and 3 deal with abstract classes. I will send a PR to this repo to make sure the code works well both with Fable 2 and 3.

alfonsogarciacaro commented 3 years ago

@cmeeren What's the best way to check everything is working? Building the docs?

cmeeren commented 3 years ago

@cmeeren What's the best way to check everything is working? Building the docs?

Building the CiBuild target should check everything, including generating the package. But Docs:Build is almost as good.

cmeeren commented 3 years ago

v1.2.4 will appear on NuGet shortly with this fix.

alfonsogarciacaro commented 3 years ago

Awesome, thanks a lot @cmeeren! There was another issue in Fable affecting Feliz.MaterialUI so users may need to update Fable too to 3.0.5: dotnet tool update fable

halcwb commented 3 years ago

I can confirm that everything work!! @cmeeren @alfonsogarciacaro Great work, thanks.

cmeeren commented 3 years ago

Awesome, thanks a lot @cmeeren!

I simply released your fix, this one is on you 👏🥳 Thanks a lot!