avatar.wxs 903 B

12345678910111213141516171819202122232425
  1. module.exports = {
  2. getAvatarOuterClass: function (classPrefix, size, shape) {
  3. var isIncludePx = size.indexOf('px') > -1;
  4. var classNames = [
  5. classPrefix,
  6. classPrefix + (shape === 'round' ? '--round' : '--circle'),
  7. isIncludePx ? '' : 't-size-' + (size || 'medium').slice(0, 1),
  8. ];
  9. return classNames.join(' ');
  10. },
  11. getAvatarSizePx: function (size = 'medium') {
  12. var pxIndex = size.indexOf('px');
  13. if (pxIndex > -1) {
  14. return 'width:' + size + ';height:' + size + ';font-size:' + ((size.slice(0, pxIndex) / 8) * 3 + 2) + 'px;';
  15. }
  16. },
  17. getStyles: function (isShow, zIndex) {
  18. var styles = 'z-index:' + zIndex + ';';
  19. return styles + (isShow ? '' : 'display: none;');
  20. },
  21. getIconClass: function (classPrefix, size) {
  22. if (size.indexOf('px') > -1) return;
  23. return classPrefix + '__icon--default-' + (size || 'medium').slice(0, 1);
  24. },
  25. };