diff options
| author | taehoon <th.dev91@gmail.com> | 2019-04-04 13:26:08 -0400 |
|---|---|---|
| committer | taehoon <th.dev91@gmail.com> | 2019-04-17 11:32:49 -0400 |
| commit | 403c7bbe6c1e794f67ac103777d98ec3baf9f4f6 (patch) | |
| tree | 7d0d2255334bea1d1395b661ca1088d6767d9cd9 /src | |
| parent | fe7766bc618f9a994e2c0a9337deb7cce8b162cf (diff) | |
add reusable progress-button cmoponent
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/progress_button/progress_button.vue | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/components/progress_button/progress_button.vue b/src/components/progress_button/progress_button.vue new file mode 100644 index 00000000..3fea2418 --- /dev/null +++ b/src/components/progress_button/progress_button.vue @@ -0,0 +1,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> |
