sharkdp / purescript-flare

A special-purpose UI library for Purescript
287 stars 17 forks source link

Add resizableList component #26

Closed sammthomson closed 7 years ago

sammthomson commented 7 years ago

Implements #2.

The implementation uses recursively nested UIs that match the List structure.

Example 18 illustrates it.

sharkdp commented 7 years ago

I'm currently on holidays and not able to review this properly, but that sounds great! I'll get back to you when I'm back.

sharkdp commented 7 years ago

Oh wow, this is so cool!!

It even works when nesting a resizableList component inside an another resizableList :sunglasses:

(Minor comment: the way you access the PureScript datatypes from JS is both ingenious and a little bit frightening :sweat_smile:)

Released as v3.2.0

sammthomson commented 7 years ago

Cheers, thanks for the responsive merge!

Yeah, I don't love accessing the internals, but it was the quickest way to get it working. The value0 and value1 stuff could be replaced by passing in more PureScript functions so they're available in JS (setupFlare, a way to pattern match on Lists...).

The subscribe call would be much harder to get rid of. Maybe instead of treating the whole thing like a mutable signal, It could be a { prepended :: Signal (List a), head :: Signal (Maybe a), tail :: Signal (List a) } that gets flattened out. "+" updates prepended somehow. "-" turns head into Nothing, etc. I hadn't worked out the whole approach to see if it would actually work.

Anyway, if you don't mind it, that's all moot.

sharkdp commented 7 years ago

I think it's perfectly fine for now. Thank you very much for the clarification.