added loading state to button and tried to fix form item

This commit is contained in:
Grzegorz Leoniec 2018-10-17 19:30:30 +02:00
parent d457b2fa82
commit 2b11d14bde
3 changed files with 22 additions and 6 deletions

View File

@ -1,9 +1,10 @@
<template> <template>
<div <div
class="ds-form-item" class="ds-form-item"
:class="$parentInput.stateClasses"> :class="$parentInput ? $parentInput.stateClasses : ''">
<ds-input-label <ds-input-label
:label="$parentInput.label" v-if="$parentInput"
:label="$parentInput.label"
:for="$parentInput.id" /> :for="$parentInput.id" />
<slot/> <slot/>
<ds-input-error :error="$parentInput.error" /> <ds-input-error :error="$parentInput.error" />

View File

@ -10,12 +10,16 @@
ghost && `ds-button-ghost`, ghost && `ds-button-ghost`,
iconOnly && `ds-button-icon-only`, iconOnly && `ds-button-icon-only`,
hover && `ds-button-hover`, hover && `ds-button-hover`,
fullWidth && `ds-button-full-width` fullWidth && `ds-button-full-width`,
loading && `ds-button-loading`
]" ]"
v-bind="bindings" v-bind="bindings"
:is="linkTag"> :is="linkTag">
<ds-icon <ds-icon
v-if="icon" v-if="loading"
name="spinner" />
<ds-icon
v-if="icon && !loading"
:name="icon"/> :name="icon"/>
<span <span
class="ds-button-text" class="ds-button-text"
@ -130,6 +134,13 @@ export default {
fullWidth: { fullWidth: {
type: Boolean, type: Boolean,
default: false default: false
},
/**
* Show loading state
*/
loading: {
type: Boolean,
default: false
} }
}, },
computed: { computed: {
@ -141,6 +152,9 @@ export default {
if (this.path && this.linkTag === 'a') { if (this.path && this.linkTag === 'a') {
bindings.href = this.path bindings.href = this.path
} }
if (this.loading) {
bindings.disabled = true
}
return bindings return bindings
}, },
iconOnly() { iconOnly() {

View File

@ -45,6 +45,7 @@ A button can take different states.
``` ```
<ds-button>Default state</ds-button> <ds-button>Default state</ds-button>
<ds-button disabled>Disabled state</ds-button> <ds-button disabled>Disabled state</ds-button>
<ds-button :loading="true">Loading state</ds-button>
<ds-button hover>Hover state</ds-button> <ds-button hover>Hover state</ds-button>
``` ```