-
-
Notifications
You must be signed in to change notification settings - Fork 222
/
viewReact.js
41 lines (38 loc) · 885 Bytes
/
viewReact.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
//@flow
import * as React from 'react'
import {createComponent} from 'effector-react'
import {screenQueries} from './screenQueries'
import {orientationCheck, screenSizeCheck} from './queryCheck'
export const Screen = createComponent<
{
children: React.Node,
small?: boolean,
medium?: boolean,
large?: boolean,
portrait?: boolean,
landscape?: boolean,
...
},
{|
large: boolean,
medium: boolean,
portrait: boolean,
small: boolean,
|},
>(screenQueries, (props, queries) => {
const orientationAllowed = orientationCheck(props, queries)
const screenSizeAllowed = screenSizeCheck(props, queries)
if (orientationAllowed && screenSizeAllowed) {
return props.children
}
return null
})
//$todo
Screen.defaultProps = {
children: null,
small: false,
medium: false,
large: false,
portrait: false,
landscape: false,
}