-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathstyled.js
42 lines (35 loc) · 1.05 KB
/
styled.js
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
40
41
42
import React from 'react'
import { StyleSheet, View, Text, Image } from 'react-primitives'
import { createStyled } from '@emotion/primitives-core'
import {
testPickPropsOnPrimitiveComponent,
testPickPropsOnOtherComponent
} from './test-props'
function getShouldForwardProp(component /*: React.ElementType */) {
switch (component) {
case View:
case Text:
case Image: {
return testPickPropsOnPrimitiveComponent
}
}
return testPickPropsOnOtherComponent
}
/**
* a function that returns a styled component which render styles on multiple targets with same code
*/
/*
type CreateStyledComponent = (
...styles: any
) => React.StatelessFunctionalComponent<any> & {
withComponent: (component: any) => React.StatelessFunctionalComponent<any>
}
type BaseStyled = (tag: React.ElementType) => CreateStyledComponent
export type Styled = BaseStyled & {
View: CreateStyledComponent,
Text: CreateStyledComponent,
Image: CreateStyledComponent
}
*/
let styled /*: Styled */ = createStyled(StyleSheet, { getShouldForwardProp })
export { styled }