brunobertolini / styled-by

Simple and powerful lib to handle styled props in your components

Home Page:https://codesandbox.io/s/ElvL8EKgg

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

First parameter of funcs should be value (props[prop])

mikestopcontinues opened this issue · comments

Hi! I realize this is a breaking change, but I believe it's worth it. See the following:

Before:

by('size', (props) => pxToRem(props['size']))
by('colorName', (props) => namesToHex[props['colorName']])

After:

by('size', pxToRem)
by('colorName', (name) => namesToHex[name])

I suggest the signature (value, props). This would allow you to compose chains of functions (a la R.pipe or _.flow), and it would also allow you to reuse logic across components. (For instance, that pxToRem function.

Hi Mike, sorry for the delay, I was very busy in the last few months.
I like this strategy, and will appreciate a PR, because, well, I will continue busy in the nexts few months 😄

Swell! I'll send one along soon.