{# Product Gallery Components ========================== Image gallery with thumbnails, zoom, and lightbox for product detail pages. Usage: {% from 'shared/macros/storefront/product-gallery.html' import product_gallery, gallery_thumbnails %} #} {# Product Gallery =============== Full image gallery with main image and thumbnails. Parameters: - images_var: Alpine.js expression for images array (default: 'product.images') - selected_var: Alpine.js variable for selected image index (default: 'selectedImage') - show_thumbnails: Show thumbnail navigation (default: true) - enable_zoom: Enable hover zoom on main image (default: true) - enable_lightbox: Enable fullscreen lightbox (default: true) - max_thumbnails: Max thumbnails to show (default: 5) - aspect_ratio: Main image aspect ratio (default: 'square') Expected image object: { id: 1, url: 'https://...', thumbnail_url: 'https://...', alt: 'Product image' } Usage: {{ product_gallery(images_var='product.images') }} #} {% macro product_gallery( images_var='product.images', selected_var='selectedImage', show_thumbnails=true, enable_zoom=true, enable_lightbox=true, max_thumbnails=5, aspect_ratio='square' ) %} {% set aspects = { 'square': 'aspect-square', '4:3': 'aspect-[4/3]', '3:4': 'aspect-[3/4]', '16:9': 'aspect-video', '3:2': 'aspect-[3/2]' } %} {% set aspect_class = aspects.get(aspect_ratio, 'aspect-square') %}
{# Main Image Container #}
{# Main Image #}
{# Product Image #} {# Zoom Indicator #} {% if enable_zoom %}
Hover to zoom
{% endif %} {# Lightbox Button #} {% if enable_lightbox %} {% endif %}
{# Navigation Arrows #} {# Image Counter #}
{# Thumbnails #} {% if show_thumbnails %}
{# More Images Indicator #}
{% endif %} {# Lightbox Modal #} {% if enable_lightbox %} {% endif %}
{% endmacro %} {# Gallery Thumbnails Only ======================= Standalone thumbnail strip for custom layouts. Parameters: - images_var: Alpine.js expression for images array - selected_var: Alpine.js variable for selected index - orientation: 'horizontal' | 'vertical' (default: 'horizontal') - size: 'sm' | 'md' | 'lg' (default: 'md') Usage: {{ gallery_thumbnails(images_var='product.images', orientation='vertical') }} #} {% macro gallery_thumbnails( images_var='product.images', selected_var='selectedImage', orientation='horizontal', size='md' ) %} {% set sizes = { 'sm': {'container': 'w-12 h-12', 'gap': 'gap-1'}, 'md': {'container': 'w-16 h-16', 'gap': 'gap-2'}, 'lg': {'container': 'w-20 h-20', 'gap': 'gap-3'} } %} {% set s = sizes[size] %} {% set is_vertical = orientation == 'vertical' %}
{% endmacro %} {# Simple Image Viewer =================== Single image with optional lightbox (for simple product pages). Parameters: - image_var: Alpine.js expression for image object or URL string - enable_lightbox: Enable click to enlarge (default: true) - aspect_ratio: Image aspect ratio (default: 'square') Usage: {{ simple_image_viewer(image_var='product.image_url') }} #} {% macro simple_image_viewer( image_var='product.image_url', enable_lightbox=true, aspect_ratio='square' ) %} {% set aspects = { 'square': 'aspect-square', '4:3': 'aspect-[4/3]', '3:4': 'aspect-[3/4]', '16:9': 'aspect-video' } %} {% set aspect_class = aspects.get(aspect_ratio, 'aspect-square') %}
{% if enable_lightbox %}
{% endif %}
{% if enable_lightbox %} {# Lightbox #} {% endif %}
{% endmacro %}