refactor: reorganize all components (#8303)
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { createNamespace } from '../utils';
|
||||
import { BORDER_TOP_BOTTOM } from '../utils/constant';
|
||||
|
||||
const [name, bem] = createNamespace('cell-group');
|
||||
|
||||
export default defineComponent({
|
||||
name,
|
||||
|
||||
inheritAttrs: false,
|
||||
|
||||
props: {
|
||||
title: String,
|
||||
border: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
|
||||
setup(props, { slots, attrs }) {
|
||||
const renderGroup = () => (
|
||||
<div class={[bem(), { [BORDER_TOP_BOTTOM]: props.border }]} {...attrs}>
|
||||
{slots.default?.()}
|
||||
</div>
|
||||
);
|
||||
|
||||
const renderTitle = () => (
|
||||
<div class={bem('title')}>
|
||||
{slots.title ? slots.title() : props.title}
|
||||
</div>
|
||||
);
|
||||
|
||||
return () => {
|
||||
if (props.title || slots.title) {
|
||||
return (
|
||||
<>
|
||||
{renderTitle()}
|
||||
{renderGroup()}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return renderGroup();
|
||||
};
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user