mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(GridItem): add reverse prop (#8878)
This commit is contained in:
parent
41d95829ba
commit
e28ac72484
@ -113,14 +113,8 @@ export default defineComponent({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
const {
|
const { center, border, square, gutter, reverse, direction, clickable } =
|
||||||
center,
|
parent.props;
|
||||||
border,
|
|
||||||
square,
|
|
||||||
gutter,
|
|
||||||
direction,
|
|
||||||
clickable,
|
|
||||||
} = parent.props;
|
|
||||||
|
|
||||||
const classes = [
|
const classes = [
|
||||||
bem('content', [
|
bem('content', [
|
||||||
@ -128,6 +122,7 @@ export default defineComponent({
|
|||||||
{
|
{
|
||||||
center,
|
center,
|
||||||
square,
|
square,
|
||||||
|
reverse,
|
||||||
clickable,
|
clickable,
|
||||||
surround: border && gutter,
|
surround: border && gutter,
|
||||||
},
|
},
|
||||||
|
@ -62,9 +62,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 var(--van-padding-xs);
|
||||||
margin-left: var(--van-padding-xs);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&--reverse {
|
||||||
|
flex-direction: column-reverse;
|
||||||
|
|
||||||
|
.van-grid-item__text {
|
||||||
|
margin: 0 0 var(--van-padding-xs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&--horizontal&--reverse {
|
||||||
|
flex-direction: row-reverse;
|
||||||
|
|
||||||
|
.van-grid-item__text {
|
||||||
|
margin: 0 var(--van-padding-xs) 0 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ const props = {
|
|||||||
center: truthProp,
|
center: truthProp,
|
||||||
border: truthProp,
|
border: truthProp,
|
||||||
gutter: [Number, String],
|
gutter: [Number, String],
|
||||||
|
reverse: Boolean,
|
||||||
iconSize: [Number, String],
|
iconSize: [Number, String],
|
||||||
direction: String as PropType<GridDirection>,
|
direction: String as PropType<GridDirection>,
|
||||||
clickable: Boolean,
|
clickable: Boolean,
|
||||||
|
@ -121,6 +121,7 @@ app.use(GridItem);
|
|||||||
| icon | Icon name or URL | _string_ | - |
|
| icon | Icon name or URL | _string_ | - |
|
||||||
| icon-prefix | Icon className prefix | _string_ | `van-icon` |
|
| icon-prefix | Icon className prefix | _string_ | `van-icon` |
|
||||||
| icon-color | Icon color | _string_ | - |
|
| icon-color | Icon color | _string_ | - |
|
||||||
|
| reverse `v3.1.0` | Whether to reverse the position of icon and text | _boolean_ | `false` |
|
||||||
| dot | Whether to show red dot | _boolean_ | `false` |
|
| dot | Whether to show red dot | _boolean_ | `false` |
|
||||||
| badge | Content of the badge | _number \| string_ | - |
|
| badge | Content of the badge | _number \| string_ | - |
|
||||||
| url | Link URL | _string_ | - |
|
| url | Link URL | _string_ | - |
|
||||||
|
@ -137,6 +137,7 @@ app.use(GridItem);
|
|||||||
| icon | [图标名称](#/zh-CN/icon)或图片链接 | _string_ | - |
|
| icon | [图标名称](#/zh-CN/icon)或图片链接 | _string_ | - |
|
||||||
| icon-prefix | 图标类名前缀,同 Icon 组件的 [class-prefix 属性](#/zh-CN/icon#props) | _string_ | `van-icon` |
|
| icon-prefix | 图标类名前缀,同 Icon 组件的 [class-prefix 属性](#/zh-CN/icon#props) | _string_ | `van-icon` |
|
||||||
| icon-color | 图标颜色,同 Icon 组件的 [color 属性](#/zh-CN/icon#props) | _string_ | - |
|
| icon-color | 图标颜色,同 Icon 组件的 [color 属性](#/zh-CN/icon#props) | _string_ | - |
|
||||||
|
| reverse `v3.1.0` | 是否调换图标和文本的位置 | _boolean_ | `false` |
|
||||||
| dot | 是否显示图标右上角小红点 | _boolean_ | `false` |
|
| dot | 是否显示图标右上角小红点 | _boolean_ | `false` |
|
||||||
| badge | 图标右上角徽标的内容 | _number \| string_ | - |
|
| badge | 图标右上角徽标的内容 | _number \| string_ | - |
|
||||||
| url | 点击后跳转的链接地址 | _string_ | - |
|
| url | 点击后跳转的链接地址 | _string_ | - |
|
||||||
|
@ -58,3 +58,19 @@ test('should render icon-slot correctly', () => {
|
|||||||
|
|
||||||
expect(wrapper.html()).toMatchSnapshot();
|
expect(wrapper.html()).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should render ".van-grid-item__content--reverse" class when using reverse prop', () => {
|
||||||
|
const wrapper = mount({
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<Grid reverse>
|
||||||
|
<GridItem />
|
||||||
|
</Grid>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper.find('.van-grid-item__content').classes()).toContain(
|
||||||
|
'van-grid-item__content--reverse'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user