evilz / fable-ant-design

Ant Design bindings for Fable Elmish
https://www.evilznet.com/fable-ant-design/index.html
MIT License
23 stars 6 forks source link

Add Cascader with docs and demo, fix build on windows #12

Closed Zaid-Ajaj closed 6 years ago

Zaid-Ajaj commented 6 years ago

This PR adds initial Cascader support in the library along with docs and working demo page.

Note that I use special interop techniques to map F# types and values manually into javascript object literals, this way you don't have to rely on [<Pojo>] or [<StringEnum>] attributes, nor Erased unions to map the options. It is a bit more work but allows for great flexibility that this library definitely needs for in order be clean, type-safe and above all, enjoyable to work with.

Let me know what you think :smile:

Planning to do more of these soon

evilz commented 6 years ago

Hi !

First of all : THANK !

I just look your code. It's look very interesting for CascaderValue. But not sur why you don't use StringEnum for simple stuff ?

[<StringEnum>]
type CascaderExpandTrigger = Click | Hover

What is the flexibility of not using this ?

Yes there is many work to do to clean this lib. Help can be very nice ;p I still have problems about complex type used in typescript def:

this is a nightmare :

    type ShowSearchType = {
      filter: (inputValue: string, path: CascaderOptionType[], names: FilledFiledNamesType) => boolean;
      render?: (
        inputValue: string,
        path: CascaderOptionType[],
        prefixCls: string | undefined,
        names: FilledFiledNamesType,
      ) => React.ReactNode;
      sort?: (a: CascaderOptionType[], b: CascaderOptionType[], inputValue: string, names: FilledFiledNamesType) => number;
      matchInputWidth?: boolean;
    }
Zaid-Ajaj commented 6 years ago

But not sur why you don't use StringEnum for simple stuff ?

I could have used StringEnum indeed, no particular reason for not using it, they are the same

this is a nightmare :

I agree that this is complex, the idea is to not put everything inside a record, you can also use a class with helper builder methods for constructing the object literal.

Also, you don't have to support every single option and configuration in the library (ant design is huge). I think we should aim for supporting common use-cases we just make sure that it is well done

evilz commented 6 years ago

By the way I already started the cascader, I just push it in this branch : https://github.com/evilz/fable-ant-design/blob/Cascader/src/Fable.Ant.Design/Cascader.fs

Zaid-Ajaj commented 6 years ago

Less code -> less bug -> less maintenance

The maintenance is usually minimal once you do it right and have working examples

I was converting code from typescript def but maybe it's not a good approch.

I am converting the types right from the docs and the demos because these provide the most common use-cases

By the way I already started the cascader, I just push it in this branch

I see, which Cascader do you wish to keep? :wink:

evilz commented 6 years ago

Yours with StringEnum :p

Zaid-Ajaj commented 6 years ago

Done