rat-button
Version:
button component for Rax.
114 lines (89 loc) • 3.02 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
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 _ratFrame = require('rat-frame');
var _ratProvider = require('rat-provider');
var _ratView = require('rat-view');
var _ratView2 = _interopRequireDefault(_ratView);
var _button = require('./button');
var _button2 = _interopRequireDefault(_button);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
/*const styles = {
button: {},
text: {
color: '#0C42FD',
textAlign: 'center',
padding: 16,
fontSize: 36,
border: '1px solid #333',
},
buttonDisabled: {},
textDisabled: {
color: '#cdcdcd',
},
};
class NormalButton extends Component {
onPress = (e) => {
this.props.onPress && this.props.onPress(e);
}
render() {
const props = this.props;
const buttonStyles = [styles.button, props.style];
const textStyles = [styles.text];
if (props.color) {
textStyles.push({ color: props.color });
}
if (props.disabled) {
buttonStyles.push(styles.buttonDisabled);
textStyles.push(styles.textDisabled);
}
let content = props.children || props.title;
if (typeof content === 'string') {
content = <button style={textStyles}>{content}</button>;
}
return (
<View role="button" {...props} style={buttonStyles} onClick={this.onPress}>
{content}
</View>
);
}
}*/
//export default Button;
exports.default = _ratProvider.ConfigProvider.config(_button2.default, {
transform: function transform(props, deprecated) {
if ('shape' in props) {
deprecated('shape', 'text | warning | ghost', 'Button');
var _props = props,
shape = _props.shape,
type = _props.type,
others = _objectWithoutProperties(_props, ['shape', 'type']);
var newType = type;
if (type === 'light' || type === 'dark' || type === 'secondary' && shape === 'warning') {
newType = 'normal';
}
var ghost = void 0;
if (shape === 'ghost') {
ghost = {
primary: 'dark',
secondary: 'dark',
normal: 'light',
dark: 'dark',
light: 'light'
}[type || _button2.default.defaultProps.type];
}
var text = shape === 'text';
var warning = shape === 'warning';
props = _extends({
type: newType,
ghost: ghost,
text: text,
warning: warning
}, others);
}
return props;
}
});
module.exports = exports['default'];
;