Shmew / Feliz.MaterialUI

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

Review: slider.marks prop #14

Closed cmeeren closed 4 years ago

cmeeren commented 5 years ago

The slider API docs says the following about the marks prop, which can be bool or array:

Marks indicate predetermined values to which the user can move the slider. If true the marks will be spaced according the value of the step prop. If an array, it should contain objects with value and an optional label keys.

I have implemented this prop as below, does that make sense?

https://github.com/cmeeren/Feliz.MaterialUI/blob/cbc5dd789a526939fdea917f888f27d4f06d7c1a/src/Feliz.MaterialUI/Props.fs#L3712-L3720

Usage:

slider.marks true
slider.marks(1, 5, 10, 50, 100)
slider.marks(0.5, 1.5)
slider.marks({| value = 37.5; label = Some "body temp" |}, {| value = 50; label = None |})
cmeeren commented 4 years ago

A less verbose alternative to anonymous records is tuples, in this case int * string option and float * string option. The final line in the usage example above then becomes


slider.marks((37.5, Some "body temp"), (50, None))
cmeeren commented 4 years ago

I got compiler errors about incompatible types when trying to pass anonymous records across project boundaries.

I ended up using the less verbose tuple alternative.