-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
Copy pathindex.js
48 lines (45 loc) · 1.62 KB
/
index.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
43
44
45
46
47
48
import React from 'react';
import {View} from 'react-native';
import Checkbox from '@components/Checkbox';
import Tooltip from '@components/Tooltip';
import withWindowDimensions from '@components/withWindowDimensions';
import CheckboxWithTooltipForMobileWebAndNative from './CheckboxWithTooltipForMobileWebAndNative';
import {defaultProps, propTypes} from './checkboxWithTooltipPropTypes';
function CheckboxWithTooltip(props) {
if (props.isSmallScreenWidth || props.isMediumScreenWidth) {
return (
<CheckboxWithTooltipForMobileWebAndNative
style={props.style}
isChecked={props.isChecked}
onPress={props.onPress}
text={props.text}
toggleTooltip={props.toggleTooltip}
disabled={props.disabled}
accessibilityLabel={props.accessibilityLabel || props.text}
/>
);
}
const checkbox = (
<Checkbox
isChecked={props.isChecked}
onPress={props.onPress}
disabled={props.disabled}
accessibilityLabel={props.accessibilityLabel || props.text}
/>
);
return (
<View style={props.style}>
{props.toggleTooltip ? (
<Tooltip text={props.text}>
<View>{checkbox}</View>
</Tooltip>
) : (
checkbox
)}
</View>
);
}
CheckboxWithTooltip.propTypes = propTypes;
CheckboxWithTooltip.defaultProps = defaultProps;
CheckboxWithTooltip.displayName = 'CheckboxWithTooltip';
export default withWindowDimensions(CheckboxWithTooltip);