From cdf32e5f8a1e431fa052684f828d0dbceab46f96 Mon Sep 17 00:00:00 2001 From: haoziqaq <357229046@qq.com> Date: Tue, 1 Dec 2020 17:05:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(ui):=20button=E5=8E=9F=E5=9E=8B=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit affects: @varlet/ui --- packages/varlet-ui/src/button/Button.vue | 6 +- .../varlet-ui/src/button/example/index.vue | 167 ++++++++++++++++-- packages/varlet-ui/src/button/propsEmits.ts | 18 ++ packages/varlet-ui/src/loading/propsEmits.ts | 12 +- 4 files changed, 182 insertions(+), 21 deletions(-) diff --git a/packages/varlet-ui/src/button/Button.vue b/packages/varlet-ui/src/button/Button.vue index a9719ec9d50..5def4fecb7f 100644 --- a/packages/varlet-ui/src/button/Button.vue +++ b/packages/varlet-ui/src/button/Button.vue @@ -16,7 +16,11 @@ :disabled="disabled" @click="trigger" > - + diff --git a/packages/varlet-ui/src/button/example/index.vue b/packages/varlet-ui/src/button/example/index.vue index 62a3f302507..4f3240fa86a 100644 --- a/packages/varlet-ui/src/button/example/index.vue +++ b/packages/varlet-ui/src/button/example/index.vue @@ -1,20 +1,5 @@ diff --git a/packages/varlet-ui/src/button/propsEmits.ts b/packages/varlet-ui/src/button/propsEmits.ts index dd09a5cdc29..02962924cb5 100644 --- a/packages/varlet-ui/src/button/propsEmits.ts +++ b/packages/varlet-ui/src/button/propsEmits.ts @@ -1,3 +1,9 @@ +import { + typeValidator as loadingTypeValidator, + sizeValidator as loadingSizeValidator, + getTypeDefault as getLoadingTypeDefault +} from '../loading/propsEmits' + function typeValidator(type: string): boolean { const validTypes = ['plain', 'primary', 'info', 'success', 'warning', 'danger'] @@ -28,6 +34,18 @@ export const props = { type: Boolean, default: false }, + // 加载动画类型 + loadingType: { + type: String, + default: getLoadingTypeDefault, + validator: loadingTypeValidator + }, + // 加载动画尺寸 + loadingSize: { + type: String, + default: (props: any) => props.size, + validator: loadingSizeValidator + }, // 原型按钮 round: { type: Boolean, diff --git a/packages/varlet-ui/src/loading/propsEmits.ts b/packages/varlet-ui/src/loading/propsEmits.ts index d75166c1961..85e91629bff 100644 --- a/packages/varlet-ui/src/loading/propsEmits.ts +++ b/packages/varlet-ui/src/loading/propsEmits.ts @@ -1,25 +1,29 @@ -function typeValidator(type: string): boolean { +export function typeValidator(type: string): boolean { const validTypes = ['wave', 'cube', 'rect', 'disappear'] return validTypes.includes(type) } -function sizeValidator(size: string): boolean { +export function sizeValidator(size: string): boolean { const validSizes = ['normal', 'mini', 'small', 'large'] return validSizes.includes(size) } +export const getTypeDefault = () => 'wave' + +export const getSizeDefault = () => 'normal' + export const props = { // loading类型 type: { type: String, - default: 'wave', + default: getTypeDefault, validator: typeValidator, }, // loading尺寸 size: { type: String, - default: 'normal', + default: getSizeDefault, validator: sizeValidator, }, // loading颜色