2017-10-13 22:01:21 +00:00
|
|
|
<script>
|
2018-01-09 11:58:34 +00:00
|
|
|
/* eslint-disable vue/require-default-prop */
|
2018-01-05 00:18:35 +00:00
|
|
|
/* This is a re-usable vue component for rendering a button
|
|
|
|
that will probably be sending off ajax requests and need
|
|
|
|
to show the loading status by setting the `loading` option.
|
|
|
|
This can also be used for initial page load when you don't
|
|
|
|
know the action of the button yet by setting
|
|
|
|
`loading: true, label: undefined`.
|
2017-10-13 22:01:21 +00:00
|
|
|
|
2018-01-05 00:18:35 +00:00
|
|
|
Sample configuration:
|
2017-10-13 22:01:21 +00:00
|
|
|
|
2018-01-05 00:18:35 +00:00
|
|
|
<loading-button
|
|
|
|
:loading="true"
|
|
|
|
:label="Hello"
|
|
|
|
@click="..."
|
|
|
|
/>
|
2017-10-13 22:01:21 +00:00
|
|
|
|
2018-01-05 00:18:35 +00:00
|
|
|
*/
|
2017-10-13 22:01:21 +00:00
|
|
|
|
2018-01-05 00:18:35 +00:00
|
|
|
import loadingIcon from './loading_icon.vue';
|
2017-10-13 22:01:21 +00:00
|
|
|
|
2018-01-05 00:18:35 +00:00
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
loadingIcon,
|
2017-10-13 22:01:21 +00:00
|
|
|
},
|
2018-01-05 00:18:35 +00:00
|
|
|
props: {
|
|
|
|
loading: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
disabled: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
label: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
},
|
|
|
|
containerClass: {
|
2018-02-12 16:49:41 +00:00
|
|
|
type: [String, Array, Object],
|
2018-01-05 00:18:35 +00:00
|
|
|
required: false,
|
|
|
|
default: 'btn btn-align-content',
|
|
|
|
},
|
2017-10-24 04:56:39 +00:00
|
|
|
},
|
2018-01-05 00:18:35 +00:00
|
|
|
methods: {
|
|
|
|
onClick(e) {
|
|
|
|
this.$emit('click', e);
|
|
|
|
},
|
2017-11-15 23:13:20 +00:00
|
|
|
},
|
2018-01-05 00:18:35 +00:00
|
|
|
};
|
2017-10-13 22:01:21 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<button
|
|
|
|
@click="onClick"
|
|
|
|
type="button"
|
2017-11-15 23:13:20 +00:00
|
|
|
:class="containerClass"
|
2017-10-24 04:56:39 +00:00
|
|
|
:disabled="loading || disabled"
|
2017-10-13 22:01:21 +00:00
|
|
|
>
|
2018-01-05 00:18:35 +00:00
|
|
|
<transition name="fade">
|
|
|
|
<loading-icon
|
|
|
|
v-if="loading"
|
|
|
|
:inline="true"
|
|
|
|
class="js-loading-button-icon"
|
|
|
|
:class="{
|
|
|
|
'append-right-5': label
|
|
|
|
}"
|
|
|
|
/>
|
|
|
|
</transition>
|
|
|
|
<transition name="fade">
|
|
|
|
<span
|
2018-01-09 11:58:34 +00:00
|
|
|
v-if="label"
|
2018-01-05 00:18:35 +00:00
|
|
|
class="js-loading-button-label"
|
|
|
|
>
|
|
|
|
{{ label }}
|
|
|
|
</span>
|
|
|
|
</transition>
|
2017-10-13 22:01:21 +00:00
|
|
|
</button>
|
|
|
|
</template>
|