UNPKG

tuya-panel-kit

Version:

a functional component library for developing tuya device panels!

126 lines (114 loc) 3.87 kB
Object.defineProperty(exports, "__esModule", { value: true }); exports.mergeActions = exports.LOADINGSIZE = exports.ACTIONS = exports.ACTIVEOPACITY = exports.STYLES = exports.DEFAULTSTYLE = exports.BASELAYOUT = exports.BASERADIUS = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _utils = require('../../utils'); function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var cx = _utils.RatioUtils.convertX; var BASERADIUS = exports.BASERADIUS = 24; var BASELAYOUT = exports.BASELAYOUT = { height: 48, smallHeight: 28, largeWidth: cx(343), normalWidth: cx(150), smallWidth: cx(56), border: { borderRadius: BASERADIUS }, textStyle: { fontSize: cx(16), color: '#fff', flexShrink: 1, zIndex: 99 } }; var DEFAULTSTYLE = exports.DEFAULTSTYLE = { textStyle: BASELAYOUT.textStyle, textDisabledColor: '#999999', backgroundColorTouched: '#e54000', backgroundColorDisabled: '#e5e5e5' }; var STYLES = exports.STYLES = { primary: _extends({ style: _extends({ width: BASELAYOUT.largeWidth, height: BASELAYOUT.height, backgroundColor: '#FF4800', paddingHorizontal: cx(8) }, BASELAYOUT.border) }, DEFAULTSTYLE), primaryGradient: _extends({ style: _extends({ width: BASELAYOUT.largeWidth, height: BASELAYOUT.height, backgroundColor: '#FF4800', paddingHorizontal: cx(8) }, BASELAYOUT.border) }, DEFAULTSTYLE), primaryBorder: _extends({ style: _extends({ width: BASELAYOUT.largeWidth, height: BASELAYOUT.height, backgroundColor: 'transparent', paddingHorizontal: cx(8) }, BASELAYOUT.border, { borderWidth: cx(1), borderColor: '#FF4800' }) }, DEFAULTSTYLE, { textStyle: _extends({}, DEFAULTSTYLE.textStyle, { color: '#FF4800' }), borderColorDisabled: '#E5E5E5', backgroundColorTouched: '#ffece5', backgroundColorDisabled: 'transparent' }), normal: _extends({ style: _extends({ width: BASELAYOUT.normalWidth, height: BASELAYOUT.height }, BASELAYOUT.border, { backgroundColor: '#FF4800', paddingHorizontal: cx(8) }) }, DEFAULTSTYLE, { textStyle: _extends({}, DEFAULTSTYLE.textStyle, { fontSize: cx(12) }) }), small: _extends({ style: _extends({ width: BASELAYOUT.smallWidth, height: BASELAYOUT.smallHeight }, BASELAYOUT.border, { backgroundColor: '#FF4800', paddingHorizontal: cx(8) }) }, DEFAULTSTYLE, { textStyle: _extends({}, DEFAULTSTYLE.textStyle, { fontSize: cx(12), paddingHorizontal: cx(4) }) }), smallLoadingSize: cx(20), largeLoadingSize: cx(36) }; var ACTIVEOPACITY = exports.ACTIVEOPACITY = 0.4; var ACTIONS = exports.ACTIONS = ['onPressIn', 'onPressOut', 'onLongPress', 'onShowUnderlay', 'onHideUnderlay']; var LOADINGSIZE = exports.LOADINGSIZE = { large: cx(22), small: cx(14) }; var mergeActions = exports.mergeActions = function mergeActions() { var events = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {}; return events.reduce(function (pre, cur) { return _extends({}, pre, _defineProperty({}, cur, function () { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return target.apply(undefined, [cur].concat(args)); })); }, {}); };