[new feature] CellGroup: add title prop (#2928)

This commit is contained in:
neverland
2019-03-09 11:04:58 +08:00
committed by GitHub
parent 2297baa917
commit 4d0e3d6644
6 changed files with 86 additions and 1 deletions
+7
View File
@@ -2,4 +2,11 @@
.van-cell-group {
background-color: @white;
&__title {
font-size: 14px;
padding: 15px 15px 5px;
color: @gray-dark;
line-height: 16px;
}
}
+14 -1
View File
@@ -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