mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
51 lines
909 B
XML
51 lines
909 B
XML
/* eslint-disable */
|
|
var utils = require('../wxs/utils.wxs');
|
|
|
|
function isImage(name) {
|
|
return name.indexOf('/') !== -1;
|
|
}
|
|
|
|
function rootClass(data) {
|
|
var classes = ['custom-class'];
|
|
|
|
if (data.classPrefix != null) {
|
|
classes.push(data.classPrefix);
|
|
}
|
|
|
|
if (isImage(data.name)) {
|
|
classes.push('van-icon--image');
|
|
} else if (data.classPrefix != null) {
|
|
classes.push(data.classPrefix + '-' + data.name);
|
|
}
|
|
|
|
return classes.join(' ');
|
|
}
|
|
|
|
function rootStyle(data) {
|
|
var styles = [];
|
|
|
|
if (data.color) {
|
|
styles.push(['color', data.color]);
|
|
}
|
|
|
|
if (data.size) {
|
|
styles.push(['font-size', utils.addUnit(data.size)]);
|
|
}
|
|
|
|
if (data.customStyle) {
|
|
styles.push([data.customStyle]);
|
|
}
|
|
|
|
return styles
|
|
.map(function (pair) {
|
|
return pair.join(':');
|
|
})
|
|
.join(';');
|
|
}
|
|
|
|
module.exports = {
|
|
isImage: isImage,
|
|
rootClass: rootClass,
|
|
rootStyle: rootStyle,
|
|
};
|