Skip to content

feat: update divider #2357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions components/divider/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { inject } from 'vue';
import PropTypes from '../_util/vue-types';
import { ConfigConsumerProps } from '../config-provider';
import Base from '../base';

const Divider = {
name: 'ADivider',
Expand All @@ -10,8 +10,10 @@ const Divider = {
dashed: PropTypes.bool,
orientation: PropTypes.oneOf(['left', 'right', 'center']),
},
inject: {
configProvider: { default: () => ConfigConsumerProps },
setup() {
return {
configProvider: inject('configProvider', ConfigConsumerProps),
};
},
render() {
const { prefixCls: customizePrefixCls, type, $slots, dashed, orientation = 'center' } = this;
Expand All @@ -28,16 +30,17 @@ const Divider = {

return (
<div class={classString} role="separator">
{$slots.default && <span class={`${prefixCls}-inner-text`}>{$slots.default}</span>}
{$slots.default && $slots.default() && (
<span class={`${prefixCls}-inner-text`}>{$slots.default()}</span>
)}
</div>
);
},
};

/* istanbul ignore next */
Divider.install = function(Vue) {
Vue.use(Base);
Vue.component(Divider.name, Divider);
Divider.install = function(app) {
app.component(Divider.name, Divider);
};

export default Divider;
2 changes: 2 additions & 0 deletions examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Button from 'ant-design-vue/button';
import Drawer from 'ant-design-vue/drawer';
import Affix from 'ant-design-vue/affix';
import Alert from 'ant-design-vue/alert';
import Divider from 'ant-design-vue/divider';
import ConfigProvider from 'ant-design-vue/config-provider';
import Spin from 'ant-design-vue/Spin';
import Empty from 'ant-design-vue/empty';
Expand All @@ -16,6 +17,7 @@ createApp(App)
.use(Drawer)
.use(Affix)
.use(Alert)
.use(Divider)
.use(Spin)
.use(Empty)
.mount('#app');