-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathEmotion.js
More file actions
39 lines (29 loc) · 1.06 KB
/
Emotion.js
File metadata and controls
39 lines (29 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import * as Emotion from '@emotion/react';
const createElement = Emotion.jsx;
export const emptyStyle = undefined;
export const emptyStyleProperty = undefined;
const flattenDataProp = (component, props) => {
let data = null;
if (typeof component === "string" && props._data != null) {
data = { _data: undefined };
Object.entries(props._data).forEach(function(entry) {
data["data-" + entry[0]] = entry[1];
});
}
return data == null ? props : Object.assign({}, props, data);
};
export const element_ = (component, props, areChildrenDynamic) => {
const args = [component, flattenDataProp(component, props)];
return createElement.apply(
null,
areChildrenDynamic || props.children == null
? args
: args.concat(props.children)
);
};
export const elementKeyed_ = (component, props) =>
element_(component, props, true);
export const global = Emotion.Global;
export const css_ = Emotion.css;
export const important = prop => typeof prop === "string" ? prop + " !important" : prop;
export const keyframes_ = Emotion.keyframes;