tuya-panel-kit
Version:
a functional component library for developing tuya device panels!
82 lines (64 loc) • 1.91 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
var _jsxFileName = 'src/components/divider/index.js';
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _reactNative = require('react-native');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function Divider(props) {
var visible = props.visible,
color = props.color,
width = props.width,
height = props.height;
var style = [styles.container, props.style];
var styleObj = _reactNative.StyleSheet.flatten(style) || {};
var flexDirection = styleObj.flexDirection || props.flexDirection;
if (flexDirection !== 'row') {
style.push({ width: _reactNative.StyleSheet.hairlineWidth });
} else {
style.push({ height: _reactNative.StyleSheet.hairlineWidth });
}
if (width) {
style.push({ width: width });
}
if (height) {
style.push({ height: height });
}
if (color) {
style.push({ backgroundColor: color });
}
if (!visible) {
style.push({ backgroundColor: 'transparent' });
}
return _react2.default.createElement(_reactNative.View, { style: style, __source: {
fileName: _jsxFileName,
lineNumber: 28
}
});
}
Divider.propTypes = {
style: _reactNative.ViewPropTypes.style,
flexDirection: _propTypes2.default.oneOf(['row', 'column']),
visible: _propTypes2.default.bool,
color: _reactNative.ColorPropType,
width: _propTypes2.default.number,
height: _propTypes2.default.number
};
Divider.defaultProps = {
style: null,
flexDirection: 'row',
visible: true,
color: null,
width: null,
height: null
};
var styles = _reactNative.StyleSheet.create({
container: {
alignSelf: 'stretch',
backgroundColor: '#DBDBDB'
}
});
exports.default = Divider;