dh-c
Version:
The front-end development engineers jimberton gulp react component
124 lines (107 loc) • 4.49 kB
JavaScript
'use strict';
exports.__esModule = true;
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**
*
*/
var Step = function (_React$Component) {
_inherits(Step, _React$Component);
function Step(props) {
_classCallCheck(this, Step);
return _possibleConstructorReturn(this, _React$Component.call(this, props));
}
Step.prototype.render = function render() {
var _context = this.context,
width = _context.width,
lineOption = _context.lineOption,
headOption = _context.headOption,
mainOption = _context.mainOption;
var lineStyle = {
backgroundColor: lineOption && lineOption.color,
height: lineOption && lineOption.weight
};
var lineStyleTransition = {
backgroundColor: lineOption && lineOption.transitionColor
};
var headStyle = {
backgroundColor: headOption && headOption.bgColor,
color: headOption && headOption.color
};
var headStyleTransition = {
backgroundColor: headOption && headOption.transitionBgColor,
color: headOption && headOption.transitionColor
};
var mainStyle = {
color: mainOption && mainOption.color
};
var mainStyleTransition = {
color: mainOption && mainOption.transitionColor
};
var _props = this.props,
icon = _props.icon,
title = _props.title;
return _react2.default.createElement(
'div',
{ className: 'dh-steps-item', style: { width: width } },
_react2.default.createElement(
'div',
{ className: 'dh-steps-step' },
_react2.default.createElement(
'div',
{ className: 'dh-steps-head' },
this.props.status === 'finish' ? _react2.default.createElement(
'div',
{ className: 'dh-steps-head-inner-finish', style: headStyleTransition },
icon
) : _react2.default.createElement(
'div',
{ style: headStyle, className: 'dh-steps-head-inner' },
icon
)
),
_react2.default.createElement(
'div',
{ className: 'dh-steps-main' },
this.props.status === 'finish' ? _react2.default.createElement(
'div',
{ style: mainStyle, className: 'dh-steps-main-title-finish' },
title
) : _react2.default.createElement(
'div',
{ style: mainStyleTransition, className: 'dh-steps-main-title' },
title
)
)
),
_react2.default.createElement(
'div',
{ style: lineStyle, className: 'dh-steps-tail' },
_react2.default.createElement('div', {
style: lineStyleTransition,
className: 'dh-steps-tail__inline',
'data-slide': this.props.status === 'finish'
})
)
);
};
return Step;
}(_react2.default.Component);
Step.contextTypes = {
width: _propTypes2.default.string.isRequired,
lineOption: _propTypes2.default.object,
headOption: _propTypes2.default.object,
mainOption: _propTypes2.default.object
};
Step.propsTypes = {
icon: _propTypes2.default.oneOfType([_propTypes2.default.element, _propTypes2.default.string]),
title: _propTypes2.default.oneOfType([_propTypes2.default.element, _propTypes2.default.string]),
status: _propTypes2.default.oneOf(['progress, finished', 'waiting'])
};
exports.default = Step;