aboutsummaryrefslogtreecommitdiff
path: root/src/components/progress_button/progress_button.vue
blob: 3fea2418181244cd8d202ca1c391bce985a68ada (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<template>
  <button :disabled="progress || disabled" @click="onClick">
    <template v-if="progress">
      <slot name="progress" />
    </template>
    <template v-else>
      <slot />
    </template>
  </button>
</template>

<script>
export default {
  props: {
    disabled: {
      type: Boolean
    },
    click: {
      type: Function,
      default: () => Promise.resolve()
    }
  },
  data () {
    return {
      progress: false
    }
  },
  methods: {
    onClick () {
      this.progress = true
      this.click().then(() => { this.progress = false })
    }
  }
}
</script>