Advertisement
ikai2

Slider Debut

Sep 18th, 2022
972
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {%- capture flickity_options -%}
  2. {
  3.   "prevNextButtons": true,
  4.   "pageDots": false,
  5.   "contain": true,
  6.   "cellAlign": "left",
  7.   "groupCells": true,
  8.   "arrowShape": {"x0": 20, "x1": 60, "y1": 40, "x2": 60, "y2": 35, "x3": 25}
  9. }
  10. {%- endcapture -%}
  11.  
  12. <style>
  13. .featured-collection-slider{
  14.   padding-left: 55px;
  15.   padding-right: 55px;
  16.   max-width: 1200px;
  17.   margin: 0 auto;
  18. }
  19. .featured-collection-slider .carousel-cell{
  20.   width:25%;
  21.   padding: 0 15px;
  22.   display: block;
  23. }
  24. .flickity-button:disabled{
  25.   pointer-events: all!important;
  26. }
  27. @media screen and (max-width: 920px){
  28.   .featured-collection-slider{
  29.     padding-left: 15px;
  30.     padding-right: 15px;
  31.   }
  32.   .featured-collection-slider .carousel-cell{
  33.     width:50%;
  34.   }
  35. }
  36. @media screen and (max-width: 767px){
  37.   .featured-collection-slider .carousel-cell{
  38.     width:100%;
  39.   }
  40. }
  41. </style>
  42.  
  43.  
  44. <div class="featured-collection-slider page-width">
  45. {% if section.settings.title != blank %}
  46. <div class="section-header text-center">
  47.   <h2>{{ section.settings.title | escape }}</h2>
  48. </div>
  49. {% endif %}
  50.  
  51. {%- assign collection = collections[section.settings.collection] -%}
  52. {%- assign product_limit = section.settings.product_count -%}
  53.  
  54.     <div class="products-carousel js-flickity" data-flickity='{{ flickity_options }}'>
  55.       {% for product in collection.products limit: product_limit %}
  56.         <div class="carousel-cell">
  57.           <a href="{{ product.url | within: collection }}">
  58.             <img class="img-explore" src="{{ product.featured_image | img_url: 'master'}}">
  59.             <h4>{{ product.title }}</h4>
  60.             <p>{{ product.price | money }}</p>
  61.           </a>
  62.       </div>  
  63.     {% endfor %}
  64.     </div>
  65. </div>
  66.  
  67. {% schema %}
  68. {
  69.   "name": "Collection Slider",
  70.   "settings": [
  71.     {
  72.       "type": "text",
  73.       "id": "title",
  74.       "label": "Heading",
  75.       "default": "Featured Collection"
  76.     },
  77.     {
  78.       "type": "collection",
  79.       "id": "collection",
  80.       "label": "Collection"
  81.     },
  82.     {
  83.       "type": "range",
  84.       "id": "product_count",
  85.       "min": 4,
  86.       "max": 12,
  87.       "label": "Number of products to display",
  88.       "default": 4
  89.     }
  90.   ],
  91.   "presets": [
  92.     {
  93.       "category": "Collection",
  94.       "name": "Collection Slider",
  95.       "settings": {}
  96.     }
  97.   ]
  98. }
  99. {% endschema %}
  100.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement