[new feature] Icon: size prop support number type

This commit is contained in:
陈嘉涵
2019-05-04 16:41:01 +08:00
parent b644c91383
commit ca020f3214
8 changed files with 29 additions and 7 deletions
+1 -1
View File
@@ -60,7 +60,7 @@ import 'vant/lib/icon/local.css';
| name | Icon name or URL | `String` | `''` |
| info | Info message | `String | Number` | `''` |
| color | Icon color | `String` | `inherit` |
| size | Icon size | `String` | `inherit` |
| size | Icon size | `String | Number` | `inherit` |
| class-prefix | ClassName prefix | `String` | `van-icon` |
| tag | HTML Tag | `String` | `i` |
+2 -2
View File
@@ -1,4 +1,4 @@
import { use } from '../utils';
import { use, suffixPx } from '../utils';
import { inherit } from '../utils/functional';
import Info from '../info';
import { isSrc } from '../utils/validate/src';
@@ -38,7 +38,7 @@ function Icon(
]}
style={{
color: props.color,
fontSize: props.size
fontSize: suffixPx(props.size)
}}
{...inherit(ctx, true)}
>
@@ -15,6 +15,11 @@ exports[`render icon with url name 1`] = `
<!----></i>
`;
exports[`size without unit 1`] = `
<i class="van-icon van-icon-undefined" style="font-size: 20px;">
<!----></i>
`;
exports[`tag prop 1`] = `
<div class="van-icon van-icon-undefined">
<!---->
+9
View File
@@ -36,3 +36,12 @@ test('tag prop', () => {
});
expect(wrapper).toMatchSnapshot();
});
test('size without unit', () => {
const wrapper = mount(Icon, {
propsData: {
size: 20
}
});
expect(wrapper).toMatchSnapshot();
});
+1 -1
View File
@@ -63,7 +63,7 @@ import 'vant/lib/icon/local.css';
| name | 图标名称或图片链接 | `String` | - | - |
| info | 图标右上角文字提示 | `String | Number` | - | - |
| color | 图标颜色 | `String` | `inherit` | 1.1.3 |
| size | 图标大小,如 `20px` `2em` | `String` | `inherit` | 1.1.15 |
| size | 图标大小,如 `20px` `2em`,默认单位为`px` | `String | Number` | `inherit` | 2.0.0 |
| class-prefix | 类名前缀 | `String` | `van-icon` | 1.2.1 |
| tag | HTML 标签 | `String` | `i` | 1.6.10 |