@dialpad/dialtone
Version:
Dialpad's Dialtone design system monorepo
123 lines (122 loc) • 4.3 kB
JavaScript
import DtSkeletonShape from "./skeleton-shape.vue.js";
import DtSkeletonListItem from "./skeleton-list-item.vue.js";
import DtSkeletonParagraph from "./skeleton-paragraph.vue.js";
import DtSkeletonText from "./skeleton-text.vue.js";
import normalizeComponent from "../../_virtual/_plugin-vue2_normalizer.js";
const _sfc_main = {
name: "DtSkeleton",
components: {
DtSkeletonText,
DtSkeletonShape,
DtSkeletonListItem,
DtSkeletonParagraph
},
props: {
/**
* Set this prop to have the skeleton render as multiple lines of text.
* Set only one option prop at a time.
*/
paragraphOption: {
type: [Object, Boolean],
default: null
},
/**
* Set this prop to have the skeleton render as a list item with an avatar and wrapping text.
* Set only one option prop at a time.
*/
listItemOption: {
type: [Object, Boolean],
default: null
},
/**
* Set this prop to have the skeleton render as a single line of text.
* Set only one option prop at a time.
*/
textOption: {
type: Object,
default: null
},
/**
* Set this prop to have the skeleton render as a specific shape.
* Set only one option prop at a time.
*/
shapeOption: {
type: [Object, Boolean],
default: null
},
/**
* Duration time of the animation (ms), set -1 for an infinite animation.
*/
animationDuration: {
type: Number,
default: -1
},
/**
* Descriptive label for the content.
*/
ariaLabel: {
type: String,
default: ""
},
/**
* This property has higher priority than "option.animate"
* @values true, false
*/
animate: {
type: Boolean,
default: true
},
/**
* RippleDuration controls how long the delay is for the animation of a
* placeholder 1000 pixels from the top of the page. Each placeholder
* from the top down will have a delay duration from 0 to this offset.
* The delay of each placeholder animation is based on how far down the page
* the placeholder is rendered. This is a linear relationship. The unit
* is milliseconds.
*/
offset: {
type: Number,
default: 1
}
},
computed: {
validationOptions() {
return {
paragraphOption: this.paragraphOption,
listItemOption: this.listItemOption,
textOption: this.textOption,
shapeOption: this.shapeOption
};
}
},
watch: {
$props: {
immediate: true,
handler: "validator"
}
},
methods: {
validator() {
const filtered = Object.entries(this.validationOptions).filter(([_, option]) => option);
if (filtered.length >= 2) {
const errorMessage = `Use only one of ${filtered.map(([key]) => key).join(" | ")} options at the same time`;
console.error(errorMessage);
}
}
}
};
var _sfc_render = function render() {
var _vm = this, _c = _vm._self._c;
return _c("div", { attrs: { "aria-busy": "true", "role": "status", "aria-label": _vm.ariaLabel } }, [_vm.listItemOption ? _c("dt-skeleton-list-item", _vm._b({ attrs: { "animation-duration": _vm.animationDuration, "animate": _vm.animate, "offset": _vm.offset } }, "dt-skeleton-list-item", _vm.listItemOption === true ? {} : _vm.listItemOption, false)) : _vm.shapeOption ? _c("dt-skeleton-shape", _vm._b({ attrs: { "animation-duration": _vm.animationDuration, "animate": _vm.animate, "offset": _vm.offset } }, "dt-skeleton-shape", _vm.shapeOption === true ? {} : _vm.shapeOption, false)) : _vm.paragraphOption ? _c("dt-skeleton-paragraph", _vm._b({ attrs: { "animation-duration": _vm.animationDuration, "animate": _vm.animate, "offset": _vm.offset } }, "dt-skeleton-paragraph", _vm.paragraphOption === true ? {} : _vm.paragraphOption, false)) : _c("dt-skeleton-text", _vm._b({ attrs: { "animation-duration": _vm.animationDuration, "animate": _vm.animate, "offset": _vm.offset } }, "dt-skeleton-text", _vm.textOption || {}, false))], 1);
};
var _sfc_staticRenderFns = [];
var __component__ = /* @__PURE__ */ normalizeComponent(
_sfc_main,
_sfc_render,
_sfc_staticRenderFns
);
const DtSkeleton = __component__.exports;
export {
DtSkeleton as default
};
//# sourceMappingURL=skeleton.vue.js.map