index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import _mergeJSXProps from "@vue/babel-helper-vue-jsx-merge-props";
  2. import { use } from '../utils';
  3. import { inherit } from '../utils/functional'; // Types
  4. var _use = use('loading'),
  5. sfc = _use[0],
  6. bem = _use[1];
  7. var DEFAULT_COLOR = '#c9c9c9';
  8. function Loading(h, props, slots, ctx) {
  9. var color = props.color,
  10. size = props.size,
  11. type = props.type;
  12. var colorType = color === 'white' || color === 'black' ? color : '';
  13. var style = {
  14. color: color === 'black' ? DEFAULT_COLOR : color,
  15. width: size,
  16. height: size
  17. };
  18. var Spin = [];
  19. if (type === 'spinner') {
  20. for (var i = 0; i < 12; i++) {
  21. Spin.push(h("i"));
  22. }
  23. }
  24. var Circular = type === 'circular' && h("svg", {
  25. "class": bem('circular'),
  26. "attrs": {
  27. "viewBox": "25 25 50 50"
  28. }
  29. }, [h("circle", {
  30. "attrs": {
  31. "cx": "50",
  32. "cy": "50",
  33. "r": "20",
  34. "fill": "none"
  35. }
  36. })]);
  37. return h("div", _mergeJSXProps([{
  38. "class": bem([type, colorType]),
  39. "style": style
  40. }, inherit(ctx, true)]), [h("span", {
  41. "class": bem('spinner', type)
  42. }, [Spin, Circular])]);
  43. }
  44. Loading.props = {
  45. size: String,
  46. type: {
  47. type: String,
  48. "default": 'circular'
  49. },
  50. color: {
  51. type: String,
  52. "default": DEFAULT_COLOR
  53. }
  54. };
  55. export default sfc(Loading);