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

Allow interpolation return value to be a function. #346

Merged
merged 8 commits into from
Sep 26, 2017

Conversation

tkh44
Copy link
Member

@tkh44 tkh44 commented Sep 26, 2017

What:
Allow the return value of dynamic values to be a function. This function will be called with zero arguments.

const fontSize = () => 20;
const H1 = styled('h1')`font-size: ${theme.fontSize}px;`

Why:
@CompuIves has some really cool stuff in his theme.
https://github.com/CompuIves/codesandbox-client/blob/master/src/common/theme.js#L23-L30

How:
Just call the interpolation if it is a function

Checklist:

  • Documentation
  • Tests
  • Code complete

@@ -116,6 +116,10 @@ function handleInterpolation(
return ''
}

if (typeof interpolation === 'function') {
return interpolation()
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be handleInterpolation(interpolation())

@codecov
Copy link

codecov bot commented Sep 26, 2017

Codecov Report

Merging #346 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #346      +/-   ##
==========================================
+ Coverage   97.33%   97.34%   +<.01%     
==========================================
  Files          17       17              
  Lines         562      564       +2     
  Branches      133      134       +1     
==========================================
+ Hits          547      549       +2     
  Misses         11       11              
  Partials        4        4
Impacted Files Coverage Δ
packages/emotion/src/index.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ec3012e...bda2a3f. Read the comment docs.

@tkh44 tkh44 merged commit 719358b into master Sep 26, 2017
@tkh44 tkh44 deleted the function-return-values branch September 26, 2017 02:54
@tkh44 tkh44 changed the title Function return values Allow interpolation return value to be a function. Sep 26, 2017
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.

2 participants