2023-02-28 08:29:30 +00:00
|
|
|
<template>
|
|
|
|
<DocSectionText v-bind="$attrs">
|
|
|
|
<p>Carousel requires a collection of items as its value along with a template to render each item.</p>
|
|
|
|
</DocSectionText>
|
|
|
|
|
|
|
|
<div class="card">
|
|
|
|
<Carousel :value="products" :numVisible="3" :numScroll="3" :responsiveOptions="responsiveOptions">
|
|
|
|
<template #item="slotProps">
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="border border-surface-200 dark:border-surface-700 rounded m-2 p-4">
|
|
|
|
<div class="mb-4">
|
2024-01-24 09:08:37 +00:00
|
|
|
<div class="relative mx-auto">
|
2024-05-20 12:14:38 +00:00
|
|
|
<img :src="'https://primefaces.org/cdn/primevue/images/product/' + slotProps.data.image" :alt="slotProps.data.name" class="w-full rounded" />
|
2024-01-24 09:37:48 +00:00
|
|
|
<Tag :value="slotProps.data.inventoryStatus" :severity="getSeverity(slotProps.data.inventoryStatus)" class="absolute" style="left: 5px; top: 5px" />
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="mb-4 font-medium">{{ slotProps.data.name }}</div>
|
|
|
|
<div class="flex justify-between items-center">
|
2024-01-24 09:08:37 +00:00
|
|
|
<div class="mt-0 font-semibold text-xl">${{ slotProps.data.price }}</div>
|
|
|
|
<span>
|
|
|
|
<Button icon="pi pi-heart" severity="secondary" outlined />
|
2024-01-24 09:37:48 +00:00
|
|
|
<Button icon="pi pi-shopping-cart" class="ml-2" />
|
2024-01-24 09:08:37 +00:00
|
|
|
</span>
|
|
|
|
</div>
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</Carousel>
|
|
|
|
</div>
|
|
|
|
<DocSectionCode :code="code" :service="['ProductService']" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { ProductService } from '@/service/ProductService';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
products: null,
|
|
|
|
responsiveOptions: [
|
|
|
|
{
|
2023-10-25 09:14:33 +00:00
|
|
|
breakpoint: '1400px',
|
|
|
|
numVisible: 2,
|
|
|
|
numScroll: 1
|
|
|
|
},
|
|
|
|
{
|
2023-10-26 18:39:49 +00:00
|
|
|
breakpoint: '1199px',
|
|
|
|
numVisible: 3,
|
2023-09-26 12:28:22 +00:00
|
|
|
numScroll: 1
|
2023-02-28 08:29:30 +00:00
|
|
|
},
|
|
|
|
{
|
2023-10-26 18:39:49 +00:00
|
|
|
breakpoint: '767px',
|
2023-02-28 08:29:30 +00:00
|
|
|
numVisible: 2,
|
2023-09-26 12:28:22 +00:00
|
|
|
numScroll: 1
|
2023-02-28 08:29:30 +00:00
|
|
|
},
|
|
|
|
{
|
2023-10-26 18:39:49 +00:00
|
|
|
breakpoint: '575px',
|
2023-02-28 08:29:30 +00:00
|
|
|
numVisible: 1,
|
|
|
|
numScroll: 1
|
|
|
|
}
|
|
|
|
],
|
|
|
|
code: {
|
2023-09-22 12:54:14 +00:00
|
|
|
basic: `
|
|
|
|
<Carousel :value="products" :numVisible="3" :numScroll="3" :responsiveOptions="responsiveOptions">
|
2023-02-28 08:29:30 +00:00
|
|
|
<template #item="slotProps">
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="border border-surface-200 dark:border-surface-700 rounded m-2 p-4">
|
|
|
|
<div class="mb-4">
|
2024-01-24 09:08:37 +00:00
|
|
|
<div class="relative mx-auto">
|
2024-05-20 12:14:38 +00:00
|
|
|
<img :src="'https://primefaces.org/cdn/primevue/images/product/' + slotProps.data.image" :alt="slotProps.data.name" class="w-full rounded" />
|
2024-01-24 09:08:37 +00:00
|
|
|
<Tag :value="slotProps.data.inventoryStatus" :severity="getSeverity(slotProps.data.inventoryStatus)" class="absolute" style="left:5px; top: 5px"/>
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="mb-4 font-medium">{{ slotProps.data.name }}</div>
|
|
|
|
<div class="flex justify-between items-center">
|
2024-01-24 09:08:37 +00:00
|
|
|
<div class="mt-0 font-semibold text-xl">\${{ slotProps.data.price }}</div>
|
|
|
|
<span>
|
|
|
|
<Button icon="pi pi-heart" severity="secondary" outlined />
|
|
|
|
<Button icon="pi pi-shopping-cart" class="ml-2"/>
|
|
|
|
</span>
|
|
|
|
</div>
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
2023-10-15 09:38:39 +00:00
|
|
|
</Carousel>
|
|
|
|
`,
|
2023-09-22 12:54:14 +00:00
|
|
|
options: `
|
|
|
|
<template>
|
2023-02-28 08:29:30 +00:00
|
|
|
<div class="card">
|
|
|
|
<Carousel :value="products" :numVisible="3" :numScroll="3" :responsiveOptions="responsiveOptions">
|
|
|
|
<template #item="slotProps">
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="border border-surface-200 dark:border-surface-700 rounded m-2 p-4">
|
|
|
|
<div class="mb-4">
|
2024-01-24 09:08:37 +00:00
|
|
|
<div class="relative mx-auto">
|
2024-05-20 12:14:38 +00:00
|
|
|
<img :src="'https://primefaces.org/cdn/primevue/images/product/' + slotProps.data.image" :alt="slotProps.data.name" class="w-full rounded" />
|
2024-01-24 09:08:37 +00:00
|
|
|
<Tag :value="slotProps.data.inventoryStatus" :severity="getSeverity(slotProps.data.inventoryStatus)" class="absolute" style="left:5px; top: 5px"/>
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="mb-4 font-medium">{{ slotProps.data.name }}</div>
|
|
|
|
<div class="flex justify-between items-center">
|
2024-01-24 09:08:37 +00:00
|
|
|
<div class="mt-0 font-semibold text-xl">\${{ slotProps.data.price }}</div>
|
|
|
|
<span>
|
|
|
|
<Button icon="pi pi-heart" severity="secondary" outlined />
|
|
|
|
<Button icon="pi pi-shopping-cart" class="ml-2"/>
|
|
|
|
</span>
|
|
|
|
</div>
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</Carousel>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { ProductService } from '@/service/ProductService';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
products: null,
|
|
|
|
responsiveOptions: [
|
2023-10-26 18:39:49 +00:00
|
|
|
{
|
2023-10-25 09:14:33 +00:00
|
|
|
breakpoint: '1400px',
|
|
|
|
numVisible: 2,
|
|
|
|
numScroll: 1
|
|
|
|
},
|
2023-02-28 08:29:30 +00:00
|
|
|
{
|
2023-10-26 18:39:49 +00:00
|
|
|
breakpoint: '1199px',
|
|
|
|
numVisible: 3,
|
2023-09-26 12:28:22 +00:00
|
|
|
numScroll: 1
|
2023-02-28 08:29:30 +00:00
|
|
|
},
|
|
|
|
{
|
2023-10-26 18:39:49 +00:00
|
|
|
breakpoint: '767px',
|
2023-02-28 08:29:30 +00:00
|
|
|
numVisible: 2,
|
2023-09-26 12:28:22 +00:00
|
|
|
numScroll: 1
|
2023-02-28 08:29:30 +00:00
|
|
|
},
|
|
|
|
{
|
2023-10-26 18:39:49 +00:00
|
|
|
breakpoint: '575px',
|
2023-02-28 08:29:30 +00:00
|
|
|
numVisible: 1,
|
|
|
|
numScroll: 1
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
ProductService.getProductsSmall().then((data) => (this.products = data.slice(0, 9)));
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
getSeverity(status) {
|
|
|
|
switch (status) {
|
|
|
|
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">
|
|
|
|
<Carousel :value="products" :numVisible="3" :numScroll="3" :responsiveOptions="responsiveOptions">
|
|
|
|
<template #item="slotProps">
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="border border-surface-200 dark:border-surface-700 rounded m-2 p-4">
|
|
|
|
<div class="mb-4">
|
2024-01-24 09:08:37 +00:00
|
|
|
<div class="relative mx-auto">
|
2024-05-20 12:14:38 +00:00
|
|
|
<img :src="'https://primefaces.org/cdn/primevue/images/product/' + slotProps.data.image" :alt="slotProps.data.name" class="w-full rounded" />
|
2024-01-24 09:08:37 +00:00
|
|
|
<Tag :value="slotProps.data.inventoryStatus" :severity="getSeverity(slotProps.data.inventoryStatus)" class="absolute" style="left:5px; top: 5px"/>
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="mb-4 font-medium">{{ slotProps.data.name }}</div>
|
|
|
|
<div class="flex justify-between items-center">
|
2024-01-24 09:08:37 +00:00
|
|
|
<div class="mt-0 font-semibold text-xl">\${{ slotProps.data.price }}</div>
|
|
|
|
<span>
|
|
|
|
<Button icon="pi pi-heart" severity="secondary" outlined />
|
|
|
|
<Button icon="pi pi-shopping-cart" class="ml-2"/>
|
|
|
|
</span>
|
|
|
|
</div>
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</Carousel>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import { ref, onMounted } from "vue";
|
|
|
|
import { ProductService } from '@/service/ProductService';
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
ProductService.getProductsSmall().then((data) => (products.value = data.slice(0, 9)));
|
|
|
|
})
|
|
|
|
|
|
|
|
const products = ref();
|
|
|
|
const responsiveOptions = ref([
|
|
|
|
{
|
2023-10-25 09:14:33 +00:00
|
|
|
breakpoint: '1400px',
|
|
|
|
numVisible: 2,
|
|
|
|
numScroll: 1
|
|
|
|
},
|
|
|
|
{
|
2023-10-26 18:39:49 +00:00
|
|
|
breakpoint: '1199px',
|
|
|
|
numVisible: 3,
|
2023-09-26 12:28:22 +00:00
|
|
|
numScroll: 1
|
2023-02-28 08:29:30 +00:00
|
|
|
},
|
|
|
|
{
|
2023-10-26 18:39:49 +00:00
|
|
|
breakpoint: '767px',
|
2023-02-28 08:29:30 +00:00
|
|
|
numVisible: 2,
|
2023-09-26 12:28:22 +00:00
|
|
|
numScroll: 1
|
2023-02-28 08:29:30 +00:00
|
|
|
},
|
|
|
|
{
|
2023-10-26 18:39:49 +00:00
|
|
|
breakpoint: '575px',
|
2023-02-28 08:29:30 +00:00
|
|
|
numVisible: 1,
|
|
|
|
numScroll: 1
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
|
|
|
|
const getSeverity = (status) => {
|
|
|
|
switch (status) {
|
|
|
|
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: `
|
2024-04-16 07:35:56 +00:00
|
|
|
/* 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, 9)));
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
getSeverity(status) {
|
|
|
|
switch (status) {
|
|
|
|
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>
|