Skip to content

Commit

Permalink
Rewrite styled-jsx/css (#422)
Browse files Browse the repository at this point in the history
Split the old `css` tag in:

* `css`: generates scoped styles
* `css.global`: generates global styles
* `css.resolve`: resolves styles to an object which contains the scoped `className` and a drop-in `styles` element to render the styles

Also introduces a macro (see babel-plugin-macros) for `css.resolve`
  • Loading branch information
giuseppeg authored Mar 29, 2018
1 parent 2831798 commit 051d0d1
Show file tree
Hide file tree
Showing 18 changed files with 4,004 additions and 874 deletions.
18 changes: 16 additions & 2 deletions css.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
module.exports = function() {
function notTranspiledError(name) {
throw new Error(
'styled-jsx/css: if you are getting this error it means that your `css` tagged template literals were not transpiled.'
'styled-jsx/css: if you are getting this error it means that your `' +
name +
'` tagged template literals were not transpiled.'
)
}
function css() {
notTranspiledError('css')
}
css.global = function() {
notTranspiledError('global')
}
css.resolve = function() {
notTranspiledError('resolve')
}
module.exports = css
module.exports.global = css.global
module.exports.resolve = css.resolve
1 change: 1 addition & 0 deletions macro.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist/macro')
Loading

0 comments on commit 051d0d1

Please sign in to comment.