forked from vueComponent/ant-design-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.jsx
46 lines (41 loc) · 1.35 KB
/
index.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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;