Skip to content

Commit da8fdd4

Browse files
committed
Pass objects given to css through Emotion's css function to allow
for slight performance optimizations when caching `Style` objects.
1 parent d41b786 commit da8fdd4

File tree

4 files changed

+25
-18
lines changed

4 files changed

+25
-18
lines changed

.circleci/config.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
jobs:
3+
build:
4+
docker:
5+
- image: node:10
6+
7+
steps:
8+
- checkout
9+
10+
- run:
11+
name: Build
12+
command: make

bower.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
{
22
"name": "purescript-react-basic-emotion",
33
"license": "Apache-2.0",
4-
"ignore": [
5-
"**/.*",
6-
"node_modules",
7-
"bower_components",
8-
"output"
9-
],
4+
"ignore": ["**/.*", "node_modules", "bower_components", "output"],
105
"repository": {
116
"type": "git",
127
"url": "git://github.com/lumihq/purescript-react-basic-emotion.git"

src/React/Basic/Emotion.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
"use strict";
22

3-
var Emotion = require("@emotion/core");
4-
var createElement = Emotion.jsx;
3+
const Emotion = require("@emotion/core");
4+
const createElement = Emotion.jsx;
55

66
exports.emptyStyle = undefined;
77

88
exports.emptyStyleProperty = undefined;
99

10-
function flattenDataProp(component, props) {
11-
var data = null;
10+
const flattenDataProp = (component, props) => {
11+
let data = null;
1212
if (typeof component === "string" && props._data != null) {
1313
data = { _data: undefined };
1414
Object.entries(props._data).forEach(function(entry) {
1515
data["data-" + entry[0]] = entry[1];
1616
});
1717
}
1818
return data == null ? props : Object.assign({}, props, data);
19-
}
19+
};
2020

21-
exports.element_ = function(component, props, areChildrenDynamic) {
22-
var args = [component, flattenDataProp(component, props)];
21+
exports.element_ = (component, props, areChildrenDynamic) => {
22+
const args = [component, flattenDataProp(component, props)];
2323
return createElement.apply(
2424
null,
2525
areChildrenDynamic || props.children == null
@@ -28,8 +28,9 @@ exports.element_ = function(component, props, areChildrenDynamic) {
2828
);
2929
};
3030

31-
exports.elementKeyed_ = function(component, props) {
32-
return exports.element_(component, props, true);
33-
};
31+
exports.elementKeyed_ = (component, props) =>
32+
exports.element_(component, props, true);
3433

3534
exports.global = Emotion.Global;
35+
36+
exports.css = _homogeneousDict => Emotion.css;

src/React/Basic/Emotion.purs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ foreign import elementKeyed_ ::
105105

106106
foreign import global :: ReactComponent { styles :: Style }
107107

108-
css :: forall r. Homogeneous r StyleProperty => { | r } -> Style
109-
css = unsafeCoerce
108+
foreign import css :: forall r. Homogeneous r StyleProperty => { | r } -> Style
110109

111110
nested :: Style -> StyleProperty
112111
nested = unsafeCoerce

0 commit comments

Comments
 (0)