primevue-mirror/apps/showcase/doc/dataview/LoadingDoc.vue

371 lines
16 KiB
Vue

<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>
</DocSectionText>
<div class="card">
<DataView :value="products" :layout="layout">
<template #header>
<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-table']" />
</template>
</SelectButton>
</div>
</template>
<template #list>
<div class="flex flex-col">
<div v-for="i in 6" :key="i">
<div class="flex flex-col xl:flex-row xl:items-start p-6 gap-6" :class="{ 'border-t border-surface-200 dark:border-surface-700': i !== 0 }">
<Skeleton class="!w-9/12 sm:!w-64 xl:!w-40 !h-24 mx-auto" />
<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 width="8rem" height="2rem" />
<Skeleton width="6rem" height="1rem" />
<div class="flex items-center gap-4">
<Skeleton width="6rem" height="1rem" />
<Skeleton width="3rem" height="1rem" />
</div>
</div>
<div class="flex sm:flex-col items-center sm:items-end gap-4 sm:gap-2">
<Skeleton width="4rem" height="2rem" />
<Skeleton size="3rem" shape="circle" />
</div>
</div>
</div>
</div>
</div>
</template>
<template #grid>
<div class="grid grid-cols-12 gap-4">
<div v-for="i in 6" :key="i" class="col-span-12 sm:col-span-6 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 width="6rem" height="2rem" />
<Skeleton width="3rem" height="1rem" />
</div>
<div class="flex flex-col items-center gap-4 py-8">
<Skeleton width="75%" height="10rem" />
<Skeleton width="8rem" height="2rem" />
<Skeleton width="6rem" height="1rem" />
</div>
<div class="flex items-center justify-between">
<Skeleton width="4rem" height="2rem" />
<Skeleton width="6rem" height="1rem" shape="circle" size="3rem" />
</div>
</div>
</div>
</div>
</template>
</DataView>
</div>
<DocSectionCode :code="code" :service="['ProductService']" />
</template>
<script>
import { ProductService } from '@/service/ProductService';
export default {
data() {
return {
products: null,
layout: 'grid',
options: ['list', 'grid'],
code: {
basic: `
<DataView :value="products" :layout="layout">
<template #header>
<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-table']" />
</template>
</SelectButton>
</div>
</template>
<template #list>
<div class="flex flex-col">
<div v-for="i in 6" :key="i">
<div class="flex flex-col xl:flex-row xl:items-start p-6 gap-6" :class="{ 'border-t border-surface-200 dark:border-surface-700': i !== 0 }">
<Skeleton class="!w-9/12 sm:!w-64 xl:!w-40 !h-24 mx-auto" />
<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 width="8rem" height="2rem" />
<Skeleton width="6rem" height="1rem" />
<div class="flex items-center gap-4">
<Skeleton width="6rem" height="1rem" />
<Skeleton width="3rem" height="1rem" />
</div>
</div>
<div class="flex sm:flex-col items-center sm:items-end gap-4 sm:gap-2">
<Skeleton width="4rem" height="2rem" />
<Skeleton size="3rem" shape="circle" />
</div>
</div>
</div>
</div>
</div>
</template>
<template #grid>
<div class="grid grid-cols-12 gap-4">
<div v-for="i in 6" :key="i" class="col-span-12 sm:col-span-6 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 width="6rem" height="2rem" />
<Skeleton width="3rem" height="1rem" />
</div>
<div class="flex flex-col items-center gap-4 py-8">
<Skeleton width="75%" height="10rem" />
<Skeleton width="8rem" height="2rem" />
<Skeleton width="6rem" height="1rem" />
</div>
<div class="flex items-center justify-between">
<Skeleton width="4rem" height="2rem" />
<Skeleton width="6rem" height="1rem" shape="circle" size="3rem" />
</div>
</div>
</div>
</div>
</template>
</DataView>
`,
options: `
<template>
<div class="card">
<DataView :value="products" :layout="layout">
<template #header>
<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-table']" />
</template>
</SelectButton>
</div>
</template>
<template #list>
<div class="flex flex-col">
<div v-for="i in 6" :key="i">
<div class="flex flex-col xl:flex-row xl:items-start p-6 gap-6" :class="{ 'border-t border-surface-200 dark:border-surface-700': i !== 0 }">
<Skeleton class="!w-9/12 sm:!w-64 xl:!w-40 !h-24 mx-auto" />
<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 width="8rem" height="2rem" />
<Skeleton width="6rem" height="1rem" />
<div class="flex items-center gap-4">
<Skeleton width="6rem" height="1rem" />
<Skeleton width="3rem" height="1rem" />
</div>
</div>
<div class="flex sm:flex-col items-center sm:items-end gap-4 sm:gap-2">
<Skeleton width="4rem" height="2rem" />
<Skeleton size="3rem" shape="circle" />
</div>
</div>
</div>
</div>
</div>
</template>
<template #grid>
<div class="grid grid-cols-12 gap-4">
<div v-for="i in 6" :key="i" class="col-span-12 sm:col-span-6 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 width="6rem" height="2rem" />
<Skeleton width="3rem" height="1rem" />
</div>
<div class="flex flex-col items-center gap-4 py-8">
<Skeleton width="75%" height="10rem" />
<Skeleton width="8rem" height="2rem" />
<Skeleton width="6rem" height="1rem" />
</div>
<div class="flex items-center justify-between">
<Skeleton width="4rem" height="2rem" />
<Skeleton width="6rem" height="1rem" shape="circle" size="3rem" />
</div>
</div>
</div>
</div>
</template>
</DataView>
</div>
</template>
<script>
import { ProductService } from '@/service/ProductService';
export default {
data() {
return {
products: null,
layout: 'grid',
options: ['list', 'grid'],
}
},
mounted() {
ProductService.getProductsSmall().then((data) => (this.products = data.slice(0, 6)));
},
methods: {
getSeverity(product) {
switch (product.inventoryStatus) {
case 'INSTOCK':
return 'success';
case 'LOWSTOCK':
return 'warn';
case 'OUTOFSTOCK':
return 'danger';
default:
return null;
}
}
}
}
<\/script>
`,
composition: `
<template>
<div class="card">
<DataView :value="products" :layout="layout">
<template #header>
<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-table']" />
</template>
</SelectButton>
</div>
</template>
<template #list>
<div class="flex flex-col">
<div v-for="i in 6" :key="i">
<div class="flex flex-col xl:flex-row xl:items-start p-6 gap-6" :class="{ 'border-t border-surface-200 dark:border-surface-700': i !== 0 }">
<Skeleton class="!w-9/12 sm:!w-64 xl:!w-40 !h-24 mx-auto" />
<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 width="8rem" height="2rem" />
<Skeleton width="6rem" height="1rem" />
<div class="flex items-center gap-4">
<Skeleton width="6rem" height="1rem" />
<Skeleton width="3rem" height="1rem" />
</div>
</div>
<div class="flex sm:flex-col items-center sm:items-end gap-4 sm:gap-2">
<Skeleton width="4rem" height="2rem" />
<Skeleton size="3rem" shape="circle" />
</div>
</div>
</div>
</div>
</div>
</template>
<template #grid>
<div class="grid grid-cols-12 gap-4">
<div v-for="i in 6" :key="i" class="col-span-12 sm:col-span-6 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 width="6rem" height="2rem" />
<Skeleton width="3rem" height="1rem" />
</div>
<div class="flex flex-col items-center gap-4 py-8">
<Skeleton width="75%" height="10rem" />
<Skeleton width="8rem" height="2rem" />
<Skeleton width="6rem" height="1rem" />
</div>
<div class="flex items-center justify-between">
<Skeleton width="4rem" height="2rem" />
<Skeleton width="6rem" height="1rem" shape="circle" size="3rem" />
</div>
</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();
const layout = ref('grid');
const options = ref(['list', 'grid']);
const getSeverity = (product) => {
switch (product.inventoryStatus) {
case 'INSTOCK':
return 'success';
case 'LOWSTOCK':
return 'warn';
case 'OUTOFSTOCK':
return 'danger';
default:
return null;
}
}
<\/script>
`,
data: `
/* ProductService */
{
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':
return 'warn';
case 'OUTOFSTOCK':
return 'danger';
default:
return null;
}
}
}
};
</script>