UNPKG

taro-ui-vue3

Version:

Taro UI Rewritten in Vue 3.0

52 lines (51 loc) 1.93 kB
var __defProp = Object.defineProperty; var __hasOwnProp = Object.prototype.hasOwnProperty; var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __propIsEnum = Object.prototype.propertyIsEnumerable; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value; var __objSpread = (a, b) => { for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); } return a; }; import {h, defineComponent, mergeProps, computed} from "vue"; import {View} from "@tarojs/components"; import {pxTransform} from "../utils/common"; const AtLoading = defineComponent({ name: "AtLoading", props: { size: {type: [String, Number], default: 0}, color: {type: [String, Number], default: ""} }, setup(props, {attrs}) { const loadingSize = typeof props.size === "string" ? props.size : String(props.size); const sizeStyle = computed(() => ({ width: props.size ? `${pxTransform(parseInt(loadingSize))}` : "", height: props.size ? `${pxTransform(parseInt(loadingSize))}` : "" })); const ringStyle = computed(() => __objSpread(__objSpread({}, sizeStyle.value), { border: props.color ? `1px solid ${props.color}` : "", "border-color": props.color ? `${props.color} transparent transparent transparent` : "" })); return () => h(View, mergeProps(attrs, { class: "at-loading", style: sizeStyle.value }), { default: () => Array.apply(null, {length: 3}).map((_, index) => h(View, { key: index, class: "at-loading__ring", style: ringStyle.value })) }); } }); var loading_default = AtLoading; export { loading_default as default };