UNPKG

@dialpad/dialtone

Version:

Dialpad's Dialtone design system monorepo

1 lines 5 kB
{"version":3,"file":"skeleton-paragraph.cjs","names":[],"sources":["../../../components/skeleton/skeleton-paragraph.vue"],"sourcesContent":["<template>\n <div\n :class=\"[\n 'd-skeleton-paragraph',\n contentClass,\n ]\"\n contentClass\n data-qa=\"skeleton-paragraph\"\n >\n <dt-skeleton-text\n v-for=\"row in integerRows\"\n :key=\"row\"\n data-qa=\"skeleton-paragraph-row\"\n :content-class=\"rowClass\"\n :animate=\"animate\"\n :offset=\"offset\"\n :animation-duration=\"animationDuration\"\n :width=\"getSizeParagraphRow(row)\"\n />\n </div>\n</template>\n\n<script>\nimport DtSkeletonText from './skeleton-text.vue';\n\nconst validator = number => number !== '' && !Number.isNaN(Number(number));\nexport default {\n compatConfig: { MODE: 3 },\n name: 'DtSkeletonParagraph',\n components: {\n DtSkeletonText,\n },\n\n props: {\n /**\n * Quantity of rows to display\n */\n rows: {\n type: [Number, String],\n default: 3,\n validator,\n },\n\n /**\n * This property has higher priority than \"option.animate\"\n * @values true, false\n */\n animate: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Controls the min width of paragraphs\n */\n minWidth: {\n type: [Number, String],\n default: 30,\n validator,\n },\n\n /**\n * Controls the max width of paragraphs\n */\n maxWidth: {\n type: [Number, String],\n default: 100,\n validator,\n },\n\n /**\n * Controls the width of paragraphs\n */\n width: {\n type: [String, Array],\n default: null,\n },\n\n /**\n * If true, row widths will be random\n * @values true, false\n */\n randomWidth: {\n type: Boolean,\n default: false,\n },\n\n /**\n * RippleDuration controls how long the delay is for the animation of a\n * placeholder 1000 pixels from the top of the page. Each placeholder\n * from the top down will have a delay duration from 0 to this offset.\n * The delay of each placeholder animation is based on how far down the page\n * the placeholder is rendered. This is a linear relationship. The unit\n * is milliseconds.\n */\n offset: {\n type: Number,\n default: 1,\n },\n\n /**\n * Duration time of the animation (ms), set -1 for an infinite animation.\n */\n animationDuration: {\n type: Number,\n default: -1,\n },\n\n /**\n * Additional class name for the content.\n */\n contentClass: {\n type: String,\n default: '',\n },\n\n /**\n * Additional class name for the row.\n */\n rowClass: {\n type: String,\n default: '',\n },\n },\n\n computed: {\n integerRows () {\n return Number(this.rows);\n },\n },\n\n methods: {\n randomWidthPercentage () {\n const min = Math.min(this.minWidth, this.maxWidth);\n const max = Math.max(this.minWidth, this.maxWidth);\n return `${Math.round(Math.random() * (max - min)) + min}%`;\n },\n\n getSizeParagraphRow (row) {\n const paragraphWidth = this.width;\n const isArrayWidth = Array.isArray(paragraphWidth);\n const currentWidth = paragraphWidth?.[row - 1];\n const isLastRow = row === this.rows;\n\n if (this.randomWidth) {\n return this.randomWidthPercentage();\n }\n\n if (paragraphWidth && !isArrayWidth) {\n return paragraphWidth;\n }\n\n if (paragraphWidth && isArrayWidth && currentWidth) {\n return currentWidth;\n }\n\n return isLastRow ? '38%' : '100%';\n },\n },\n};\n</script>\n"],"mappings":"yPAyBA,IAAM,EAAY,GAAU,IAAW,IAAM,CAAC,OAAO,MAAM,OAAO,EAAO,CAAC,CACrE,EAAU,CACb,aAAc,CAAE,KAAM,EAAG,CACzB,KAAM,sBACN,WAAY,CACV,eAAA,EAAA,QACD,CAED,MAAO,CAIL,KAAM,CACJ,KAAM,CAAC,OAAQ,OAAO,CACtB,QAAS,EACT,YACD,CAMD,QAAS,CACP,KAAM,QACN,QAAS,GACV,CAKD,SAAU,CACR,KAAM,CAAC,OAAQ,OAAO,CACtB,QAAS,GACT,YACD,CAKD,SAAU,CACR,KAAM,CAAC,OAAQ,OAAO,CACtB,QAAS,IACT,YACD,CAKD,MAAO,CACL,KAAM,CAAC,OAAQ,MAAM,CACrB,QAAS,KACV,CAMD,YAAa,CACX,KAAM,QACN,QAAS,GACV,CAUD,OAAQ,CACN,KAAM,OACN,QAAS,EACV,CAKD,kBAAmB,CACjB,KAAM,OACN,QAAS,GACV,CAKD,aAAc,CACZ,KAAM,OACN,QAAS,GACV,CAKD,SAAU,CACR,KAAM,OACN,QAAS,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