mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(Cell): cell-group add inset prop (#9055)
* feat(Cell): cell-group add inset prop * style(CellGroup): prettier * docs(Cell): format doc
This commit is contained in:
parent
93b502b17b
commit
3d84598cbd
@ -3,10 +3,20 @@
|
|||||||
.van-cell-group {
|
.van-cell-group {
|
||||||
background-color: @cell-group-background-color;
|
background-color: @cell-group-background-color;
|
||||||
|
|
||||||
|
&--inset {
|
||||||
|
margin: @cell-group-inset-padding;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: @cell-group-inset-border-radius;
|
||||||
|
}
|
||||||
|
|
||||||
&__title {
|
&__title {
|
||||||
padding: @cell-group-title-padding;
|
padding: @cell-group-title-padding;
|
||||||
color: @cell-group-title-color;
|
color: @cell-group-title-color;
|
||||||
font-size: @cell-group-title-font-size;
|
font-size: @cell-group-title-font-size;
|
||||||
line-height: @cell-group-title-line-height;
|
line-height: @cell-group-title-line-height;
|
||||||
|
|
||||||
|
&--inset {
|
||||||
|
padding: @cell-group-inset-title-padding;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import { DefaultSlots, ScopedSlot } from '../utils/types';
|
|||||||
|
|
||||||
export type CellGroupProps = {
|
export type CellGroupProps = {
|
||||||
title?: string;
|
title?: string;
|
||||||
|
inset: boolean;
|
||||||
border: boolean;
|
border: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -26,7 +27,10 @@ function CellGroup(
|
|||||||
) {
|
) {
|
||||||
const Group = (
|
const Group = (
|
||||||
<div
|
<div
|
||||||
class={[bem(), { [BORDER_TOP_BOTTOM]: props.border }]}
|
class={[
|
||||||
|
bem({ inset: props.inset }),
|
||||||
|
{ [BORDER_TOP_BOTTOM]: props.border },
|
||||||
|
]}
|
||||||
{...inherit(ctx, true)}
|
{...inherit(ctx, true)}
|
||||||
>
|
>
|
||||||
{slots.default?.()}
|
{slots.default?.()}
|
||||||
@ -36,7 +40,7 @@ function CellGroup(
|
|||||||
if (props.title || slots.title) {
|
if (props.title || slots.title) {
|
||||||
return (
|
return (
|
||||||
<div key={ctx.data.key}>
|
<div key={ctx.data.key}>
|
||||||
<div class={bem('title')}>
|
<div class={bem('title', { inset: props.inset })}>
|
||||||
{slots.title ? slots.title() : props.title}
|
{slots.title ? slots.title() : props.title}
|
||||||
</div>
|
</div>
|
||||||
{Group}
|
{Group}
|
||||||
@ -49,6 +53,7 @@ function CellGroup(
|
|||||||
|
|
||||||
CellGroup.props = {
|
CellGroup.props = {
|
||||||
title: String,
|
title: String,
|
||||||
|
inset: Boolean,
|
||||||
border: {
|
border: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
|
@ -21,6 +21,15 @@ Vue.use(CellGroup);
|
|||||||
</van-cell-group>
|
</van-cell-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Inset Grouped
|
||||||
|
|
||||||
|
```html
|
||||||
|
<van-cell-group inset>
|
||||||
|
<van-cell title="Cell title" value="Content" />
|
||||||
|
<van-cell title="Cell title" value="Content" label="Description" />
|
||||||
|
</van-cell-group>
|
||||||
|
```
|
||||||
|
|
||||||
### Size
|
### Size
|
||||||
|
|
||||||
```html
|
```html
|
||||||
@ -130,7 +139,7 @@ Vue.use(CellGroup);
|
|||||||
### Cell Props
|
### Cell Props
|
||||||
|
|
||||||
| Attribute | Description | Type | Default |
|
| Attribute | Description | Type | Default |
|
||||||
| --- | --- | --- | --- |
|
| -------------------- | ------------------------------------------------------- | ------------------ | ---------- |
|
||||||
| title | Title | _number \| string_ | - |
|
| title | Title | _number \| string_ | - |
|
||||||
| value | Right text | _number \| string_ | - |
|
| value | Right text | _number \| string_ | - |
|
||||||
| label | Description below the title | _string_ | - |
|
| label | Description below the title | _string_ | - |
|
||||||
@ -180,7 +189,7 @@ Vue.use(CellGroup);
|
|||||||
How to use: [Custom Theme](#/en-US/theme).
|
How to use: [Custom Theme](#/en-US/theme).
|
||||||
|
|
||||||
| Name | Default Value | Description |
|
| Name | Default Value | Description |
|
||||||
| --- | --- | --- |
|
| ----------------------------- | ------------------------------------- | ----------- |
|
||||||
| @cell-font-size | `@font-size-md` | - |
|
| @cell-font-size | `@font-size-md` | - |
|
||||||
| @cell-line-height | `24px` | - |
|
| @cell-line-height | `24px` | - |
|
||||||
| @cell-vertical-padding | `10px` | - |
|
| @cell-vertical-padding | `10px` | - |
|
||||||
|
@ -27,6 +27,17 @@ Vue.use(CellGroup);
|
|||||||
</van-cell-group>
|
</van-cell-group>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 卡片风格
|
||||||
|
|
||||||
|
通过 `CellGroup` 的 `inset` 属性,可以将单元格转换为圆角卡片风格(从 2.12.25 版本开始支持)。
|
||||||
|
|
||||||
|
```html
|
||||||
|
<van-cell-group inset>
|
||||||
|
<van-cell title="单元格" value="内容" />
|
||||||
|
<van-cell title="单元格" value="内容" label="描述信息" />
|
||||||
|
</van-cell-group>
|
||||||
|
```
|
||||||
|
|
||||||
### 单元格大小
|
### 单元格大小
|
||||||
|
|
||||||
通过 `size` 属性可以控制单元格的大小。
|
通过 `size` 属性可以控制单元格的大小。
|
||||||
@ -137,7 +148,7 @@ Vue.use(CellGroup);
|
|||||||
### Cell Props
|
### Cell Props
|
||||||
|
|
||||||
| 参数 | 说明 | 类型 | 默认值 |
|
| 参数 | 说明 | 类型 | 默认值 |
|
||||||
| --- | --- | --- | --- |
|
| -------------------- | ----------------------------------------------------------------------------------------- | ------------------ | ---------- |
|
||||||
| title | 左侧标题 | _number \| string_ | - |
|
| title | 左侧标题 | _number \| string_ | - |
|
||||||
| value | 右侧内容 | _number \| string_ | - |
|
| value | 右侧内容 | _number \| string_ | - |
|
||||||
| label | 标题下方的描述信息 | _string_ | - |
|
| label | 标题下方的描述信息 | _string_ | - |
|
||||||
|
@ -7,6 +7,13 @@
|
|||||||
</van-cell-group>
|
</van-cell-group>
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
|
<demo-block :title="t('insetGrouped')">
|
||||||
|
<van-cell-group inset>
|
||||||
|
<van-cell :title="t('cell')" :value="t('content')" />
|
||||||
|
<van-cell :title="t('cell')" :value="t('content')" :label="t('desc')" />
|
||||||
|
</van-cell-group>
|
||||||
|
</demo-block>
|
||||||
|
|
||||||
<demo-block :title="t('largeSize')">
|
<demo-block :title="t('largeSize')">
|
||||||
<van-cell :title="t('cell')" :value="t('content')" size="large" />
|
<van-cell :title="t('cell')" :value="t('content')" size="large" />
|
||||||
<van-cell
|
<van-cell
|
||||||
@ -91,6 +98,7 @@ export default {
|
|||||||
urlRoute: 'URL 跳转',
|
urlRoute: 'URL 跳转',
|
||||||
vueRoute: '路由跳转',
|
vueRoute: '路由跳转',
|
||||||
useSlots: '使用插槽',
|
useSlots: '使用插槽',
|
||||||
|
insetGrouped: '卡片风格',
|
||||||
verticalCenter: '垂直居中',
|
verticalCenter: '垂直居中',
|
||||||
},
|
},
|
||||||
'en-US': {
|
'en-US': {
|
||||||
@ -105,6 +113,7 @@ export default {
|
|||||||
urlRoute: 'URL',
|
urlRoute: 'URL',
|
||||||
vueRoute: 'Vue Router',
|
vueRoute: 'Vue Router',
|
||||||
useSlots: 'Use Slots',
|
useSlots: 'Use Slots',
|
||||||
|
insetGrouped: 'Inset Grouped',
|
||||||
verticalCenter: 'Vertical center',
|
verticalCenter: 'Vertical center',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -16,6 +16,20 @@ exports[`renders demo correctly 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="van-cell-group van-cell-group--inset van-hairline--top-bottom">
|
||||||
|
<div class="van-cell">
|
||||||
|
<div class="van-cell__title"><span>单元格</span></div>
|
||||||
|
<div class="van-cell__value"><span>内容</span></div>
|
||||||
|
</div>
|
||||||
|
<div class="van-cell">
|
||||||
|
<div class="van-cell__title"><span>单元格</span>
|
||||||
|
<div class="van-cell__label">描述信息</div>
|
||||||
|
</div>
|
||||||
|
<div class="van-cell__value"><span>内容</span></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="van-cell van-cell--large">
|
<div class="van-cell van-cell--large">
|
||||||
<div class="van-cell__title"><span>单元格</span></div>
|
<div class="van-cell__title"><span>单元格</span></div>
|
||||||
|
@ -242,6 +242,9 @@
|
|||||||
@cell-group-title-padding: @padding-md @padding-md @padding-xs;
|
@cell-group-title-padding: @padding-md @padding-md @padding-xs;
|
||||||
@cell-group-title-font-size: @font-size-md;
|
@cell-group-title-font-size: @font-size-md;
|
||||||
@cell-group-title-line-height: 16px;
|
@cell-group-title-line-height: 16px;
|
||||||
|
@cell-group-inset-padding: 0 @padding-md;
|
||||||
|
@cell-group-inset-border-radius: @border-radius-lg;
|
||||||
|
@cell-group-inset-title-padding: @padding-md @padding-md @padding-xs @padding-xl;
|
||||||
|
|
||||||
// Checkbox
|
// Checkbox
|
||||||
@checkbox-size: 20px;
|
@checkbox-size: 20px;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user