Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. <template>
  2. <div v-if="loading" class="loader" :style="spinnerStyle"></div>
  3. </template>
  4.  
  5. <script>
  6. export default {
  7. props: {
  8. style: {
  9. required: false,
  10. type: Object,
  11. default: () => {}
  12. },
  13.  
  14. loading: {
  15. required: true,
  16. type: Boolean
  17. },
  18.  
  19. color: {
  20. type: String,
  21. default: '#42b983'
  22. },
  23.  
  24. staticColor: {
  25. type: String,
  26. default: '#f3f3f3'
  27. },
  28.  
  29. thickness: {
  30. type: [String, Number],
  31. default: 3
  32. },
  33.  
  34. width: {
  35. type: [String, Number],
  36. default: 20
  37. },
  38.  
  39. height: {
  40. type: [String, Number],
  41. default: 20
  42. },
  43. },
  44.  
  45. computed: {
  46. spinnerStyle () {
  47. return Object.assign({
  48. width: this.addPx(this.width),
  49. height: this.addPx(this.height),
  50. border: `${this.addPx(this.thickness)} solid ${this.staticColor}`,
  51. borderTop: `${this.addPx(this.thickness)} solid ${this.color}`,
  52. borderRadius: '50%',
  53. }, this.style);
  54. }
  55. },
  56.  
  57. methods: {
  58. /**
  59. * Make the given var a string then check if it contains px and return it else add px.
  60. *
  61. * @param {mixed} a
  62. */
  63. addPx (a) {
  64. return String(a).indexOf('px') !== -1 ? a : a + 'px';
  65. }
  66. }
  67. }
  68. </script>
  69.  
  70. <style scoped>
  71. .loader {
  72. border: 16px solid #f3f3f3; /* Light grey */
  73. border-top: 16px solid #3498db; /* Blue */
  74. border-radius: 50%;
  75. width: 120px;
  76. height: 120px;
  77. animation: spin 2s linear infinite;
  78. }
  79.  
  80. @keyframes spin {
  81. 0% { transform: rotate(0deg); }
  82. 100% { transform: rotate(360deg); }
  83. }
  84. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement