ost-ui
Version:
ost ui for react
64 lines (52 loc) • 1.73 kB
JavaScript
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
var OstText = function (_React$Component) {
_inherits(OstText, _React$Component);
function OstText() {
_classCallCheck(this, OstText);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
OstText.prototype.render = function render() {
var _classnames;
var _props = this.props,
fixedCls = _props.fixedCls,
className = _props.className,
label = _props.label,
text = _props.text,
multiLine = _props.multiLine,
type = _props.type,
size = _props.size;
var wrapClass = classnames(fixedCls, className, (_classnames = {}, _classnames[fixedCls + '-' + type] = type, _classnames[fixedCls + '-' + size] = size, _classnames));
return React.createElement(
'div',
{ className: wrapClass },
label && React.createElement(
'label',
{ className: 'ost-text-label' },
label
),
React.createElement(
'p',
{ className: classnames({ 'ost-text-single-line': !multiLine }) },
text
)
);
};
return OstText;
}(React.Component);
OstText.defaultProps = {
fixedCls: 'ost-text',
size: 'md',
multiLine: true // 是否多行显示,默认多行显示
};
export default OstText;
OstText.propTypes = {
fixedCls: PropTypes.string,
type: PropTypes.string,
size: PropTypes.string,
multiLine: PropTypes.bool.isRequired
};