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">
|
|
|
|
<div class="border-1 surface-border border-round m-2 text-center py-5 px-3">
|
|
|
|
<div class="mb-3">
|
|
|
|
<img :src="'https://primefaces.org/cdn/primevue/images/product/' + slotProps.data.image" :alt="slotProps.data.name" class="w-6 shadow-2" />
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<h4 class="mb-1">{{ slotProps.data.name }}</h4>
|
|
|
|
<h6 class="mt-0 mb-3">${{ slotProps.data.price }}</h6>
|
|
|
|
<Tag :value="slotProps.data.inventoryStatus" :severity="getSeverity(slotProps.data.inventoryStatus)" />
|
|
|
|
<div class="mt-5">
|
2023-03-03 12:15:20 +00:00
|
|
|
<Button icon="pi pi-search" rounded class="mr-2" />
|
|
|
|
<Button icon="pi pi-star-fill" rounded severity="success" class="mr-2" />
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</Carousel>
|
|
|
|
</div>
|
|
|
|
<DocSectionCode :code="code" :service="['ProductService']" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { ProductService } from '@/service/ProductService';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
products: null,
|
|
|
|
responsiveOptions: [
|
|
|
|
{
|
|
|
|
breakpoint: '1199px',
|
2023-09-26 12:28:22 +00:00
|
|
|
numVisible: 1,
|
|
|
|
numScroll: 1
|
2023-02-28 08:29:30 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
breakpoint: '991px',
|
|
|
|
numVisible: 2,
|
2023-09-26 12:28:22 +00:00
|
|
|
numScroll: 1
|
2023-02-28 08:29:30 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
breakpoint: '767px',
|
|
|
|
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">
|
|
|
|
<div class="border-1 surface-border border-round m-2 text-center py-5 px-3">
|
|
|
|
<div class="mb-3">
|
|
|
|
<img :src="'https://primefaces.org/cdn/primevue/images/product/' + slotProps.data.image" :alt="slotProps.data.name" class="w-6 shadow-2" />
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<h4 class="mb-1">{{ slotProps.data.name }}</h4>
|
|
|
|
<h6 class="mt-0 mb-3">\${{ slotProps.data.price }}</h6>
|
|
|
|
<Tag :value="slotProps.data.inventoryStatus" :severity="getSeverity(slotProps.data.inventoryStatus)" />
|
|
|
|
<div class="mt-5">
|
2023-03-03 12:15:20 +00:00
|
|
|
<Button icon="pi pi-search" rounded class="mr-2" />
|
|
|
|
<Button icon="pi pi-star-fill" rounded severity="success" class="mr-2"
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</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">
|
|
|
|
<div class="border-1 surface-border border-round m-2 text-center py-5 px-3">
|
|
|
|
<div class="mb-3">
|
|
|
|
<img :src="'https://primefaces.org/cdn/primevue/images/product/' + slotProps.data.image" :alt="slotProps.data.name" class="w-6 shadow-2" />
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<h4 class="mb-1">{{ slotProps.data.name }}</h4>
|
|
|
|
<h6 class="mt-0 mb-3">\${{ slotProps.data.price }}</h6>
|
|
|
|
<Tag :value="slotProps.data.inventoryStatus" :severity="getSeverity(slotProps.data.inventoryStatus)" />
|
|
|
|
<div class="mt-5">
|
2023-03-03 12:15:20 +00:00
|
|
|
<Button icon="pi pi-search" rounded class="mr-2" />
|
|
|
|
<Button icon="pi pi-star-fill" rounded severity="success" class="mr-2" />
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</Carousel>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { ProductService } from '@/service/ProductService';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
products: null,
|
|
|
|
responsiveOptions: [
|
|
|
|
{
|
|
|
|
breakpoint: '1199px',
|
2023-09-26 12:28:22 +00:00
|
|
|
numVisible: 1,
|
|
|
|
numScroll: 1
|
2023-02-28 08:29:30 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
breakpoint: '991px',
|
|
|
|
numVisible: 2,
|
2023-09-26 12:28:22 +00:00
|
|
|
numScroll: 1
|
2023-02-28 08:29:30 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
breakpoint: '767px',
|
|
|
|
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':
|
|
|
|
return 'warning';
|
|
|
|
|
|
|
|
case 'OUTOFSTOCK':
|
|
|
|
return 'danger';
|
|
|
|
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
<\/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">
|
|
|
|
<div class="border-1 surface-border border-round m-2 text-center py-5 px-3">
|
|
|
|
<div class="mb-3">
|
|
|
|
<img :src="'https://primefaces.org/cdn/primevue/images/product/' + slotProps.data.image" :alt="slotProps.data.name" class="w-6 shadow-2" />
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<h4 class="mb-1">{{ slotProps.data.name }}</h4>
|
|
|
|
<h6 class="mt-0 mb-3">\${{ slotProps.data.price }}</h6>
|
|
|
|
<Tag :value="slotProps.data.inventoryStatus" :severity="getSeverity(slotProps.data.inventoryStatus)" />
|
|
|
|
<div class="mt-5">
|
2023-03-03 12:15:20 +00:00
|
|
|
<Button icon="pi pi-search" rounded class="mr-2" />
|
|
|
|
<Button icon="pi pi-star-fill" rounded severity="success" class="mr-2" />
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</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([
|
|
|
|
{
|
|
|
|
breakpoint: '1199px',
|
2023-09-26 12:28:22 +00:00
|
|
|
numVisible: 1,
|
|
|
|
numScroll: 1
|
2023-02-28 08:29:30 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
breakpoint: '991px',
|
|
|
|
numVisible: 2,
|
2023-09-26 12:28:22 +00:00
|
|
|
numScroll: 1
|
2023-02-28 08:29:30 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
breakpoint: '767px',
|
|
|
|
numVisible: 1,
|
|
|
|
numScroll: 1
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
|
|
|
|
const getSeverity = (status) => {
|
|
|
|
switch (status) {
|
|
|
|
case 'INSTOCK':
|
|
|
|
return 'success';
|
|
|
|
|
|
|
|
case 'LOWSTOCK':
|
|
|
|
return 'warning';
|
|
|
|
|
|
|
|
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, 9)));
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
getSeverity(status) {
|
|
|
|
switch (status) {
|
|
|
|
case 'INSTOCK':
|
|
|
|
return 'success';
|
|
|
|
|
|
|
|
case 'LOWSTOCK':
|
|
|
|
return 'warning';
|
|
|
|
|
|
|
|
case 'OUTOFSTOCK':
|
|
|
|
return 'danger';
|
|
|
|
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|