VciLoading.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <div
  3. :class="{'vl-mask': enableMask}"
  4. class="VciLoading vci-flex-ccm"
  5. >
  6. <svg
  7. class="circular"
  8. viewBox="25 25 50 50"
  9. >
  10. <circle
  11. :style="{stroke: color}"
  12. class="path"
  13. cx="50"
  14. cy="50"
  15. fill="none"
  16. r="20"
  17. ></circle>
  18. </svg>
  19. <TextBounce
  20. v-if="text"
  21. :style="{color: textColor}"
  22. :text="text"
  23. class="text"
  24. />
  25. </div>
  26. </template>
  27. <script>
  28. import VciTextBounce from "../../text/VciTextBounce.vue";
  29. export default {
  30. name: "VciLoading",
  31. components: { TextBounce: VciTextBounce },
  32. props: {
  33. color: {
  34. default: "#fff",
  35. type: String
  36. },
  37. text: {
  38. default: "加载中",
  39. type: String
  40. },
  41. textColor: {
  42. default: "#fff",
  43. type: String
  44. },
  45. enableMask: {
  46. type: Boolean,
  47. default: false
  48. }
  49. }
  50. };
  51. </script>
  52. <style lang="scss" scoped>
  53. @use "@vci/style/src/var" as va;
  54. .VciLoading {
  55. padding: 12px 24px;
  56. border-radius: 8px;
  57. min-width: 120px;
  58. transition: va.$transition-slow;
  59. &.vl-mask {
  60. background-color: rgba(0, 0, 0, .2);
  61. }
  62. .circular {
  63. height: 42px;
  64. width: 42px;
  65. animation: loading-rotate 2s linear infinite;
  66. transition: va.$transition-slow;
  67. .path {
  68. animation: loading-dash 1.5s ease-in-out infinite;
  69. stroke-dasharray: 90, 150;
  70. stroke-dashoffset: 0;
  71. stroke-width: 3;
  72. stroke: #5185e9;
  73. stroke-linecap: round;
  74. }
  75. @keyframes loading-rotate {
  76. to {
  77. transform: rotate(1turn)
  78. }
  79. }
  80. @keyframes loading-dash {
  81. 0% {
  82. stroke-dasharray: 1, 200;
  83. stroke-dashoffset: 0
  84. }
  85. 50% {
  86. stroke-dasharray: 90, 150;
  87. stroke-dashoffset: -40px
  88. }
  89. to {
  90. stroke-dasharray: 90, 150;
  91. stroke-dashoffset: -120px
  92. }
  93. }
  94. }
  95. .text {
  96. margin-top: 12px;
  97. transition: va.$transition-slow;
  98. text-shadow: 1px 0 1px #333,
  99. -1px 0 1px #333,
  100. 0 -1px 1px #333,
  101. 0 1px 1px #333;
  102. }
  103. }
  104. </style>