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

Migrate "theming" library #292

Merged
merged 36 commits into from
Sep 28, 2017
Merged

Migrate "theming" library #292

merged 36 commits into from
Sep 28, 2017

Conversation

quantizor
Copy link
Contributor

@quantizor quantizor commented Sep 5, 2017

Fixes: #274

Checklist:

  • Documentation
  • Tests
  • Code complete

The only thing left I think is to update the existing docs to point to emotion-theming instead.

@codecov-io
Copy link

codecov-io commented Sep 5, 2017

Codecov Report

Merging #292 into master will increase coverage by 0.37%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #292      +/-   ##
==========================================
+ Coverage   97.36%   97.73%   +0.37%     
==========================================
  Files          17       22       +5     
  Lines         569      662      +93     
  Branches      134      152      +18     
==========================================
+ Hits          554      647      +93     
  Misses         11       11              
  Partials        4        4
Impacted Files Coverage Δ
packages/emotion-theming/src/with-theme.js 100% <100%> (ø)
packages/emotion-theming/test/test-helpers.js 100% <100%> (ø)
packages/emotion-theming/src/utils.js 100% <100%> (ø)
packages/react-emotion/src/index.js 100% <100%> (ø) ⬆️
packages/emotion-theming/src/theme-provider.js 100% <100%> (ø)
packages/emotion-theming/src/create-broadcast.js 100% <100%> (ø)
... and 1 more

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 b44540d...1005d48. Read the comment docs.

@tkh44 tkh44 requested a review from emmatown September 5, 2017 16:02
@quantizor
Copy link
Contributor Author

I'll finish this up tonight

"clean": "rimraf dist",
"build": "run-s clean babel:*",
"babel:cjs": "cross-env BABEL_ENV=cjs babel src -d dist/cjs",
"babel:esm": "cross-env BABEL_ENV=esm babel src -d dist/esm"
Copy link
Member

Choose a reason for hiding this comment

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

Could you change this to use the rollup setup we have for the other packages?

https://github.com/emotion-js/emotion/blob/master/packages/preact-emotion/package.json#L12-L14

"react-dom": "^15.5.4",
"react-test-renderer": "^15.5.4",
"rimraf": "^2.6.1"
},
Copy link
Member

Choose a reason for hiding this comment

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

Could you remove all the devDependencies except rollup, rimraf, npm-run-all and I think prop-types since it's not in the root package.json. It's better to have devDependencies in the root package.json because otherwise they have to be installed multiple times except for packages where we use binaries since binaries aren't linked.

tkh44
tkh44 previously requested changes Sep 6, 2017
Copy link
Member

@tkh44 tkh44 left a comment

Choose a reason for hiding this comment

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

Please see @mitchellhamilton's feedback.

package.json Outdated
@@ -8,7 +8,7 @@
"clean": "lerna run clean --parallel",
"test": "npm-run-all -p lint:check coverage test:size",
"coverage": "jest --coverage --no-cache --ci --runInBand",
"lint:check": "eslint .",
"lint:check": "eslint . --fix",
Copy link
Member

Choose a reason for hiding this comment

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

Please change this back. This is for CI to check that there are no linting errors.

Copy link
Contributor Author

@quantizor quantizor Sep 7, 2017

Choose a reason for hiding this comment

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

I will, debugging something else

@quantizor
Copy link
Contributor Author

quantizor commented Sep 7, 2017

Ok so I came up with an interesting bug while trying to finish this... looking for feedback.

Basically if you have a situation where you're using styled() on top of another emotion primitive wrapped with withTheme() it throws on render because I think emotion is processing all the css upfront before withTheme can inject the theme prop deeper in the stack.

Something like this:

const theme = { color: 'red' }

const Component = styled.div`
    color: ${p => p.theme.color};
`
const ThemedComponent = withTheme(Component)

const FinalComponent = styled(ThemedComponent)`
    border: 1px solid blue;
`

const wrapper = mount(
    <ThemeProvider theme={theme}>
        <FinalComponent />
    </ThemeProvider>
)
TypeError: Cannot read property 'color' of undefined

However, this only happens with static hoisting... if I remove the hoisting the error goes away, but then component selector will no longer work.

@quantizor
Copy link
Contributor Author

quantizor commented Sep 7, 2017

We could get away with doing this:

hoist(WithTheme, Component)
delete WithTheme.__emotion_spec

any objections?

update: pushed this fix in 9478fb4

@@ -23,6 +23,7 @@
},
"devDependencies": {
"babel-cli": "^6.24.1",
"emotion-theming": "^1.0.0",
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't need to be a devDependency here since it's in jest's moduleNameMapper.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’m on vacation until Tuesday, so if you want to get this in sooner feel free to push that change on.

Copy link
Member

Choose a reason for hiding this comment

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

No rush. Enjoy your vacation!

@quantizor
Copy link
Contributor Author

@tkh44 @mitchellhamilton all comments should be addressed

@quantizor
Copy link
Contributor Author

Wait why is component selector being removed? It’s quite hard to achieve the same functionality without first class support, and the majority of the reason I even opened this PR :/

@emmatown
Copy link
Member

@probablyup #329

@tkh44
Copy link
Member

tkh44 commented Sep 28, 2017

Thank you for putting all this work in @probablyup 🍻

@tkh44 tkh44 merged commit 361d060 into emotion-js:master Sep 28, 2017
@miklschmidt miklschmidt mentioned this pull request Sep 2, 2019
4 tasks
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.

None yet

4 participants