mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
feat(Icon): add dot prop (#2063)
This commit is contained in:
parent
d1169348ae
commit
a6fea1bc6f
@ -87,6 +87,8 @@
|
|||||||
@info-font-weight: 500;
|
@info-font-weight: 500;
|
||||||
@info-border-width: 1px;
|
@info-border-width: 1px;
|
||||||
@info-background-color: @red;
|
@info-background-color: @red;
|
||||||
|
@info-dot-color: @red;
|
||||||
|
@info-dot-size: 8px;
|
||||||
@info-font-family: PingFang SC, Helvetica Neue, Arial, sans-serif;
|
@info-font-family: PingFang SC, Helvetica Neue, Arial, sans-serif;
|
||||||
|
|
||||||
// NavBar
|
// NavBar
|
||||||
|
@ -25,9 +25,12 @@
|
|||||||
<van-icon name="https://b.yzcdn.cn/vant/icon-demo-1126.png" />
|
<van-icon name="https://b.yzcdn.cn/vant/icon-demo-1126.png" />
|
||||||
```
|
```
|
||||||
|
|
||||||
### 显示徽标
|
### 提示信息
|
||||||
|
|
||||||
|
设置`dot`属性后,会在图标右上角展示一个小红点。设置`info`属性后,会在图标右上角展示相应的徽标
|
||||||
|
|
||||||
```html
|
```html
|
||||||
|
<van-icon name="chat" dot />
|
||||||
<van-icon name="chat" info="9" />
|
<van-icon name="chat" info="9" />
|
||||||
<van-icon name="chat" info="99+" />
|
<van-icon name="chat" info="99+" />
|
||||||
```
|
```
|
||||||
@ -39,6 +42,7 @@
|
|||||||
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
||||||
|-----------|-----------|-----------|-------------|-------------|
|
|-----------|-----------|-----------|-------------|-------------|
|
||||||
| name | 图标名称或图片链接 | *string* | - | - |
|
| name | 图标名称或图片链接 | *string* | - | - |
|
||||||
|
| dot | 是否显示图标右上角小红点 | *boolean* | `false` | - |
|
||||||
| info | 图标右上角文字提示 | *string \| number* | - | - |
|
| info | 图标右上角文字提示 | *string \| number* | - | - |
|
||||||
| color | 图标颜色 | *string* | `inherit` | - |
|
| color | 图标颜色 | *string* | `inherit` | - |
|
||||||
| size | 图标大小,如 `20px`,`2em`,默认单位为`px` | *string \| number* | `inherit` | - |
|
| size | 图标大小,如 `20px`,`2em`,默认单位为`px` | *string \| number* | `inherit` | - |
|
||||||
|
@ -3,6 +3,7 @@ import { addUnit } from '../common/utils';
|
|||||||
|
|
||||||
VantComponent({
|
VantComponent({
|
||||||
props: {
|
props: {
|
||||||
|
dot: Boolean,
|
||||||
info: null,
|
info: null,
|
||||||
size: {
|
size: {
|
||||||
type: null,
|
type: null,
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
bind:tap="onClick"
|
bind:tap="onClick"
|
||||||
>
|
>
|
||||||
<van-info
|
<van-info
|
||||||
wx:if="{{ info !== null }}"
|
wx:if="{{ info !== null || dot }}"
|
||||||
|
dot="{{ dot }}"
|
||||||
info="{{ info }}"
|
info="{{ info }}"
|
||||||
custom-class="van-icon__info"
|
custom-class="van-icon__info"
|
||||||
/>
|
/>
|
||||||
|
@ -21,4 +21,12 @@
|
|||||||
.theme(background-color, '@info-background-color');
|
.theme(background-color, '@info-background-color');
|
||||||
.theme(border, '@info-border-width solid @white');
|
.theme(border, '@info-border-width solid @white');
|
||||||
.theme(border-radius, '@info-size');
|
.theme(border-radius, '@info-size');
|
||||||
|
|
||||||
|
&--dot {
|
||||||
|
min-width: 0;
|
||||||
|
border-radius: 100%;
|
||||||
|
.theme(width, '@info-dot-size');
|
||||||
|
.theme(height, '@info-dot-size');
|
||||||
|
.theme(background-color, '@info-dot-color');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import { VantComponent } from '../common/component';
|
|||||||
|
|
||||||
VantComponent({
|
VantComponent({
|
||||||
props: {
|
props: {
|
||||||
|
dot: Boolean,
|
||||||
info: null,
|
info: null,
|
||||||
customStyle: String
|
customStyle: String
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||||
|
|
||||||
<view
|
<view
|
||||||
wx:if="{{ info !== null && info !== '' }}"
|
wx:if="{{ info !== null && info !== '' || dot }}"
|
||||||
class="custom-class van-info"
|
class="custom-class van-info {{ utils.bem('info', { dot }) }}"
|
||||||
style="{{ customStyle }}"
|
style="{{ customStyle }}"
|
||||||
>{{ info }}</view>
|
>{{ dot ? '' : info }}</view>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user