feat: update toast&switch

This commit is contained in:
jiangruowei
2017-03-17 11:30:53 +08:00
parent 9ccce7cd5c
commit 25ce414de2
6 changed files with 101 additions and 27 deletions
+1 -6
View File
@@ -15,7 +15,6 @@
* @param {boolean} [checked=false] - 开关状态
* @param {boolean} [disabled=false] - 禁用
* @param {boolean} [loading=false] - loading状态
* @param {callback} [onChange] - 开关状态改变回调函数。
*
* @example
* <zan-switch checked="true" disabled="false"></zan-switch>
@@ -34,10 +33,6 @@ export default {
loading: {
type: Boolean,
default: false
},
onChange: {
type: Function,
default: function() {}
}
},
computed: {
@@ -54,7 +49,7 @@ export default {
*/
toggleState: function() {
if (this.disabled || this.loading) return;
this.onChange(!this.checked);
this.$emit('change', !this.checked);
}
}
};
+23
View File
@@ -1,4 +1,5 @@
import Vue from 'vue';
import merge from 'src/utils/merge';
const ToastConstructor = Vue.extend(require('./toast.vue'));
let toastQueue = [];
@@ -50,4 +51,26 @@ var Toast = (options = {}) => {
return instance;
};
Toast.loading = (options) => {
return new Toast(merge({
type: 'loading'
}, options));
};
Toast.success = (options) => {
const message = typeof options === 'string' ? options : options.message;
return new Toast(merge({
type: 'success',
message: message
}, options));
};
Toast.fail = (options) => {
const message = typeof options === 'string' ? options : options.message;
return new Toast(merge({
type: 'fail',
message: message
}, options));
};
export default Toast;
+2 -2
View File
@@ -22,7 +22,7 @@
import zanLoading from 'packages/loading';
import zanIcon from 'packages/icon';
const TOAST_TYPES = ['text', 'loading', 'success', 'failure'];
const TOAST_TYPES = ['text', 'loading', 'success', 'fail'];
/**
* zan-toast
* @module components/toast
@@ -50,7 +50,7 @@ export default {
type: String,
default: '',
validate(value) {
if (this.type === 'success' || this.type === 'failure') {
if (this.type === 'success' || this.type === 'fail') {
return value.length <= 16;
}
}
+2 -1
View File
@@ -19,7 +19,8 @@
}
@m text {
padding: 11px;
padding: 12px;
min-width: 200px;
}
@m default {