Skip to content

Commit

Permalink
refactor(divider): refactor with ts (vueComponent#2928)
Browse files Browse the repository at this point in the history
* refactor(divider): refactor with ts

* refactor(divider): add default value for dashed prop

* style(divider): remove unuse import
  • Loading branch information
John60676 authored Sep 30, 2020
1 parent 28111e7 commit a1a4fdb
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 45 deletions.
45 changes: 0 additions & 45 deletions components/divider/index.jsx

This file was deleted.

52 changes: 52 additions & 0 deletions components/divider/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { App, computed, defineComponent, inject, PropType, unref } from 'vue';
import { defaultConfigProvider } from '../config-provider';

const Divider = defineComponent({
name: 'ADivider',
props: {
prefixCls: String,
type: {
type: String as PropType<'horizontal' | 'vertical' | ''>,
default: 'horizontal',
},
dashed: {
type: Boolean,
default: false,
},
orientation: {
type: String as PropType<'left' | 'right' | 'center'>,
default: 'center',
},
},
setup(props, { slots }) {
const { getPrefixCls } = inject('configProvider', defaultConfigProvider);
const prefixCls = computed(() => getPrefixCls('divider', props.prefixCls));

const classString = computed(() => {
const { type, dashed, orientation } = props;
const orientationPrefix = orientation.length > 0 ? '-' + orientation : orientation;
const prefixClsRef = unref(prefixCls);
return {
[prefixClsRef]: true,
[`${prefixClsRef}-${type}`]: true,
[`${prefixClsRef}-with-text${orientationPrefix}`]: slots.default,
[`${prefixClsRef}-dashed`]: !!dashed,
};
});

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

/* istanbul ignore next */
Divider.install = function(app: App) {
app.component(Divider.name, Divider);
};

export default Divider;
File renamed without changes.

0 comments on commit a1a4fdb

Please sign in to comment.