<div x-data="initCarouselcarousel15679898()" x-init="init()" class="relative w-full h-full mx-auto">
<div class="flex justify-between items-center mb-8 ">
<h2 class="text-3xl font-semibold ">Nos services</h2>
<div class="flex items-center justify-center space-x-4 ">
<div class=" hidden sm:flex flex space-x-2">
<button type="button" class="carousel-button-prev-carousel-15679898 before:border-none btn btn-dark-subtle btn-only-icon">
<svg class=" shrink-0" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.46967 12.5303C9.17678 12.2374 9.17678 11.7626 9.46967 11.4697L13.4697 7.46967C13.7626 7.17678 14.2374 7.17678 14.5303 7.46967C14.8232 7.76256 14.8232 8.23744 14.5303 8.53033L11.0607 12L14.5303 15.4697C14.8232 15.7626 14.8232 16.2374 14.5303 16.5303C14.2374 16.8232 13.7626 16.8232 13.4697 16.5303L9.46967 12.5303Z" fill="currentColor" />
</svg>
</button>
<button type="button" class="carousel-button-next-carousel-15679898 before:border-none btn btn-dark-subtle btn-only-icon">
<svg class=" shrink-0" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M14.5303 11.4697C14.8232 11.7626 14.8232 12.2374 14.5303 12.5303L10.5303 16.5303C10.2374 16.8232 9.76256 16.8232 9.46967 16.5303C9.17678 16.2374 9.17678 15.7626 9.46967 15.4697L12.9393 12L9.46967 8.53033C9.17678 8.23744 9.17678 7.76256 9.46967 7.46967C9.76256 7.17678 10.2374 7.17678 10.5303 7.46967L14.5303 11.4697Z" fill="currentColor" />
</svg>
</button>
</div>
</div>
</div>
<div x-ref="swiperContainer" id="carousel-15679898" class="swiper md:h-full">
<div class="swiper-wrapper ">
<div class="swiper-slide !transform-none " data-theme="light" data-hash="index-carousel-15679898-0">
<div class="overflow-hidden">
<img src="/img/store/productSlider.png" alt="Tiers Payant Mutuelle" class="w-full object-cover aspect-square rounded-lg" />
<div class="p-6 text-neutral-800">
<h2 class="text-xl font-semibold mb-3">Tiers Payant Mutuelle</h2>
<p class="text-sm">Les magasins ALAIN AFFLELOU sont partenaires de très nombreuses mutuelles. Sur chaque fiche magasin et opticien proche de chez vous ou de votre choix</p>
</div>
</div>
</div>
<div class="swiper-slide !transform-none " data-theme="light" data-hash="index-carousel-15679898-1">
<div class="overflow-hidden">
<img src="/img/store/productSlider2.png" alt="Entretien et ajustement gratuits" class="w-full object-cover aspect-square rounded-lg" />
<div class="p-6 text-neutral-800">
<h2 class="text-xl font-semibold mb-3">Entretien et ajustement gratuits</h2>
<p class="text-sm">Pour que votre vision soit toujours parfaite, nos opticiens vous proposent un entretien et un ajustage gratuit de vos lunettes à vie.</p>
</div>
</div>
</div>
<div class="swiper-slide !transform-none " data-theme="light" data-hash="index-carousel-15679898-2">
<div class="overflow-hidden">
<img src="/img/store/productSlider3.png" alt="Remise de devis gratuit" class="w-full object-cover aspect-square rounded-lg" />
<div class="p-6 text-neutral-800">
<h2 class="text-xl font-semibold mb-3">Remise de devis gratuit</h2>
<p class="text-sm">Avant de finaliser chaque vente, notre opticien a la possibilité de vous fournir un devis optique.</p>
</div>
</div>
</div>
<div class="swiper-slide !transform-none " data-theme="light" data-hash="index-carousel-15679898-3">
<div class="overflow-hidden">
<img src="/img/productsSlider/products13.png" alt="Entretien et ajustement gratuits" class="w-full object-cover aspect-square rounded-lg" />
<div class="p-6 text-neutral-800">
<h2 class="text-xl font-semibold mb-3">Entretien et ajustement gratuits</h2>
<p class="text-sm">Pour que votre vision soit toujours parfaite, nos opticiens vous proposent un entretien et un ajustage gratuit de vos lunettes à vie.</p>
</div>
</div>
</div>
</div>
<div class="flex sm:hidden mt-6">
<a href="https://www.afflelou.com/" target="_blank" rel="noopenner noreferer" class="mx-auto btn btn-dark-subtle ">
Voir toute la collection
</a>
</div>
</div>
</div>
<script>
function initCarouselcarousel15679898() {
return {
swiper: null,
options: {
"color": "dark",
"slidesPerView": {
"mobile": 1.2,
"tablet": 2,
"desktop": 2
},
"spaceBetween": 30,
"showPagination": false,
"showNavigation": true,
"showNavigationMobile": false
},
componentId: 'carousel-15679898',
init() {
this.initSwiper();
if (typeof this.customFunction === 'function') {
this.customFunction();
}
},
initSwiper() {
this.swiper = new Swiper(this.$refs.swiperContainer, {
slidesPerView: this.options.slidesPerView.mobile,
spaceBetween: this.options.spaceBetween,
pagination: this.options.showPagination ? {
el: '.swiper-pagination-' + this.componentId,
clickable: true,
bulletClass: 'bullet',
bulletActiveClass: 'active',
} : false,
navigation: this.options.showNavigation ? {
nextEl: '.carousel-button-next-' + this.componentId,
prevEl: '.carousel-button-prev-' + this.componentId
} : false,
hashNavigation: {
watchState: true,
},
breakpoints: {
640: {
slidesPerView: this.options.slidesPerView.tablet
},
1024: {
slidesPerView: this.options.slidesPerView.desktop
}
},
on: {
slideChange: () => this.updateSliderTheme(),
},
});
this.updateSliderTheme();
},
updateSliderTheme() {
const activeSlide = this.swiper.slides[this.swiper.activeIndex];
const theme = activeSlide.getAttribute('data-slider-theme');
this.sliderTheme = theme || 'light';
},
customFunction() {
// Custom function can be defined here and overridden outside.
}
};
}
</script>
{# components/carousel/carousel.twig #}
{% set uniqueId = "carousel-" ~ random() %}
{% set carouselFunctionName = "initCarousel" ~ uniqueId|replace({'-': ''}) %}
<div
x-data="{{ carouselFunctionName }}()"
x-init="init()"
class="relative w-full h-full mx-auto"
>
{# Header Section #}
<div class="flex justify-between items-center mb-8 {% if variant is defined and variant == 'small' %} absolute top-6 md:top-10 left-6 md:left-10 right-6 md:right-10 z-10 {% endif %}">
{% if title is defined and title %}
<h2 class="text-3xl font-semibold {{ titleClass }}">{{ title }}</h2>
{% endif %}
<div class="flex items-center justify-center space-x-4 {% if variant is defined and variant == 'small' %} justify-between w-full {% endif %}">
{% if variant is defined and variant == 'small' %}
{% if carousel.showPagination %}
<div x-ref="pagination"
class="swiper-pagination-{{ uniqueId }} swiper-pagination mt-0 !w-auto {{ paginationClass }}" {{ swiper_pagination_attribute }}></div>
{% endif %}
{% else %}
{% if showCTA %}
{% render "@template-button" with {
href: CTA.href,
external: CTA.external,
color: CTA.color ~ "-subtle",
label: CTA.label,
button_class:"hidden sm:inline-flex mx-auto",
button_attribute: cta_button_attribute,
} %}
{% endif %}
{% endif %}
{% if carousel.showNavigation %}
<div class="{% if carousel.showNavigationMobile == false %} hidden sm:flex {% endif %} flex space-x-2">
{% render "@template-button" with {
color: carousel.color ~ "-subtle",
type: "only-icon",
icon: {
name: "library--chevron-left"
},
button_class:"carousel-button-prev-" ~ uniqueId ~ " before:border-none",
button_attribute: swiper_navigation_attribute
} %}
{% render "@template-button" with {
color: carousel.color ~ "-subtle",
type: "only-icon",
icon: {
name: "library--chevron-right"
},
button_class:"carousel-button-next-" ~ uniqueId ~ " before:border-none",
button_attribute: swiper_navigation_attribute
} %}
</div>
{% endif %}
</div>
</div>
<div x-ref="swiperContainer" id="{{ uniqueId }}" class="swiper md:h-full">
<div class="swiper-wrapper {{ wrapperClass }}">
{% for index, slide in slides %}
<div
class="swiper-slide !transform-none {{ slideClass }}"
data-theme="{{ slide.theme|default('light') }}"
data-hash="index-{{ uniqueId }}-{{ index }}"
>
{% if slide.template %}
{% render "@" ~ slide.template with {
slide: slide
} %}
{% else %}
{{ slide.content|raw }}
{% endif %}
</div>
{% endfor %}
</div>
{% if variant is defined and variant != 'small' and carousel.showPagination %}
<div x-ref="pagination"
class="swiper-pagination-{{ uniqueId }} swiper-pagination {{ paginationClass }}" {{ swiper_pagination_attribute }}></div>
{% endif %}
{% if CTA %}
<div class="flex sm:hidden mt-6">
{% render "@template-button" with {
href: CTA.href,
external: CTA.external,
color: CTA.color ~ "-subtle",
label: CTA.label,
button_class:"mx-auto",
button_attribute: cta_button_attribute
} %}
</div>
{% endif %}
</div>
</div>
<script>
function {{ carouselFunctionName }}() {
return {
swiper: null,
options: {{ carousel|json_encode|raw }},
componentId: '{{ uniqueId }}',
init() {
this.initSwiper();
if (typeof this.customFunction === 'function') {
this.customFunction();
}
},
initSwiper() {
this.swiper = new Swiper(this.$refs.swiperContainer, {
slidesPerView: this.options.slidesPerView.mobile,
spaceBetween: this.options.spaceBetween,
pagination: this.options.showPagination ? {
el: '.swiper-pagination-' + this.componentId,
clickable: true,
bulletClass: 'bullet',
bulletActiveClass: 'active',
} : false,
navigation: this.options.showNavigation ? {
nextEl: '.carousel-button-next-' + this.componentId,
prevEl: '.carousel-button-prev-' + this.componentId
} : false,
hashNavigation: {
watchState: true,
},
breakpoints: {
640: {
slidesPerView: this.options.slidesPerView.tablet
},
1024: {
slidesPerView: this.options.slidesPerView.desktop
}
},
on: {
slideChange: () => this.updateSliderTheme(),
},
});
this.updateSliderTheme();
},
updateSliderTheme() {
const activeSlide = this.swiper.slides[this.swiper.activeIndex];
const theme = activeSlide.getAttribute('data-slider-theme');
this.sliderTheme = theme || 'light';
},
customFunction() {
// Custom function can be defined here and overridden outside.
{% if customFunction is defined and customFunction %}
{{ customFunction }}
{% endif %}
}
};
}
</script>
{
"title": "Nos services",
"variant": "default",
"showCTA": false,
"CTA": {
"label": "Voir toute la collection",
"href": "https://www.afflelou.com/",
"external": true,
"color": "dark"
},
"paginationClass": "swiper-light",
"carousel": {
"color": "dark",
"slidesPerView": {
"mobile": 1.2,
"tablet": 2,
"desktop": 2
},
"spaceBetween": 30,
"showPagination": false,
"showNavigation": true,
"showNavigationMobile": false
},
"slides": [
{
"template": "storeproductcard",
"image": "/img/store/productSlider.png",
"title": "Tiers Payant Mutuelle",
"description": "Les magasins ALAIN AFFLELOU sont partenaires de très nombreuses mutuelles. Sur chaque fiche magasin et opticien proche de chez vous ou de votre choix"
},
{
"template": "storeproductcard",
"image": "/img/store/productSlider2.png",
"title": "Entretien et ajustement gratuits",
"description": "Pour que votre vision soit toujours parfaite, nos opticiens vous proposent un entretien et un ajustage gratuit de vos lunettes à vie."
},
{
"template": "storeproductcard",
"image": "/img/store/productSlider3.png",
"title": "Remise de devis gratuit",
"description": "Avant de finaliser chaque vente, notre opticien a la possibilité de vous fournir un devis optique."
},
{
"template": "storeproductcard",
"image": "/img/productsSlider/products13.png",
"title": "Entretien et ajustement gratuits",
"description": "Pour que votre vision soit toujours parfaite, nos opticiens vous proposent un entretien et un ajustage gratuit de vos lunettes à vie."
}
]
}
A reusable component for displaying product cards, compatible with both carousels and grids.
The component can be configured via the productCard.config.js
file. Here are the available options:
Object containing product information:
url
: Product page URLopenInNewTab
: Boolean to open link in new tabimage
: Path to main product imagehoverImage
: Path to image displayed on hovername
: Product namebrand
: Product branddescription
: Product descriptioncolors
: Text indicating available colorsprice
: Product priceoldPrice
: Original price (for promotions)discountText
: Promotion textwebLabel
: Web price labelinlinePrice
: Boolean to display price inline with titlebuttonColor
: Action buttons colorbuttonColorHover
: Action buttons hover colorAction buttons configuration:
showActionButtons
: Boolean to show/hide action buttonsshowFavoriteButton
: Boolean to show/hide favorite buttonshowQuickViewButton
: Boolean to show/hide quick view buttonAlpine.js attributes configuration for reactivity:
alpineAttribute: {
productInfo: {
brand: 'x-text="product.brand"',
name: 'x-text="product.name"',
description: 'x-text="product.description"',
colors: 'x-text="product.colors"',
price: 'x-text="product.price"',
webLabel: 'x-text="product.webLabel"'
}
}
default
: Standard display with image, title, and pricewith-hover
: Variant with image hover effectwith-discount
: Variant with original price and promotion textinline-price
: Variant with price inline with title{# Basic usage #}
{% include '@components/product/productCard.twig' with {
product: {
url: '/product/1',
image: '/path/to/image.jpg',
name: 'Product name',
price: '199.00'
}
} %}
{# Usage with all options #}
{% include '@components/product/productCard.twig' with {
product: {
url: '/product/1',
openInNewTab: false,
image: '/path/to/image.jpg',
hoverImage: '/path/to/hover-image.jpg',
name: 'Product name',
brand: 'Brand',
description: 'Product description',
colors: '3 colors available',
price: '199.00',
oldPrice: '249.00',
discountText: '-20%',
webLabel: 'WEB PRICE',
inlinePrice: true,
buttonColor: 'light',
buttonColorHover: 'dark',
showActionButtons: true,
showFavoriteButton: true,
showQuickViewButton: true,
addCart: true,
alpineAttribute: {
productInfo: {
brand: 'x-text="product.brand"'
// ... other Alpine.js attributes
}
}
},
class: 'custom-class'
} %}
hoverImage
is definedinlinePrice
template-button
component for actionsThe component uses Tailwind CSS classes for styling:
The component integrates with the template-button component for: