-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
37 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use strict'; | ||
|
||
exports.addonStyled = function (renderer) { | ||
renderer.styled = function (fn, styles, dynamicTemplate, block) { | ||
var isElement = typeof fn === 'string'; | ||
var jsxComponent = renderer.jsx(fn, styles, block); | ||
|
||
if (!block && !isElement) | ||
block = fn.displayName || fn.name; | ||
|
||
var Component = function(props) { | ||
var copy = props; | ||
|
||
if (process.env.NODE_ENV !== 'production') { | ||
copy = Object.assign({}, props); | ||
} | ||
|
||
if (dynamicTemplate) { | ||
copy.css = dynamicTemplate(props); | ||
} | ||
|
||
return jsxComponent(copy); | ||
}; | ||
|
||
if (process.env.NODE_EVN !== 'production') { | ||
if (block || (typeof fn === 'function')) { | ||
Component.displayName = 'styled(' + (block || fn.displayName || fn.name) + ')'; | ||
} | ||
} | ||
|
||
return Component; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters