mirror of
https://github.com/youzan/vant.git
synced 2026-01-23 01:07:55 +08:00
chore: merge src and src-next
This commit is contained in:
33
src/divider/index.js
Normal file
33
src/divider/index.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import { createNamespace } from '../utils';
|
||||
|
||||
const [createComponent, bem] = createNamespace('divider');
|
||||
|
||||
export default createComponent({
|
||||
props: {
|
||||
dashed: Boolean,
|
||||
hairline: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
contentPosition: {
|
||||
type: String,
|
||||
default: 'center',
|
||||
},
|
||||
},
|
||||
|
||||
render() {
|
||||
const Content = this.$slots.default?.();
|
||||
return (
|
||||
<div
|
||||
role="separator"
|
||||
class={bem({
|
||||
dashed: this.dashed,
|
||||
hairline: this.hairline,
|
||||
[`content-${this.contentPosition}`]: !!Content,
|
||||
})}
|
||||
>
|
||||
{Content}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -1,52 +0,0 @@
|
||||
// Utils
|
||||
import { createNamespace } from '../utils';
|
||||
import { inherit } from '../utils/functional';
|
||||
|
||||
// Types
|
||||
import { CreateElement, RenderContext } from 'vue/types';
|
||||
import { DefaultSlots } from '../utils/types';
|
||||
|
||||
export type DividerProps = {
|
||||
dashed?: boolean;
|
||||
hairline: boolean;
|
||||
borderColor?: string;
|
||||
contentPosition: 'left' | 'center' | 'right';
|
||||
};
|
||||
|
||||
const [createComponent, bem] = createNamespace('divider');
|
||||
|
||||
function Divider(
|
||||
h: CreateElement,
|
||||
props: DividerProps,
|
||||
slots: DefaultSlots,
|
||||
ctx: RenderContext
|
||||
) {
|
||||
return (
|
||||
<div
|
||||
role="separator"
|
||||
style={{ borderColor: props.borderColor }}
|
||||
class={bem({
|
||||
dashed: props.dashed,
|
||||
hairline: props.hairline,
|
||||
[`content-${props.contentPosition}`]: slots.default,
|
||||
})}
|
||||
{...inherit(ctx, true)}
|
||||
>
|
||||
{slots.default && slots.default()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Divider.props = {
|
||||
dashed: Boolean,
|
||||
hairline: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
contentPosition: {
|
||||
type: String,
|
||||
default: 'center',
|
||||
},
|
||||
};
|
||||
|
||||
export default createComponent<DividerProps>(Divider);
|
||||
Reference in New Issue
Block a user