feat(Grid): add reverse prop (#4280)

* Update index.ts

* doc(Grid): add reverse prop

* feat(GridItem): reverse prop

* Update index.wxml

* Update index.less

* Update index.less

* Update style
This commit is contained in:
agoni1212 2021-06-26 20:58:33 +08:00 committed by GitHub
parent ad4753988a
commit 41e8565ee4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 4 deletions

View File

@ -44,9 +44,24 @@
&--horizontal { &--horizontal {
flex-direction: row; flex-direction: row;
.van-grid-item__icon + .van-grid-item__text { .van-grid-item__text {
margin-top: 0; margin: 0 0 0 @padding-xs;
margin-left: @padding-xs; }
}
&--reverse {
flex-direction: column-reverse;
.van-grid-item__text {
margin: 0 0 @padding-xs;
}
}
&--horizontal&--reverse {
flex-direction: row-reverse;
.van-grid-item__text {
margin: 0 @padding-xs 0 0;
} }
} }

View File

@ -43,6 +43,7 @@ VantComponent({
clickable, clickable,
center, center,
direction, direction,
reverse,
iconSize, iconSize,
} = data; } = data;
@ -53,6 +54,7 @@ VantComponent({
gutter, gutter,
clickable, clickable,
direction, direction,
reverse,
iconSize, iconSize,
index: children.indexOf(this), index: children.indexOf(this),
columnNum, columnNum,

View File

@ -7,7 +7,7 @@
bindtap="onClick" bindtap="onClick"
> >
<view <view
class="content-class {{ utils.bem('grid-item__content', [direction, { center, square, clickable, surround: border && gutter }]) }} {{ border ? 'van-hairline--surround' : '' }}" class="content-class {{ utils.bem('grid-item__content', [direction, { center, square, reverse, clickable, surround: border && gutter }]) }} {{ border ? 'van-hairline--surround' : '' }}"
style="{{ computed.contentStyle({ square, gutter }) }}" style="{{ computed.contentStyle({ square, gutter }) }}"
> >
<block wx:if="{{ useSlot }}"> <block wx:if="{{ useSlot }}">

View File

@ -135,6 +135,7 @@
| square | 是否将格子固定为正方形 | _boolean_ | `false` | - | | square | 是否将格子固定为正方形 | _boolean_ | `false` | - |
| clickable | 是否开启格子点击反馈 | _boolean_ | `false` | - | | clickable | 是否开启格子点击反馈 | _boolean_ | `false` | - |
| direction | 格子内容排列的方向,可选值为 `horizontal` | _string_ | `vertical` | - | | direction | 格子内容排列的方向,可选值为 `horizontal` | _string_ | `vertical` | - |
| reverse `v1.7.0` | 是否调换图标和文本的位置 | _boolean_ | `false` |
| use-slot | 是否使用自定义内容的插槽 | _boolean_ | `false` | | use-slot | 是否使用自定义内容的插槽 | _boolean_ | `false` |
### Grid 外部样式类 ### Grid 外部样式类

View File

@ -41,6 +41,11 @@ VantComponent({
type: String, type: String,
observer: 'updateChildren', observer: 'updateChildren',
}, },
reverse: {
type: Boolean,
value: false,
observer: 'updateChildren',
},
}, },
methods: { methods: {