logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://anongit.hacktivis.me/git/pleroma-fe.git/

progress_button.vue (663B)


  1. <template>
  2. <button
  3. :disabled="progress || disabled"
  4. @click="onClick"
  5. >
  6. <template v-if="progress && $slots.progress">
  7. <slot name="progress" />
  8. </template>
  9. <template v-else>
  10. <slot />
  11. </template>
  12. </button>
  13. </template>
  14. <script>
  15. export default {
  16. props: {
  17. disabled: {
  18. type: Boolean
  19. },
  20. click: { // click event handler. Must return a promise
  21. type: Function,
  22. default: () => Promise.resolve()
  23. }
  24. },
  25. data () {
  26. return {
  27. progress: false
  28. }
  29. },
  30. methods: {
  31. onClick () {
  32. this.progress = true
  33. this.click().then(() => { this.progress = false })
  34. }
  35. }
  36. }
  37. </script>