primevue-mirror/doc/dataview/LayoutDoc.vue

463 lines
26 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>DataView supports <i>list</i> and <i>grid</i> display modes defined with the <i>layout</i> property.</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 }">
2024-05-24 06:25:19 +00:00
<i :class="[option === 'list' ? 'pi pi-bars' : 'pi pi-table']" />
</template>
</SelectButton>
2023-02-28 08:29:30 +00:00
</div>
</template>
<template #list="slotProps">
2024-05-21 11:38:41 +00:00
<div class="flex flex-col">
<div v-for="(item, index) in slotProps.items" :key="index">
<div class="flex flex-col sm:flex-row sm:items-center p-6 gap-4" :class="{ 'border-t border-surface-200 dark:border-surface-700': index !== 0 }">
2024-05-20 12:14:38 +00:00
<div class="md:w-40 relative">
<img class="block xl:block mx-auto rounded w-full" :src="`https://primefaces.org/cdn/primevue/images/product/${item.image}`" :alt="item.name" />
2024-01-24 08:38:08 +00:00
<Tag :value="item.inventoryStatus" :severity="getSeverity(item)" class="absolute" style="left: 4px; top: 4px"></Tag>
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-col md:flex-row justify-between md:items-center flex-1 gap-6">
<div class="flex flex-row md:flex-col justify-between items-start gap-2">
2024-01-24 08:38:08 +00:00
<div>
2024-05-21 07:57:47 +00:00
<span class="font-medium text-surface-500 dark:text-surface-400 text-sm">{{ item.category }}</span>
2024-05-21 11:17:35 +00:00
<div class="text-lg font-medium mt-2">{{ item.name }}</div>
2024-01-24 08:38:08 +00:00
</div>
2024-05-20 12:14:38 +00:00
<div class="bg-surface-100 p-1" style="border-radius: 30px">
<div class="bg-surface-0 flex items-center gap-2 justify-center py-1 px-2" style="border-radius: 30px; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.04), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)">
<span class="text-surface-900 font-medium text-sm">{{ item.rating }}</span>
2024-01-24 08:38:08 +00:00
<i class="pi pi-star-fill text-yellow-500"></i>
</div>
</div>
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-col md:items-end gap-8">
2024-05-21 11:17:35 +00:00
<span class="text-xl font-semibold">${{ item.price }}</span>
2024-01-24 08:38:08 +00:00
<div class="flex flex-row-reverse md:flex-row gap-2">
<Button icon="pi pi-heart" outlined></Button>
2024-05-20 12:14:38 +00:00
<Button icon="pi pi-shopping-cart" label="Buy Now" :disabled="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto md:flex-initial whitespace-nowrap"></Button>
2024-01-24 08:38:08 +00:00
</div>
2023-02-28 08:29:30 +00:00
</div>
</div>
</div>
</div>
</div>
</template>
<template #grid="slotProps">
2024-05-24 06:25:19 +00:00
<div class="grid grid-cols-12 gap-4">
2024-05-20 12:14:38 +00:00
<div v-for="(item, index) in slotProps.items" :key="index" class="col-span-12 sm:col-span-6 md:col-span-4 xl:col-span-6 p-2">
<div class="p-6 border border-surface-200 dark:border-surface-700 bg-surface-0 dark:bg-surface-900 rounded flex flex-col">
<div class="bg-surface-50 flex justify-center rounded p-4">
2024-01-24 08:38:08 +00:00
<div class="relative mx-auto">
2024-05-20 12:14:38 +00:00
<img class="rounded w-full" :src="`https://primefaces.org/cdn/primevue/images/product/${item.image}`" :alt="item.name" style="max-width: 300px" />
2024-01-24 08:38:08 +00:00
<Tag :value="item.inventoryStatus" :severity="getSeverity(item)" class="absolute" style="left: 4px; top: 4px"></Tag>
</div>
</div>
2024-05-20 12:14:38 +00:00
<div class="pt-6">
<div class="flex flex-row justify-between items-start gap-2">
2024-01-24 08:38:08 +00:00
<div>
2024-05-21 07:57:47 +00:00
<span class="font-medium text-surface-500 dark:text-surface-400 text-sm">{{ item.category }}</span>
2024-05-21 11:17:35 +00:00
<div class="text-lg font-medium mt-1">{{ item.name }}</div>
2024-01-24 08:38:08 +00:00
</div>
2024-05-20 12:14:38 +00:00
<div class="bg-surface-100 p-1" style="border-radius: 30px">
<div class="bg-surface-0 flex items-center gap-2 justify-center py-1 px-2" style="border-radius: 30px; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.04), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)">
<span class="text-surface-900 font-medium text-sm">{{ item.rating }}</span>
2024-01-24 08:38:08 +00:00
<i class="pi pi-star-fill text-yellow-500"></i>
</div>
</div>
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-col gap-6 mt-6">
2024-05-21 11:17:35 +00:00
<span class="text-2xl font-semibold">${{ item.price }}</span>
2024-01-24 08:38:08 +00:00
<div class="flex gap-2">
2024-05-20 12:14:38 +00:00
<Button icon="pi pi-shopping-cart" label="Buy Now" :disabled="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto whitespace-nowrap"></Button>
2024-01-24 08:38:08 +00:00
<Button icon="pi pi-heart" outlined></Button>
</div>
</div>
2023-02-28 08:29:30 +00:00
</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,
2024-05-24 06:25:19 +00:00
layout: 'grid',
options: ['list', 'grid'],
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 }">
2024-05-24 06:25:19 +00:00
<i :class="[option === 'list' ? 'pi pi-bars' : 'pi pi-table']" />
</template>
</SelectButton>
2023-02-28 08:29:30 +00:00
</div>
</template>
<template #list="slotProps">
2024-05-21 11:38:41 +00:00
<div class="flex flex-col">
<div v-for="(item, index) in slotProps.items" :key="index">
<div class="flex flex-col sm:flex-row sm:items-center p-6 gap-4" :class="{ 'border-t border-surface-200 dark:border-surface-700': index !== 0 }">
2024-05-20 12:14:38 +00:00
<div class="md:w-40 relative">
<img class="block xl:block mx-auto rounded w-full" :src="\`https://primefaces.org/cdn/primevue/images/product/\${item.image}\`" :alt="item.name" />
2024-01-24 08:38:08 +00:00
<Tag :value="item.inventoryStatus" :severity="getSeverity(item)" class="absolute" style="left: 4px; top: 4px"></Tag>
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-col md:flex-row justify-between md:items-center flex-1 gap-6">
<div class="flex flex-row md:flex-col justify-between items-start gap-2">
2024-01-24 08:38:08 +00:00
<div>
2024-05-21 07:57:47 +00:00
<span class="font-medium text-surface-500 dark:text-surface-400 text-sm">{{ item.category }}</span>
2024-05-21 11:17:35 +00:00
<div class="text-lg font-medium mt-2">{{ item.name }}</div>
2024-01-24 08:38:08 +00:00
</div>
2024-05-20 12:14:38 +00:00
<div class="bg-surface-100 p-1" style="border-radius: 30px">
<div class="bg-surface-0 flex items-center gap-2 justify-center py-1 px-2" style="border-radius: 30px; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.04), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)">
<span class="text-surface-900 font-medium text-sm">{{ item.rating }}</span>
2024-01-24 08:38:08 +00:00
<i class="pi pi-star-fill text-yellow-500"></i>
</div>
</div>
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-col md:items-end gap-8">
2024-05-21 11:17:35 +00:00
<span class="text-xl font-semibold">\${{ item.price }}</span>
2024-01-24 08:38:08 +00:00
<div class="flex flex-row-reverse md:flex-row gap-2">
<Button icon="pi pi-heart" outlined></Button>
2024-05-20 12:14:38 +00:00
<Button icon="pi pi-shopping-cart" label="Buy Now" :disabled="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto md:flex-initial whitespace-nowrap"></Button>
2024-01-24 08:38:08 +00:00
</div>
2023-02-28 08:29:30 +00:00
</div>
</div>
</div>
</div>
</div>
</template>
<template #grid="slotProps">
2024-05-24 06:25:19 +00:00
<div class="grid grid-cols-12 gap-4">
2024-05-20 12:14:38 +00:00
<div v-for="(item, index) in slotProps.items" :key="index" class="col-span-12 sm:col-span-6 md:col-span-4 xl:col-span-6 p-2">
<div class="p-6 border border-surface-200 dark:border-surface-700 bg-surface-0 dark:bg-surface-900 rounded flex flex-col">
<div class="bg-surface-50 flex justify-center rounded p-4">
2024-01-24 08:38:08 +00:00
<div class="relative mx-auto">
2024-05-20 12:14:38 +00:00
<img class="rounded w-full" :src="\`https://primefaces.org/cdn/primevue/images/product/\${item.image}\`" :alt="item.name" style="max-width: 300px"/>
2024-01-24 08:38:08 +00:00
<Tag :value="item.inventoryStatus" :severity="getSeverity(item)" class="absolute" style="left: 4px; top: 4px"></Tag>
</div>
</div>
2024-05-20 12:14:38 +00:00
<div class="pt-6">
<div class="flex flex-row justify-between items-start gap-2">
2024-01-24 08:38:08 +00:00
<div>
2024-05-21 07:57:47 +00:00
<span class="font-medium text-surface-500 dark:text-surface-400 text-sm">{{ item.category }}</span>
2024-05-21 11:17:35 +00:00
<div class="text-lg font-medium mt-1">{{ item.name }}</div>
2024-01-24 08:38:08 +00:00
</div>
2024-05-20 12:14:38 +00:00
<div class="bg-surface-100 p-1" style="border-radius: 30px">
<div class="bg-surface-0 flex items-center gap-2 justify-center py-1 px-2" style="border-radius: 30px; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.04), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)">
<span class="text-surface-900 font-medium text-sm">{{ item.rating }}</span>
2024-01-24 08:38:08 +00:00
<i class="pi pi-star-fill text-yellow-500"></i>
</div>
</div>
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-col gap-6 mt-6">
2024-05-21 11:17:35 +00:00
<span class="text-2xl font-semibold">\${{ item.price }}</span>
2024-01-24 08:38:08 +00:00
<div class="flex gap-2">
2024-05-20 12:14:38 +00:00
<Button icon="pi pi-shopping-cart" label="Buy Now" :disabled="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto whitespace-nowrap"></Button>
2024-01-24 08:38:08 +00:00
<Button icon="pi pi-heart" outlined></Button>
</div>
</div>
2023-02-28 08:29:30 +00:00
</div>
</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 }">
2024-05-24 06:25:19 +00:00
<i :class="[option === 'list' ? 'pi pi-bars' : 'pi pi-table']" />
</template>
</SelectButton>
2023-02-28 08:29:30 +00:00
</div>
</template>
<template #list="slotProps">
2024-05-21 11:38:41 +00:00
<div class="flex flex-col">
<div v-for="(item, index) in slotProps.items" :key="index">
<div class="flex flex-col sm:flex-row sm:items-center p-6 gap-4" :class="{ 'border-t border-surface-200 dark:border-surface-700': index !== 0 }">
2024-05-20 12:14:38 +00:00
<div class="md:w-40 relative">
<img class="block xl:block mx-auto rounded w-full" :src="\`https://primefaces.org/cdn/primevue/images/product/\${item.image}\`" :alt="item.name" />
2024-01-24 08:38:08 +00:00
<Tag :value="item.inventoryStatus" :severity="getSeverity(item)" class="absolute" style="left: 4px; top: 4px"></Tag>
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-col md:flex-row justify-between md:items-center flex-1 gap-6">
<div class="flex flex-row md:flex-col justify-between items-start gap-2">
2024-01-24 08:38:08 +00:00
<div>
2024-05-21 07:57:47 +00:00
<span class="font-medium text-surface-500 dark:text-surface-400 text-sm">{{ item.category }}</span>
2024-05-21 11:17:35 +00:00
<div class="text-lg font-medium mt-2">{{ item.name }}</div>
2024-01-24 08:38:08 +00:00
</div>
2024-05-20 12:14:38 +00:00
<div class="bg-surface-100 p-1" style="border-radius: 30px">
<div class="bg-surface-0 flex items-center gap-2 justify-center py-1 px-2" style="border-radius: 30px; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.04), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)">
<span class="text-surface-900 font-medium text-sm">{{ item.rating }}</span>
2024-01-24 08:38:08 +00:00
<i class="pi pi-star-fill text-yellow-500"></i>
</div>
</div>
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-col md:items-end gap-8">
2024-05-21 11:17:35 +00:00
<span class="text-xl font-semibold">\${{ item.price }}</span>
2024-01-24 08:38:08 +00:00
<div class="flex flex-row-reverse md:flex-row gap-2">
<Button icon="pi pi-heart" outlined></Button>
2024-05-20 12:14:38 +00:00
<Button icon="pi pi-shopping-cart" label="Buy Now" :disabled="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto md:flex-initial whitespace-nowrap"></Button>
2024-01-24 08:38:08 +00:00
</div>
2023-02-28 08:29:30 +00:00
</div>
</div>
</div>
</div>
</div>
</template>
<template #grid="slotProps">
2024-05-24 06:25:19 +00:00
<div class="grid grid-cols-12 gap-4">
2024-05-20 12:14:38 +00:00
<div v-for="(item, index) in slotProps.items" :key="index" class="col-span-12 sm:col-span-6 md:col-span-4 xl:col-span-6 p-2">
<div class="p-6 border border-surface-200 dark:border-surface-700 bg-surface-0 dark:bg-surface-900 rounded flex flex-col">
<div class="bg-surface-50 flex justify-center rounded p-4">
2024-01-24 08:38:08 +00:00
<div class="relative mx-auto">
2024-05-20 12:14:38 +00:00
<img class="rounded w-full" :src="\`https://primefaces.org/cdn/primevue/images/product/\${item.image}\`" :alt="item.name" style="max-width: 300px"/>
2024-01-24 08:38:08 +00:00
<Tag :value="item.inventoryStatus" :severity="getSeverity(item)" class="absolute" style="left: 4px; top: 4px"></Tag>
</div>
</div>
2024-05-20 12:14:38 +00:00
<div class="pt-6">
<div class="flex flex-row justify-between items-start gap-2">
2024-01-24 08:38:08 +00:00
<div>
2024-05-21 07:57:47 +00:00
<span class="font-medium text-surface-500 dark:text-surface-400 text-sm">{{ item.category }}</span>
2024-05-21 11:17:35 +00:00
<div class="text-lg font-medium mt-1">{{ item.name }}</div>
2024-01-24 08:38:08 +00:00
</div>
2024-05-20 12:14:38 +00:00
<div class="bg-surface-100 p-1" style="border-radius: 30px">
<div class="bg-surface-0 flex items-center gap-2 justify-center py-1 px-2" style="border-radius: 30px; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.04), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)">
<span class="text-surface-900 font-medium text-sm">{{ item.rating }}</span>
2024-01-24 08:38:08 +00:00
<i class="pi pi-star-fill text-yellow-500"></i>
</div>
</div>
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-col gap-6 mt-6">
2024-05-21 11:17:35 +00:00
<span class="text-2xl font-semibold">\${{ item.price }}</span>
2024-01-24 08:38:08 +00:00
<div class="flex gap-2">
2024-05-20 12:14:38 +00:00
<Button icon="pi pi-shopping-cart" label="Buy Now" :disabled="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto whitespace-nowrap"></Button>
2024-01-24 08:38:08 +00:00
<Button icon="pi pi-heart" outlined></Button>
</div>
</div>
2023-02-28 08:29:30 +00:00
</div>
</div>
</div>
</div>
</template>
</DataView>
</div>
</template>
<script>
import { ProductService } from '@/service/ProductService';
export default {
data() {
return {
products: null,
2024-05-24 06:25:19 +00:00
layout: 'grid',
options: ['list', 'grid'],
2023-02-28 08:29:30 +00:00
}
},
mounted() {
ProductService.getProducts().then((data) => (this.products = data.slice(0, 12)));
},
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 }">
2024-05-24 06:25:19 +00:00
<i :class="[option === 'list' ? 'pi pi-bars' : 'pi pi-table']" />
</template>
</SelectButton>
2023-02-28 08:29:30 +00:00
</div>
</template>
<template #list="slotProps">
2024-05-21 11:38:41 +00:00
<div class="flex flex-col">
<div v-for="(item, index) in slotProps.items" :key="index"">
<div class="flex flex-col sm:flex-row sm:items-center p-6 gap-4" :class="{ 'border-t border-surface-200 dark:border-surface-700': index !== 0 }">
2024-05-20 12:14:38 +00:00
<div class="md:w-40 relative">
<img class="block xl:block mx-auto rounded w-full" :src="\`https://primefaces.org/cdn/primevue/images/product/\${item.image}\`" :alt="item.name" />
2024-01-24 08:38:08 +00:00
<Tag :value="item.inventoryStatus" :severity="getSeverity(item)" class="absolute" style="left: 4px; top: 4px"></Tag>
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-col md:flex-row justify-between md:items-center flex-1 gap-6">
<div class="flex flex-row md:flex-col justify-between items-start gap-2">
2024-01-24 08:38:08 +00:00
<div>
2024-05-21 07:57:47 +00:00
<span class="font-medium text-surface-500 dark:text-surface-400 text-sm">{{ item.category }}</span>
2024-05-21 11:17:35 +00:00
<div class="text-lg font-medium mt-2">{{ item.name }}</div>
2024-01-24 08:38:08 +00:00
</div>
2024-05-20 12:14:38 +00:00
<div class="bg-surface-100 p-1" style="border-radius: 30px">
<div class="bg-surface-0 flex items-center gap-2 justify-center py-1 px-2" style="border-radius: 30px; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.04), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)">
<span class="text-surface-900 font-medium text-sm">{{ item.rating }}</span>
2024-01-24 08:38:08 +00:00
<i class="pi pi-star-fill text-yellow-500"></i>
</div>
</div>
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-col md:items-end gap-8">
2024-05-21 11:17:35 +00:00
<span class="text-xl font-semibold">\${{ item.price }}</span>
2024-01-24 08:38:08 +00:00
<div class="flex flex-row-reverse md:flex-row gap-2">
<Button icon="pi pi-heart" outlined></Button>
2024-05-20 12:14:38 +00:00
<Button icon="pi pi-shopping-cart" label="Buy Now" :disabled="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto md:flex-initial whitespace-nowrap"></Button>
2024-01-24 08:38:08 +00:00
</div>
2023-02-28 08:29:30 +00:00
</div>
</div>
</div>
</div>
</div>
</template>
<template #grid="slotProps">
2024-05-24 06:25:19 +00:00
<div class="grid grid-cols-12 gap-4">
2024-05-20 12:14:38 +00:00
<div v-for="(item, index) in slotProps.items" :key="index" class="col-span-12 sm:col-span-6 md:col-span-4 xl:col-span-6 p-2">
<div class="p-6 border border-surface-200 dark:border-surface-700 bg-surface-0 dark:bg-surface-900 rounded flex flex-col">
<div class="bg-surface-50 flex justify-center rounded p-4">
2024-01-24 08:38:08 +00:00
<div class="relative mx-auto">
2024-05-20 12:14:38 +00:00
<img class="rounded w-full" :src="\`https://primefaces.org/cdn/primevue/images/product/\${item.image}\`" :alt="item.name" style="max-width: 300px"/>
2024-01-24 08:38:08 +00:00
<Tag :value="item.inventoryStatus" :severity="getSeverity(item)" class="absolute" style="left: 4px; top: 4px"></Tag>
</div>
</div>
2024-05-20 12:14:38 +00:00
<div class="pt-6">
<div class="flex flex-row justify-between items-start gap-2">
2024-01-24 08:38:08 +00:00
<div>
2024-05-21 07:57:47 +00:00
<span class="font-medium text-surface-500 dark:text-surface-400 text-sm">{{ item.category }}</span>
2024-05-21 11:17:35 +00:00
<div class="text-lg font-medium mt-1">{{ item.name }}</div>
2024-01-24 08:38:08 +00:00
</div>
2024-05-20 12:14:38 +00:00
<div class="bg-surface-100 p-1" style="border-radius: 30px">
<div class="bg-surface-0 flex items-center gap-2 justify-center py-1 px-2" style="border-radius: 30px; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.04), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)">
<span class="text-surface-900 font-medium text-sm">{{ item.rating }}</span>
2024-01-24 08:38:08 +00:00
<i class="pi pi-star-fill text-yellow-500"></i>
</div>
</div>
</div>
2024-05-20 12:14:38 +00:00
<div class="flex flex-col gap-6 mt-6">
2024-05-21 11:17:35 +00:00
<span class="text-2xl font-semibold">\${{ item.price }}</span>
2024-01-24 08:38:08 +00:00
<div class="flex gap-2">
2024-05-20 12:14:38 +00:00
<Button icon="pi pi-shopping-cart" label="Buy Now" :disabled="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto whitespace-nowrap"></Button>
2024-01-24 08:38:08 +00:00
<Button icon="pi pi-heart" outlined></Button>
</div>
</div>
2023-02-28 08:29:30 +00:00
</div>
</div>
</div>
</div>
</template>
</DataView>
</div>
</template>
<script setup>
import { ref, onMounted } from "vue";
import { ProductService } from '@/service/ProductService';
onMounted(() => {
ProductService.getProducts().then((data) => (products.value = data.slice(0, 12)));
});
const products = ref();
2024-05-24 06:25:19 +00:00
const layout = ref('grid');
const options = ref(['list', 'grid']);
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.getProducts().then((data) => (this.products = data.slice(0, 12)));
},
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>