zent
Version:
一套前端设计语言和基于React的实现
32 lines (31 loc) • 1.84 kB
JavaScript
import { __assign, __extends } from "tslib";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Component } from 'react';
import cx from 'classnames';
import Placeholder from '../placeholder';
import isNil from '../utils/isNil';
var Card = (function (_super) {
__extends(Card, _super);
function Card() {
return _super !== null && _super.apply(this, arguments) || this;
}
Card.prototype.render = function () {
var _a = this.props, title = _a.title, action = _a.action, type = _a.type, loading = _a.loading, style = _a.style, children = _a.children, className = _a.className, bodyStyle = _a.bodyStyle;
var isValidTitle = !isNil(title);
var isValidAction = !isNil(action);
return (_jsxs("div", __assign({ className: cx('zent-card', className, {
'zent-card--normal': type === 'normal',
'zent-card--nested': type === 'nested',
}), style: style, "data-zv": '10.0.17' }, { children: [(isValidTitle || isValidAction) && (_jsxs("div", __assign({ className: "zent-card-header", "data-zv": '10.0.17' }, { children: [isValidTitle && (_jsx("h3", __assign({ className: "zent-card-header__title", "data-zv": '10.0.17' }, { children: title }), void 0)), isValidAction && (_jsx("div", __assign({ className: "zent-card-header__action", "data-zv": '10.0.17' }, { children: action }), void 0))] }), void 0)), _jsx("div", __assign({ className: "zent-card-body", style: bodyStyle, "data-zv": '10.0.17' }, { children: loading ? _jsx(Placeholder.TextBlock, { rows: 5 }, void 0) : children }), void 0)] }), void 0));
};
Card.defaultProps = {
type: 'normal',
style: {},
bodyStyle: {},
loading: false,
className: '',
};
return Card;
}(Component));
export { Card };
export default Card;