[new feature] CellGroup: add title prop (#2928)
This commit is contained in:
@@ -2,4 +2,11 @@
|
||||
|
||||
.van-cell-group {
|
||||
background-color: @white;
|
||||
|
||||
&__title {
|
||||
font-size: 14px;
|
||||
padding: 15px 15px 5px;
|
||||
color: @gray-dark;
|
||||
line-height: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { CreateElement, RenderContext } from 'vue/types';
|
||||
import { DefaultSlots } from '../utils/use/sfc';
|
||||
|
||||
export type CellGroupProps = {
|
||||
title?: string;
|
||||
border: boolean
|
||||
};
|
||||
|
||||
@@ -17,7 +18,7 @@ function CellGroup(
|
||||
slots: DefaultSlots,
|
||||
ctx: RenderContext<CellGroupProps>
|
||||
) {
|
||||
return (
|
||||
const Group = (
|
||||
<div
|
||||
class={[bem(), { 'van-hairline--top-bottom': props.border }]}
|
||||
{...inherit(ctx, true)}
|
||||
@@ -25,9 +26,21 @@ function CellGroup(
|
||||
{slots.default && slots.default()}
|
||||
</div>
|
||||
);
|
||||
|
||||
if (props.title) {
|
||||
return (
|
||||
<div>
|
||||
<div class={bem('title')}>{props.title}</div>
|
||||
{Group}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return Group;
|
||||
}
|
||||
|
||||
CellGroup.props = {
|
||||
title: String,
|
||||
border: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
|
||||
Reference in New Issue
Block a user