Skip to content

Commit

Permalink
feat: add propsEmits for loading
Browse files Browse the repository at this point in the history
  • Loading branch information
BeADre committed Dec 1, 2020
1 parent 66be153 commit 41bfdab
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 26 deletions.
28 changes: 2 additions & 26 deletions packages/varlet-ui/src/loading/Loading.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,35 +117,11 @@

<script lang="ts">
import { defineComponent } from 'vue'
import { props } from './propsEmits'
export default defineComponent({
name: 'VarletLoading',
props: {
type: {
type: String,
default: 'wave',
},
color: {
type: String,
default: 'currentColor',
},
fontColor: {
type: String,
default: '#ccc',
},
size: {
type: String,
default: 'normal',
},
fontSize: {
type: Number,
default: 14,
},
vertical: {
type: Boolean,
default: true,
},
},
props,
})
</script>

Expand Down
45 changes: 45 additions & 0 deletions packages/varlet-ui/src/loading/propsEmits.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function typeValidator(type: string): boolean {
const validTypes = ['wave', 'cube', 'rect', 'disappear']
return validTypes.includes(type)
}

function sizeValidator(size: string): boolean {
const validSizes = ['normal', 'mini', 'small', 'large']

return validSizes.includes(size)
}

export const props = {
// loading类型
type: {
type: String,
default: 'wave',
validator: typeValidator,
},
// loading尺寸
size: {
type: String,
default: 'normal',
validator: sizeValidator,
},
// loading颜色
color: {
type: String,
default: 'currentColor',
},
// 文字颜色
fontColor: {
type: String,
default: '#ccc',
},
// 字体大小
fontSize: {
type: Number,
default: 14,
},
// 是否垂直排列图标和文字内容
vertical: {
type: Boolean,
default: true,
},
}

0 comments on commit 41bfdab

Please sign in to comment.