@tuya-miniapp/smart-ui 2.3.2 → 2.3.3-beta-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/calendar/calendar.wxml +1 -1
- package/dist/icon/index.wxml +5 -0
- package/dist/icon/index.wxs +32 -5
- package/lib/calendar/calendar.wxml +1 -1
- package/lib/icon/index.wxml +5 -0
- package/lib/icon/index.wxs +32 -5
- package/package.json +1 -1
package/dist/icon/index.wxml
CHANGED
package/dist/icon/index.wxs
CHANGED
@@ -6,6 +6,10 @@ function isImage(name) {
|
|
6
6
|
return name.indexOf('/') !== -1;
|
7
7
|
}
|
8
8
|
|
9
|
+
function isSvgPath(name) {
|
10
|
+
return name.indexOf(' ') !== -1;
|
11
|
+
}
|
12
|
+
|
9
13
|
function isSvg(name) {
|
10
14
|
return name.indexOf('data:image/svg+xml') !== -1;
|
11
15
|
}
|
@@ -20,10 +24,9 @@ function rootClass(data) {
|
|
20
24
|
if (data.classPrefix != null) {
|
21
25
|
classes.push(data.classPrefix);
|
22
26
|
}
|
23
|
-
|
24
|
-
if (isImage(data.name)) {
|
27
|
+
if (isImage(data.name) || isSvgPath(data.name)) {
|
25
28
|
classes.push('smart-icon--image');
|
26
|
-
if (isSvg(data.name)) classes.push('smart-icon--svg');
|
29
|
+
if (isSvg(data.name) || isSvgPath(data.name)) classes.push('smart-icon--svg');
|
27
30
|
} else if (data.classPrefix != null) {
|
28
31
|
classes.push(data.classPrefix + '-' + data.name);
|
29
32
|
}
|
@@ -58,8 +61,30 @@ function svgStyle(data) {
|
|
58
61
|
'-webkit-mask-position': 'center',
|
59
62
|
'mask-image': imageBase64Src,
|
60
63
|
'mask-size': 'contain',
|
61
|
-
|
62
|
-
|
64
|
+
background: data.color,
|
65
|
+
},
|
66
|
+
]);
|
67
|
+
return ret;
|
68
|
+
}
|
69
|
+
function svgPathStyle(data) {
|
70
|
+
const { name, color } = data;
|
71
|
+
// 构建SVG字符串
|
72
|
+
const svg = `
|
73
|
+
<svg class="icon" width="100%" height="100%" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
74
|
+
<path d="${name}" fill="${color || 'currentColor'}" fill-rule="evenodd"></path>
|
75
|
+
</svg>
|
76
|
+
`;
|
77
|
+
|
78
|
+
const imageBase64Src = `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
|
79
|
+
var ret = style([
|
80
|
+
{
|
81
|
+
|
82
|
+
'-webkit-mask-image': imageBase64Src,
|
83
|
+
'-webkit-mask-size': 'contain',
|
84
|
+
'-webkit-mask-repeat': 'no-repeat',
|
85
|
+
'-webkit-mask-position': 'center',
|
86
|
+
'mask-image': imageBase64Src,
|
87
|
+
'mask-size': 'contain',
|
63
88
|
background: data.color,
|
64
89
|
},
|
65
90
|
]);
|
@@ -69,8 +94,10 @@ function svgStyle(data) {
|
|
69
94
|
module.exports = {
|
70
95
|
isImage: isImage,
|
71
96
|
isSvg: isSvg,
|
97
|
+
isSvgPath: isSvgPath,
|
72
98
|
getImageSrc: getImageSrc,
|
73
99
|
rootClass: rootClass,
|
74
100
|
rootStyle: rootStyle,
|
75
101
|
svgStyle: svgStyle,
|
102
|
+
svgPathStyle: svgPathStyle,
|
76
103
|
};
|
package/lib/icon/index.wxml
CHANGED
package/lib/icon/index.wxs
CHANGED
@@ -6,6 +6,10 @@ function isImage(name) {
|
|
6
6
|
return name.indexOf('/') !== -1;
|
7
7
|
}
|
8
8
|
|
9
|
+
function isSvgPath(name) {
|
10
|
+
return name.indexOf(' ') !== -1;
|
11
|
+
}
|
12
|
+
|
9
13
|
function isSvg(name) {
|
10
14
|
return name.indexOf('data:image/svg+xml') !== -1;
|
11
15
|
}
|
@@ -20,10 +24,9 @@ function rootClass(data) {
|
|
20
24
|
if (data.classPrefix != null) {
|
21
25
|
classes.push(data.classPrefix);
|
22
26
|
}
|
23
|
-
|
24
|
-
if (isImage(data.name)) {
|
27
|
+
if (isImage(data.name) || isSvgPath(data.name)) {
|
25
28
|
classes.push('smart-icon--image');
|
26
|
-
if (isSvg(data.name)) classes.push('smart-icon--svg');
|
29
|
+
if (isSvg(data.name) || isSvgPath(data.name)) classes.push('smart-icon--svg');
|
27
30
|
} else if (data.classPrefix != null) {
|
28
31
|
classes.push(data.classPrefix + '-' + data.name);
|
29
32
|
}
|
@@ -58,8 +61,30 @@ function svgStyle(data) {
|
|
58
61
|
'-webkit-mask-position': 'center',
|
59
62
|
'mask-image': imageBase64Src,
|
60
63
|
'mask-size': 'contain',
|
61
|
-
|
62
|
-
|
64
|
+
background: data.color,
|
65
|
+
},
|
66
|
+
]);
|
67
|
+
return ret;
|
68
|
+
}
|
69
|
+
function svgPathStyle(data) {
|
70
|
+
const { name, color } = data;
|
71
|
+
// 构建SVG字符串
|
72
|
+
const svg = `
|
73
|
+
<svg class="icon" width="100%" height="100%" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
74
|
+
<path d="${name}" fill="${color || 'currentColor'}" fill-rule="evenodd"></path>
|
75
|
+
</svg>
|
76
|
+
`;
|
77
|
+
|
78
|
+
const imageBase64Src = `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
|
79
|
+
var ret = style([
|
80
|
+
{
|
81
|
+
|
82
|
+
'-webkit-mask-image': imageBase64Src,
|
83
|
+
'-webkit-mask-size': 'contain',
|
84
|
+
'-webkit-mask-repeat': 'no-repeat',
|
85
|
+
'-webkit-mask-position': 'center',
|
86
|
+
'mask-image': imageBase64Src,
|
87
|
+
'mask-size': 'contain',
|
63
88
|
background: data.color,
|
64
89
|
},
|
65
90
|
]);
|
@@ -69,8 +94,10 @@ function svgStyle(data) {
|
|
69
94
|
module.exports = {
|
70
95
|
isImage: isImage,
|
71
96
|
isSvg: isSvg,
|
97
|
+
isSvgPath: isSvgPath,
|
72
98
|
getImageSrc: getImageSrc,
|
73
99
|
rootClass: rootClass,
|
74
100
|
rootStyle: rootStyle,
|
75
101
|
svgStyle: svgStyle,
|
102
|
+
svgPathStyle: svgPathStyle,
|
76
103
|
};
|