UNPKG

@dialpad/dialtone

Version:

Dialpad's Dialtone design system monorepo

140 lines (139 loc) 3.96 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); const skeletonText = require("./skeleton-text.vue.cjs"); const _pluginVue2_normalizer = require("../../_virtual/_plugin-vue2_normalizer.cjs"); const validator = (number) => number !== "" && !Number.isNaN(Number(number)); const _sfc_main = { name: "DtSkeletonParagraph", components: { DtSkeletonText: skeletonText.default }, props: { /** * Quantity of rows to display */ rows: { type: [Number, String], default: 3, validator }, /** * This property has higher priority than "option.animate" * @values true, false */ animate: { type: Boolean, default: true }, /** * Controls the min width of paragraphs */ minWidth: { type: [Number, String], default: 30, validator }, /** * Controls the max width of paragraphs */ maxWidth: { type: [Number, String], default: 100, validator }, /** * Controls the width of paragraphs */ width: { type: [String, Array], default: null }, /** * If true, row widths will be random * @values true, false */ randomWidth: { type: Boolean, default: false }, /** * 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 }, /** * Duration time of the animation (ms), set -1 for an infinite animation. */ animationDuration: { type: Number, default: -1 }, /** * Additional class name for the content. */ contentClass: { type: String, default: "" }, /** * Additional class name for the row. */ rowClass: { type: String, default: "" } }, computed: { integerRows() { return Number(this.rows); } }, methods: { randomWidthPercentage() { const min = Math.min(this.minWidth, this.maxWidth); const max = Math.max(this.minWidth, this.maxWidth); return `${Math.round(Math.random() * (max - min)) + min}%`; }, getSizeParagraphRow(row) { const paragraphWidth = this.width; const isArrayWidth = Array.isArray(paragraphWidth); const currentWidth = paragraphWidth == null ? void 0 : paragraphWidth[row - 1]; const isLastRow = row === this.rows; if (this.randomWidth) { return this.randomWidthPercentage(); } if (paragraphWidth && !isArrayWidth) { return paragraphWidth; } if (paragraphWidth && isArrayWidth && currentWidth) { return currentWidth; } return isLastRow ? "38%" : "100%"; } } }; var _sfc_render = function render() { var _vm = this, _c = _vm._self._c; return _c("div", { class: [ "d-skeleton-paragraph", _vm.contentClass ], attrs: { "contentClass": "", "data-qa": "skeleton-paragraph" } }, _vm._l(_vm.integerRows, function(row) { return _c("dt-skeleton-text", { key: row, attrs: { "data-qa": "skeleton-paragraph-row", "content-class": _vm.rowClass, "animate": _vm.animate, "offset": _vm.offset, "animation-duration": _vm.animationDuration, "width": _vm.getSizeParagraphRow(row) } }); }), 1); }; var _sfc_staticRenderFns = []; var __component__ = /* @__PURE__ */ _pluginVue2_normalizer.default( _sfc_main, _sfc_render, _sfc_staticRenderFns ); const DtSkeletonParagraph = __component__.exports; exports.default = DtSkeletonParagraph; //# sourceMappingURL=skeleton-paragraph.vue.cjs.map