mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[Improvement] Icon add 'info' prop (#447)
This commit is contained in:
parent
4c18aca42f
commit
a8666591c9
@ -2,7 +2,7 @@
|
|||||||
<demo-section>
|
<demo-section>
|
||||||
<demo-block :title="$t('title')">
|
<demo-block :title="$t('title')">
|
||||||
<van-col span="8" v-for="icon in icons" :key="icon">
|
<van-col span="8" v-for="icon in icons" :key="icon">
|
||||||
<van-icon :name="icon"></van-icon>
|
<van-icon :name="icon" />
|
||||||
<span>{{ icon }}</span>
|
<span>{{ icon }}</span>
|
||||||
</van-col>
|
</van-col>
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
@ -28,3 +28,4 @@ import 'vant/lib/vant-css/icon-local.css';
|
|||||||
| Attribute | Description | Type | Default | Accepted Values |
|
| Attribute | Description | Type | Default | Accepted Values |
|
||||||
|-----------|-----------|-----------|-------------|-------------|
|
|-----------|-----------|-----------|-------------|-------------|
|
||||||
| name | Icon name | `String` | `''` | - |
|
| name | Icon name | `String` | `''` | - |
|
||||||
|
| info | Info message | `String` | `''` | - |
|
||||||
|
@ -28,4 +28,5 @@ import 'vant/lib/vant-css/icon-local.css';
|
|||||||
|
|
||||||
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|
||||||
|-----------|-----------|-----------|-------------|-------------|
|
|-----------|-----------|-----------|-------------|-------------|
|
||||||
| name | icon名称 | `String` | `''` | - |
|
| name | 图标名称 | `String` | `''` | - |
|
||||||
|
| info | 图标右上角文字提示 | `String` | `''` | - |
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<i class="van-icon" :class="`van-icon-${name}`" v-on="$listeners">
|
<i class="van-icon" :class="`van-icon-${name}`" v-on="$listeners">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
|
<div v-if="info" class="van-icon__info">{{ info }}</div>
|
||||||
</i>
|
</i>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -11,7 +12,8 @@ export default {
|
|||||||
install,
|
install,
|
||||||
name: 'van-icon',
|
name: 'van-icon',
|
||||||
props: {
|
props: {
|
||||||
name: String
|
name: String,
|
||||||
|
info: String
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<slot name="icon" :active="active">
|
<slot name="icon" :active="active">
|
||||||
<icon v-if="icon" :name="icon" />
|
<icon v-if="icon" :name="icon" />
|
||||||
</slot>
|
</slot>
|
||||||
<div v-if="info" class="van-tabbar-item__info">{{ info }}</div>
|
<div v-if="info" class="van-icon__info">{{ info }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="van-tabbar-item__text">
|
<div class="van-tabbar-item__text">
|
||||||
<slot :active="active"></slot>
|
<slot :active="active"></slot>
|
||||||
@ -42,8 +42,9 @@ export default create({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onClick() {
|
onClick(event) {
|
||||||
this.$parent.onChange(this.$parent.items.indexOf(this));
|
this.$parent.onChange(this.$parent.items.indexOf(this));
|
||||||
|
this.$emit('click', event);
|
||||||
this.routerLink();
|
this.routerLink();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
@import './common/var.css';
|
||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
@ -11,6 +13,23 @@
|
|||||||
font-size: inherit;
|
font-size: inherit;
|
||||||
text-rendering: auto;
|
text-rendering: auto;
|
||||||
|
|
||||||
|
&__info {
|
||||||
|
color: #fff;
|
||||||
|
left: 50%;
|
||||||
|
top: -.5em;
|
||||||
|
font-size: .5em;
|
||||||
|
margin-left: .8em;
|
||||||
|
padding: 0 .3em;
|
||||||
|
text-align: center;
|
||||||
|
min-width: 1.2em;
|
||||||
|
line-height: 1.2;
|
||||||
|
position: absolute;
|
||||||
|
border-radius: .6em;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background-color: $red;
|
||||||
|
font-family: PingFang SC, Helvetica Neue, Arial, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
&:before {
|
&:before {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
@import './common/var.css';
|
||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
@ -6,11 +8,29 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.van-icon {
|
.van-icon {
|
||||||
|
position: relative;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
font: normal normal normal 14px/1 "vant-icon";
|
font: normal normal normal 14px/1 "vant-icon";
|
||||||
font-size: inherit;
|
font-size: inherit;
|
||||||
text-rendering: auto;
|
text-rendering: auto;
|
||||||
|
|
||||||
|
&__info {
|
||||||
|
color: #fff;
|
||||||
|
left: 50%;
|
||||||
|
top: -.5em;
|
||||||
|
font-size: .5em;
|
||||||
|
margin-left: .8em;
|
||||||
|
padding: 0 .3em;
|
||||||
|
text-align: center;
|
||||||
|
min-width: 1.2em;
|
||||||
|
line-height: 1.2;
|
||||||
|
position: absolute;
|
||||||
|
border-radius: .6em;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background-color: $red;
|
||||||
|
font-family: PingFang SC, Helvetica Neue, Arial, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
&:before {
|
&:before {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
@ -49,22 +49,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__info {
|
|
||||||
color: #fff;
|
|
||||||
top: -5px;
|
|
||||||
right: -100%;
|
|
||||||
font-size: 12px;
|
|
||||||
transform: scale(.8);
|
|
||||||
box-sizing: border-box;
|
|
||||||
padding: 0 3px;
|
|
||||||
text-align: center;
|
|
||||||
min-width: 18px;
|
|
||||||
line-height: 18px;
|
|
||||||
border-radius: 9px;
|
|
||||||
background-color: $red;
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
|
|
||||||
&--active {
|
&--active {
|
||||||
color: $blue;
|
color: $blue;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user