primevue-mirror/doc/virtualscroller/LoadingDoc.vue

139 lines
6.3 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>
Busy state is enabled by adding <i>showLoader</i> property which blocks the UI with a modal by default. Alternatively, <i>loader</i> template can be used to customize items e.g. with
<PrimeVueNuxtLink to="/skeleton">Skeleton</PrimeVueNuxtLink>.
</p>
2023-02-28 08:29:30 +00:00
</DocSectionText>
2024-05-20 12:14:38 +00:00
<div class="card flex flex-wrap justify-center gap-8">
2023-02-28 08:29:30 +00:00
<div>
<span class="font-bold block mb-2">Modal</span>
2024-05-20 12:14:38 +00:00
<VirtualScroller :items="items" :itemSize="50" showLoader :delay="250" class="border border-surface-200 dark:border-surface-700 rounded" style="width: 200px; height: 200px">
2023-02-28 08:29:30 +00:00
<template v-slot:item="{ item, options }">
2024-05-20 12:14:38 +00:00
<div :class="['flex items-center p-2', { 'surface-hover': options.odd }]" style="height: 50px">{{ item }}</div>
2023-02-28 08:29:30 +00:00
</template>
</VirtualScroller>
</div>
<div>
<span class="font-bold block mb-2">Skeleton</span>
2024-05-20 12:14:38 +00:00
<VirtualScroller :items="items" :itemSize="50" showLoader :delay="250" class="border border-surface-200 dark:border-surface-700 rounded" style="width: 200px; height: 200px">
2023-02-28 08:29:30 +00:00
<template v-slot:item="{ item, options }">
2024-05-20 12:14:38 +00:00
<div :class="['flex items-center p-2', { 'surface-hover': options.odd }]" style="height: 50px">{{ item }}</div>
2023-02-28 08:29:30 +00:00
</template>
<template v-slot:loader="{ options }">
2024-05-20 12:14:38 +00:00
<div :class="['flex items-center p-2', { 'surface-hover': options.odd }]" style="height: 50px">
2023-02-28 08:29:30 +00:00
<Skeleton :width="options.even ? '60%' : '50%'" height="1.3rem" />
</div>
</template>
</VirtualScroller>
</div>
</div>
<DocSectionCode :code="code" />
</template>
<script>
export default {
data() {
return {
items: null,
code: {
2023-09-22 12:54:14 +00:00
basic: `
2024-05-20 12:14:38 +00:00
<VirtualScroller :items="items" :itemSize="50" showLoader :delay="250" class="border border-surface-200 dark:border-surface-700 rounded" style="width: 200px; height: 200px">
2023-02-28 08:29:30 +00:00
<template v-slot:item="{ item, options }">
2024-05-20 12:14:38 +00:00
<div :class="['flex items-center p-2', { 'surface-hover': options.odd }]" style="height: 50px">{{ item }}</div>
2023-02-28 08:29:30 +00:00
</template>
</VirtualScroller>
2024-05-20 12:14:38 +00:00
<VirtualScroller :items="items" :itemSize="50" showLoader :delay="250" class="border border-surface-200 dark:border-surface-700 rounded" style="width: 200px; height: 200px">
2023-02-28 08:29:30 +00:00
<template v-slot:item="{ item, options }">
2024-05-20 12:14:38 +00:00
<div :class="['flex items-center p-2', { 'surface-hover': options.odd }]" style="height: 50px">{{ item }}</div>
2023-02-28 08:29:30 +00:00
</template>
<template v-slot:loader="{ options }">
2024-05-20 12:14:38 +00:00
<div :class="['flex items-center p-2', { 'surface-hover': options.odd }]" style="height: 50px">
2023-02-28 08:29:30 +00:00
<Skeleton :width="options.even ? '60%' : '50%'" height="1.3rem" />
</div>
</template>
2023-10-15 09:38:39 +00:00
</VirtualScroller>
`,
2023-09-22 12:54:14 +00:00
options: `
<template>
2024-05-20 12:14:38 +00:00
<div class="card flex flex-wrap justify-center gap-8">
2023-02-28 08:29:30 +00:00
<div>
<span class="font-bold block mb-2">Modal</span>
2024-05-20 12:14:38 +00:00
<VirtualScroller :items="items" :itemSize="50" showLoader :delay="250" class="border border-surface-200 dark:border-surface-700 rounded" style="width: 200px; height: 200px">
2023-02-28 08:29:30 +00:00
<template v-slot:item="{ item, options }">
2024-05-20 12:14:38 +00:00
<div :class="['flex items-center p-2', { 'surface-hover': options.odd }]" style="height: 50px">{{ item }}</div>
2023-02-28 08:29:30 +00:00
</template>
</VirtualScroller>
</div>
<div>
<span class="font-bold block mb-2">Skeleton</span>
2024-05-20 12:14:38 +00:00
<VirtualScroller :items="items" :itemSize="50" showLoader :delay="250" class="border border-surface-200 dark:border-surface-700 rounded" style="width: 200px; height: 200px">
2023-02-28 08:29:30 +00:00
<template v-slot:item="{ item, options }">
2024-05-20 12:14:38 +00:00
<div :class="['flex items-center p-2', { 'surface-hover': options.odd }]" style="height: 50px">{{ item }}</div>
2023-02-28 08:29:30 +00:00
</template>
<template v-slot:loader="{ options }">
2024-05-20 12:14:38 +00:00
<div :class="['flex items-center p-2', { 'surface-hover': options.odd }]" style="height: 50px">
2023-02-28 08:29:30 +00:00
<Skeleton :width="options.even ? '60%' : '50%'" height="1.3rem" />
</div>
</template>
</VirtualScroller>
</div>
</div>
</template>
<script>
export default {
data() {
return {
items: null
};
},
mounted() {
this.items = Array.from({ length: 100000 }).map((_, i) => \`Item #\${i}\`);
}
};
2023-10-15 09:38:39 +00:00
<\/script>
`,
2023-09-22 12:54:14 +00:00
composition: `
<template>
2024-05-20 12:14:38 +00:00
<div class="card flex flex-wrap justify-center gap-8">
2023-02-28 08:29:30 +00:00
<div>
<span class="font-bold block mb-2">Modal</span>
2024-05-20 12:14:38 +00:00
<VirtualScroller :items="items" :itemSize="50" showLoader :delay="250" class="border border-surface-200 dark:border-surface-700 rounded" style="width: 200px; height: 200px">
2023-02-28 08:29:30 +00:00
<template v-slot:item="{ item, options }">
2024-05-20 12:14:38 +00:00
<div :class="['flex items-center p-2', { 'surface-hover': options.odd }]" style="height: 50px">{{ item }}</div>
2023-02-28 08:29:30 +00:00
</template>
</VirtualScroller>
</div>
<div>
<span class="font-bold block mb-2">Skeleton</span>
2024-05-20 12:14:38 +00:00
<VirtualScroller :items="items" :itemSize="50" showLoader :delay="250" class="border border-surface-200 dark:border-surface-700 rounded" style="width: 200px; height: 200px">
2023-02-28 08:29:30 +00:00
<template v-slot:item="{ item, options }">
2024-05-20 12:14:38 +00:00
<div :class="['flex items-center p-2', { 'surface-hover': options.odd }]" style="height: 50px">{{ item }}</div>
2023-02-28 08:29:30 +00:00
</template>
<template v-slot:loader="{ options }">
2024-05-20 12:14:38 +00:00
<div :class="['flex items-center p-2', { 'surface-hover': options.odd }]" style="height: 50px">
2023-02-28 08:29:30 +00:00
<Skeleton :width="options.even ? '60%' : '50%'" height="1.3rem" />
</div>
</template>
</VirtualScroller>
</div>
</div>
</template>
<script setup>
import { ref } from 'vue';
const items = ref(Array.from({ length: 100000 }).map((_, i) => \`Item #\${i}\`));
2023-10-15 09:38:39 +00:00
<\/script>
`
2023-02-28 08:29:30 +00:00
}
};
},
mounted() {
this.items = Array.from({ length: 100000 }).map((_, i) => `Item #${i}`);
}
};
</script>