Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for first-class functions #1820

Merged

Conversation

acjay
Copy link
Member

@acjay acjay commented Jun 21, 2018

Closes #1620

Inspired by @probablyup's comment, I checkout out #1732 to see if I could solve my problem in #1620. Turns out, it was really straightforward.

To get a feel for the syntax this enables:

image

or alternatively

image

This is particularly useful for DRYing up repetitive logic mapping props to styles and not having to repeatedly reference the props object.

wmertens
wmertens previously approved these changes Jun 21, 2018
Copy link
Contributor

@wmertens wmertens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, great! It always bugged me that I needed to run the same function a few times to set different attributes.

Short and sweet changeset, too. 👍

mxstbr
mxstbr previously approved these changes Jun 21, 2018
Copy link
Member

@mxstbr mxstbr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is simple and nice enough that I'm a small 👍 I probably won't use this a ton, but I can defo see why you'd want to use this.

/cc @probablyup for final approfval

quantizor
quantizor previously approved these changes Jun 21, 2018
Copy link
Contributor

@quantizor quantizor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!

CHANGELOG.md Outdated
}))
```

This can be useful for destructuring the props of the styled component or for inserting logic for computing the styles from props.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a byline to this matching the previous entries?

@acjay acjay dismissed stale reviews from quantizor, mxstbr, and wmertens via 518d3e8 June 21, 2018 16:15
@acjay
Copy link
Member Author

acjay commented Jun 21, 2018

@probablyup Ok, tried to match it more closely and make it more brief (since many of the recent entries are pretty brief). Let me know if this is better.

Copy link
Contributor

@quantizor quantizor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thanks!

@quantizor quantizor merged commit cfbca01 into styled-components:master Jun 21, 2018
@mxstbr
Copy link
Member

mxstbr commented Jun 21, 2018

Thank you so much for helping us improve styled-components! Based on our Community Guidelines every person that has a PR of any kind merged is offered an invitation to the styled-components organization—that is you right now!

Should you accept, you'll get write access to the main repository. (and a fancy styled-components logo on your GitHub profile!) You'll be able to label and close issues, merge pull requests, create new branches, etc. We want you to help us out with those things, so don't be scared to do them! Make sure to read our contribution and community guidelines, which explains all of this in more detail. Of course, if you have any questions just let me know!

@quantizor
Copy link
Contributor

We'll probably cut a minor release after these PRs are finished:

#1739
#1807

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants