primevue-mirror/doc/dataview/LoadingDoc.vue

367 lines
16 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>While data is being loaded. <PrimeVueNuxtLink to="/skeleton">Skeleton</PrimeVueNuxtLink> component may be used to indicate the busy state.</p>
2023-02-28 08:29:30 +00:00
</DocSectionText>
<div class="card">
<DataView :value="products" :layout="layout">
<template #header>
2024-05-20 12:14:38 +00:00
<div class="flex justify-end">
<SelectButton v-model="layout" :options="options" :allowEmpty="false">
<template #option="{ option }">
<i :class="[option === 'list' ? 'pi pi-bars' : 'pi pi-th-large']" />
</template>
</SelectButton>
2023-02-28 08:29:30 +00:00
</div>
</template>
<template #list>
2024-05-20 12:14:38 +00:00
<div class="grid grid-cols-12 gap-4 grid-nogutter">
<div v-for="i in 6" :key="i" class="col-span-12">
<div class="flex flex-col xl:flex-row xl:items-start p-6 gap-6" :class="{ 'border-top-1 surface-border': i !== 0 }">
<Skeleton class="w-9/12 sm:w-64 xl:w-40 h-24 block xl:block mx-auto rounded" />
<div class="flex flex-col sm:flex-row justify-between items-center xl:items-start flex-1 gap-6">
<div class="flex flex-col items-center sm:items-start gap-4">
<Skeleton class="w-32 rounded h-8" />
<Skeleton class="w-24 rounded h-4" />
<div class="flex items-center gap-4">
<Skeleton class="w-24 rounded h-4" />
<Skeleton class="w-12 rounded h-4" />
</div>
</div>
2024-05-20 12:14:38 +00:00
<div class="flex sm:flex-col items-center sm:items-end gap-4 sm:gap-2">
<Skeleton class="w-16 rounded h-8" />
<Skeleton shape="circle" class="w-12 h-12" />
2023-02-28 08:29:30 +00:00
</div>
</div>
</div>
</div>
</div>
</template>
<template #grid>
2024-05-20 12:14:38 +00:00
<div class="grid grid-cols-12 gap-4 grid-nogutter">
<div v-for="i in 6" :key="i" class="col-span-12 sm:col-span-6 lg:col-span-12 xl:col-span-4 p-2">
<div class="p-6 border border-surface-200 dark:border-surface-700 bg-surface-0 dark:bg-surface-900 rounded">
<div class="flex flex-wrap items-center justify-between gap-2">
<Skeleton class="w-24 rounded h-8" />
<Skeleton class="w-12 rounded h-4" />
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-col items-center gap-4 py-8">
<Skeleton class="w-9/12 rounded h-40" />
<Skeleton class="w-32 rounded h-8" />
<Skeleton class="w-24 rounded h-4" />
</div>
2024-05-20 12:14:38 +00:00
<div class="flex items-center justify-between">
<Skeleton class="w-16 rounded h-8" />
<Skeleton shape="circle" class="w-12 h-12" />
</div>
2023-02-28 08:29:30 +00:00
</div>
</div>
</div>
</template>
</DataView>
</div>
<DocSectionCode :code="code" :service="['ProductService']" />
</template>
<script>
import { ProductService } from '@/service/ProductService';
export default {
data() {
return {
products: null,
2024-05-20 12:14:38 +00:00
layout: 'grid grid-cols-12 gap-4',
options: ['list', 'grid grid-cols-12 gap-4'],
2023-02-28 08:29:30 +00:00
code: {
2023-09-22 12:54:14 +00:00
basic: `
<DataView :value="products" :layout="layout">
2023-02-28 08:29:30 +00:00
<template #header>
2024-05-20 12:14:38 +00:00
<div class="flex justify-end">
<SelectButton v-model="layout" :options="options" :allowEmpty="false">
<template #option="{ option }">
<i :class="[option === 'list' ? 'pi pi-bars' : 'pi pi-th-large']" />
</template>
</SelectButton>
2023-02-28 08:29:30 +00:00
</div>
</template>
<template #list>
2024-05-20 12:14:38 +00:00
<div class="grid grid-cols-12 gap-4 grid-nogutter">
<div v-for="i in 6" :key="i" class="col-span-12">
<div class="flex flex-col xl:flex-row xl:items-start p-6 gap-6" :class="{ 'border-top-1 surface-border': i !== 0 }">
<Skeleton class="w-9/12 sm:w-64 xl:w-40 h-24 block xl:block mx-auto rounded" />
<div class="flex flex-col sm:flex-row justify-between items-center xl:items-start flex-1 gap-6">
<div class="flex flex-col items-center sm:items-start gap-4">
<Skeleton class="w-32 rounded h-8" />
<Skeleton class="w-24 rounded h-4" />
<div class="flex items-center gap-4">
<Skeleton class="w-24 rounded h-4" />
<Skeleton class="w-12 rounded h-4" />
</div>
</div>
2024-05-20 12:14:38 +00:00
<div class="flex sm:flex-col items-center sm:items-end gap-4 sm:gap-2">
<Skeleton class="w-16 rounded h-8" />
<Skeleton shape="circle" class="w-12 h-12" />
2023-02-28 08:29:30 +00:00
</div>
</div>
</div>
</div>
</div>
</template>
<template #grid>
2024-05-20 12:14:38 +00:00
<div class="grid grid-cols-12 gap-4 grid-nogutter">
<div v-for="i in 6" :key="i" class="col-span-12 sm:col-span-6 lg:col-span-12 xl:col-span-4 p-2">
<div class="p-6 border border-surface-200 dark:border-surface-700 bg-surface-0 dark:bg-surface-900 rounded">
<div class="flex flex-wrap items-center justify-between gap-2">
<Skeleton class="w-24 rounded h-8" />
<Skeleton class="w-12 rounded h-4" />
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-col items-center gap-4 py-8">
<Skeleton class="w-9/12 rounded h-40" />
<Skeleton class="w-32 rounded h-8" />
<Skeleton class="w-24 rounded h-4" />
</div>
2024-05-20 12:14:38 +00:00
<div class="flex items-center justify-between">
<Skeleton class="w-16 rounded h-8" />
<Skeleton shape="circle" class="w-12 h-12" />
</div>
2023-02-28 08:29:30 +00:00
</div>
</div>
</div>
</template>
2023-10-15 09:38:39 +00:00
</DataView>
`,
2023-09-22 12:54:14 +00:00
options: `
<template>
2023-02-28 08:29:30 +00:00
<div class="card">
<DataView :value="products" :layout="layout">
<template #header>
2024-05-20 12:14:38 +00:00
<div class="flex justify-end">
<SelectButton v-model="layout" :options="options" :allowEmpty="false">
<template #option="{ option }">
<i :class="[option === 'list' ? 'pi pi-bars' : 'pi pi-th-large']" />
</template>
</SelectButton>
2023-02-28 08:29:30 +00:00
</div>
</template>
<template #list>
2024-05-20 12:14:38 +00:00
<div class="grid grid-cols-12 gap-4 grid-nogutter">
<div v-for="i in 6" :key="i" class="col-span-12">
<div class="flex flex-col xl:flex-row xl:items-start p-6 gap-6" :class="{ 'border-top-1 surface-border': i !== 0 }">
<Skeleton class="w-9/12 sm:w-64 xl:w-40 h-24 block xl:block mx-auto rounded" />
<div class="flex flex-col sm:flex-row justify-between items-center xl:items-start flex-1 gap-6">
<div class="flex flex-col items-center sm:items-start gap-4">
<Skeleton class="w-32 rounded h-8" />
<Skeleton class="w-24 rounded h-4" />
<div class="flex items-center gap-4">
<Skeleton class="w-24 rounded h-4" />
<Skeleton class="w-12 rounded h-4" />
</div>
</div>
2024-05-20 12:14:38 +00:00
<div class="flex sm:flex-col items-center sm:items-end gap-4 sm:gap-2">
<Skeleton class="w-16 rounded h-8" />
<Skeleton shape="circle" class="w-12 h-12" />
2023-02-28 08:29:30 +00:00
</div>
</div>
</div>
</div>
</div>
</template>
<template #grid>
2024-05-20 12:14:38 +00:00
<div class="grid grid-cols-12 gap-4 grid-nogutter">
<div v-for="i in 6" :key="i" class="col-span-12 sm:col-span-6 lg:col-span-12 xl:col-span-4 p-2">
<div class="p-6 border border-surface-200 dark:border-surface-700 bg-surface-0 dark:bg-surface-900 rounded">
<div class="flex flex-wrap items-center justify-between gap-2">
<Skeleton class="w-24 rounded h-8" />
<Skeleton class="w-12 rounded h-4" />
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-col items-center gap-4 py-8">
<Skeleton class="w-9/12 rounded h-40" />
<Skeleton class="w-32 rounded h-8" />
<Skeleton class="w-24 rounded h-4" />
</div>
2024-05-20 12:14:38 +00:00
<div class="flex items-center justify-between">
<Skeleton class="w-16 rounded h-8" />
<Skeleton shape="circle" class="w-12 h-12" />
</div>
2023-02-28 08:29:30 +00:00
</div>
</div>
</div>
</template>
</DataView>
</div>
</template>
<script>
import { ProductService } from '@/service/ProductService';
export default {
data() {
return {
products: null,
2024-05-20 12:14:38 +00:00
layout: 'grid grid-cols-12 gap-4',
options: ['list', 'grid grid-cols-12 gap-4'],
2023-02-28 08:29:30 +00:00
}
},
mounted() {
ProductService.getProductsSmall().then((data) => (this.products = data.slice(0, 6)));
},
methods: {
getSeverity(product) {
switch (product.inventoryStatus) {
case 'INSTOCK':
return 'success';
case 'LOWSTOCK':
2024-04-16 07:35:56 +00:00
return 'warn';
2023-02-28 08:29:30 +00:00
case 'OUTOFSTOCK':
return 'danger';
default:
return null;
}
}
}
}
2023-10-15 09:38:39 +00:00
<\/script>
`,
2023-09-22 12:54:14 +00:00
composition: `
<template>
2023-02-28 08:29:30 +00:00
<div class="card">
<DataView :value="products" :layout="layout">
<template #header>
2024-05-20 12:14:38 +00:00
<div class="flex justify-end">
<SelectButton v-model="layout" :options="options" :allowEmpty="false">
<template #option="{ option }">
<i :class="[option === 'list' ? 'pi pi-bars' : 'pi pi-th-large']" />
</template>
</SelectButton>
2023-02-28 08:29:30 +00:00
</div>
</template>
<template #list>
2024-05-20 12:14:38 +00:00
<div class="grid grid-cols-12 gap-4 grid-nogutter">
<div v-for="i in 6" :key="i" class="col-span-12">
<div class="flex flex-col xl:flex-row xl:items-start p-6 gap-6" :class="{ 'border-top-1 surface-border': i !== 0 }">
<Skeleton class="w-9/12 sm:w-64 xl:w-40 h-24 block xl:block mx-auto rounded" />
<div class="flex flex-col sm:flex-row justify-between items-center xl:items-start flex-1 gap-6">
<div class="flex flex-col items-center sm:items-start gap-4">
<Skeleton class="w-32 rounded h-8" />
<Skeleton class="w-24 rounded h-4" />
<div class="flex items-center gap-4">
<Skeleton class="w-24 rounded h-4" />
<Skeleton class="w-12 rounded h-4" />
</div>
</div>
2024-05-20 12:14:38 +00:00
<div class="flex sm:flex-col items-center sm:items-end gap-4 sm:gap-2">
<Skeleton class="w-16 rounded h-8" />
<Skeleton shape="circle" class="w-12 h-12" />
2023-02-28 08:29:30 +00:00
</div>
</div>
</div>
</div>
</div>
</template>
<template #grid>
2024-05-20 12:14:38 +00:00
<div class="grid grid-cols-12 gap-4 grid-nogutter">
<div v-for="i in 6" :key="i" class="col-span-12 sm:col-span-6 lg:col-span-12 xl:col-span-4 p-2">
<div class="p-6 border border-surface-200 dark:border-surface-700 bg-surface-0 dark:bg-surface-900 rounded">
<div class="flex flex-wrap items-center justify-between gap-2">
<Skeleton class="w-24 rounded h-8" />
<Skeleton class="w-12 rounded h-4" />
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-col items-center gap-4 py-8">
<Skeleton class="w-9/12 rounded h-40" />
<Skeleton class="w-32 rounded h-8" />
<Skeleton class="w-24 rounded h-4" />
</div>
2024-05-20 12:14:38 +00:00
<div class="flex items-center justify-between">
<Skeleton class="w-16 rounded h-8" />
<Skeleton shape="circle" class="w-12 h-12" />
</div>
2023-02-28 08:29:30 +00:00
</div>
</div>
</div>
</template>
</DataView>
</div>
</template>
<script setup>
import { ref, onMounted } from "vue";
import { ProductService } from '@/service/ProductService';
onMounted(() => {
ProductService.getProductsSmall().then((data) => (products.value = data.slice(0, 6)));
});
const products = ref();
2024-05-20 12:14:38 +00:00
const layout = ref('grid grid-cols-12 gap-4');
const options = ref(['list', 'grid grid-cols-12 gap-4']);
2023-02-28 08:29:30 +00:00
const getSeverity = (product) => {
switch (product.inventoryStatus) {
case 'INSTOCK':
return 'success';
case 'LOWSTOCK':
2024-04-16 07:35:56 +00:00
return 'warn';
2023-02-28 08:29:30 +00:00
case 'OUTOFSTOCK':
return 'danger';
default:
return null;
}
}
2023-10-15 09:38:39 +00:00
<\/script>
`,
2023-02-28 08:29:30 +00:00
data: `
/* ProductService */
2023-02-28 08:29:30 +00:00
{
id: '1000',
code: 'f230fh0g3',
name: 'Bamboo Watch',
description: 'Product Description',
image: 'bamboo-watch.jpg',
price: 65,
category: 'Accessories',
quantity: 24,
inventoryStatus: 'INSTOCK',
rating: 5
},
...
`
}
};
},
mounted() {
ProductService.getProductsSmall().then((data) => (this.products = data.slice(0, 6)));
},
methods: {
getSeverity(product) {
switch (product.inventoryStatus) {
case 'INSTOCK':
return 'success';
case 'LOWSTOCK':
2024-04-16 07:35:56 +00:00
return 'warn';
2023-02-28 08:29:30 +00:00
case 'OUTOFSTOCK':
return 'danger';
default:
return null;
}
}
}
};
</script>