UNPKG

vue-ant-patterns

Version:

vue-ant-patterns

91 lines (81 loc) 2.17 kB
import _extends from 'babel-runtime/helpers/extends'; import _defineProperty from 'babel-runtime/helpers/defineProperty'; import PropTypes from 'ant-design-vue/es/_util/vue-types'; import cx from 'classnames'; import Container from '../d-container'; var depotProps = { flex: true, justify: 'start', align: 'center' }; var TitleBar = { name: 'DTitleBar', props: { prefixCls: PropTypes.string.def('depot-title-bar'), title: String, tagName: PropTypes.oneOf(['h2', 'h3', 'h4', 'h5']).def('h3'), bold: PropTypes.bool.def(true), margin: PropTypes.string.def('0 0 0px 0'), padding: PropTypes.string.def('0'), height: PropTypes.string }, methods: { renderTitle: function renderTitle(h) { var tagName = this.tagName, title = this.title, $slots = this.$slots; return $slots.title ? $slots.title : h(tagName, title); } }, render: function render(h) { var _cx; var prefixCls = this.prefixCls, $slots = this.$slots, bold = this.bold, margin = this.margin, padding = this.padding, height = this.height; var main = $slots.main, second = $slots.second; var wrapProps = { 'class': cx((_cx = {}, _defineProperty(_cx, prefixCls, 1), _defineProperty(_cx, prefixCls + '-bold', bold), _cx)), props: _extends({}, depotProps, { justify: 'between', margin: margin, padding: padding, height: height }) // style: { // margin, // padding, // }, }; var mainProps = { 'class': prefixCls + '-main', props: _extends({}, depotProps) }; var secondProps = { 'class': prefixCls + '-second', props: _extends({}, depotProps, { justify: 'end' }) }; return h( Container, wrapProps, [h( Container, mainProps, [this.renderTitle(h), main ? main : null] ), second ? h( Container, secondProps, [second] ) : null] ); } }; TitleBar.install = function (Vue) { Vue.component(TitleBar.name, TitleBar); }; export default TitleBar;