You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Proposal:HOC for composing styles in one place #522
Hey guys, today I wanted to style Link from react-router with styled-components and I didn't find any good solution how to handle className and activeClassName. I didn't like solution with defaultProps and neither i like random generated className as can be seen #184 . I've been little been hacking on top of your lib and I've create HOC for composing styles together
@mxstbr@geelen@patrick91@relekang You're the most active contributors/owners, what do you think about my idea? I know you have your own business and are probably quite busy, I just want to know if you like it because if not, I will probably create small package with this HOC for people to use. Thanks for your time! 👍
This is a nice idea but we're hoping to provide native support for this exact use case in #509 (part of v2, in particular the attrs method described in #365).
Glad to see you were able to get a HOC to do the same thing in the mean time, but yeah this use case is general enough that I think it'll be good to support it in core.
Oh, wait, sorry. That's not what #509 is doing—it's generating style blocks not classnames. Hmm, ok I'll have to have a bit more of a think about how this could fit in.
well, I hope I don't overrated my solution, but I believed this is the most pure solution with few lines of code for supporting 3rd party libs. The great part is that it's just styled-components, so it works great with all the props passed down and theming etc.
@svrcekmichal I think there are both pros and cons to your approach.
As It doesn't require the user to learn new vocabulary (compared to attrs) it lessens the cognitive load, which is always a good thing (attrs is also a bit ambigious in the context of react and props IMO).
What I don't like is that it forces the user to explicitly use className, which might be confusing, since it is not self-exploratory that the className styles are the ones applied by styled-components. This would, in some sense, require the user to know that the className is injected by styled-components, and one could argue that is a implementation detail.
Given that attrs is in v2, I don think this addition to the API would be justified, since it doesn't cover a new use-case as far as I understand it.
I agree with @GGAlanSmithee, I don't really see a reason to add this API anymore since we're covering all the use cases now. Thanks for kicking off the discussion @svrcekmichal!
Activity
svrcekmichal commentedon Feb 22, 2017
@mxstbr @geelen @patrick91 @relekang You're the most active contributors/owners, what do you think about my idea? I know you have your own business and are probably quite busy, I just want to know if you like it because if not, I will probably create small package with this HOC for people to use. Thanks for your time! 👍
geelen commentedon Feb 22, 2017
This is a nice idea but we're hoping to provide native support for this exact use case in #509 (part of v2, in particular the
attrsmethod described in #365).Glad to see you were able to get a HOC to do the same thing in the mean time, but yeah this use case is general enough that I think it'll be good to support it in core.
geelen commentedon Feb 22, 2017
Oh, wait, sorry. That's not what #509 is doing—it's generating style blocks not classnames. Hmm, ok I'll have to have a bit more of a think about how this could fit in.
svrcekmichal commentedon Feb 23, 2017
well, I hope I don't overrated my solution, but I believed this is the most pure solution with few lines of code for supporting 3rd party libs. The great part is that it's just styled-components, so it works great with all the props passed down and theming etc.
GGAlanSmithee commentedon Mar 6, 2017
@svrcekmichal I think there are both pros and cons to your approach.
As It doesn't require the user to learn new vocabulary (compared to
attrs) it lessens the cognitive load, which is always a good thing (attrsis also a bit ambigious in the context of react andpropsIMO).What I don't like is that it forces the user to explicitly use
className, which might be confusing, since it is not self-exploratory that theclassNamestyles are the ones applied bystyled-components. This would, in some sense, require the user to know that theclassNameis injected bystyled-components, and one could argue that is a implementation detail.Given that
attrsis inv2, I don think this addition to the API would be justified, since it doesn't cover a new use-case as far as I understand it.mxstbr commentedon Dec 15, 2017
I agree with @GGAlanSmithee, I don't really see a reason to add this API anymore since we're covering all the use cases now. Thanks for kicking off the discussion @svrcekmichal!