index.wxs 610B

123456789101112131415161718192021222324252627282930313233
  1. /* eslint-disable */
  2. var style = require('../wxs/style.wxs');
  3. var addUnit = require('../wxs/add-unit.wxs');
  4. function rootStyle(data) {
  5. return style([
  6. {
  7. width: addUnit(data.width),
  8. height: addUnit(data.height),
  9. 'border-radius': addUnit(data.radius),
  10. },
  11. data.radius ? 'overflow: hidden' : null,
  12. ]);
  13. }
  14. var FIT_MODE_MAP = {
  15. none: 'center',
  16. fill: 'scaleToFill',
  17. cover: 'aspectFill',
  18. contain: 'aspectFit',
  19. widthFix: 'widthFix',
  20. heightFix: 'heightFix',
  21. };
  22. function mode(fit) {
  23. return FIT_MODE_MAP[fit];
  24. }
  25. module.exports = {
  26. rootStyle: rootStyle,
  27. mode: mode,
  28. };