mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-16 01:41:15 +08:00
0935262334
* feat: update divider * chore: remove base import * style: move up slot.default() judge
47 lines
1.4 KiB
Vue
47 lines
1.4 KiB
Vue
import { inject } from 'vue';
|
|
import PropTypes from '../_util/vue-types';
|
|
import { ConfigConsumerProps } from '../config-provider';
|
|
|
|
const Divider = {
|
|
name: 'ADivider',
|
|
props: {
|
|
prefixCls: PropTypes.string,
|
|
type: PropTypes.oneOf(['horizontal', 'vertical', '']).def('horizontal'),
|
|
dashed: PropTypes.bool,
|
|
orientation: PropTypes.oneOf(['left', 'right', 'center']),
|
|
},
|
|
setup() {
|
|
return {
|
|
configProvider: inject('configProvider', ConfigConsumerProps),
|
|
};
|
|
},
|
|
render() {
|
|
const { prefixCls: customizePrefixCls, type, $slots, dashed, orientation = 'center' } = this;
|
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
|
const prefixCls = getPrefixCls('divider', customizePrefixCls);
|
|
const orientationPrefix = orientation.length > 0 ? '-' + orientation : orientation;
|
|
|
|
const classString = {
|
|
[prefixCls]: true,
|
|
[`${prefixCls}-${type}`]: true,
|
|
[`${prefixCls}-with-text${orientationPrefix}`]: $slots.default,
|
|
[`${prefixCls}-dashed`]: !!dashed,
|
|
};
|
|
|
|
return (
|
|
<div class={classString} role="separator">
|
|
{$slots.default && $slots.default() && (
|
|
<span class={`${prefixCls}-inner-text`}>{$slots.default()}</span>
|
|
)}
|
|
</div>
|
|
);
|
|
},
|
|
};
|
|
|
|
/* istanbul ignore next */
|
|
Divider.install = function(app) {
|
|
app.component(Divider.name, Divider);
|
|
};
|
|
|
|
export default Divider;
|