Advertisement
ikai2

Slider Dawn

Sep 18th, 2022 (edited)
949
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {% comment %}
  2.   * Make sure you have the Flickity plugin installed and the proper license for this to function on your store
  3.   * Plugin, licensing and documentation at https://flickity.metafizzy.co/
  4. {% endcomment %}
  5.  
  6. {% assign cell_align = section.settings.cell_align %}
  7. {% assign wrap_around = section.settings.wrap_around %}
  8. {% assign img_width = section.settings.img_width | append: 'x' %}
  9.  
  10. <div class="flickity-section-{{ section.id }} flickity-index-slider product" style="background-color: {{ section.settings.bg }}">
  11.   <div class="page-width">
  12.     <div>
  13.       <p class="text-title text-center" style="margin-bottom:{{ section.settings.title_mb }}px">{{ section.settings.title }}</p>
  14.     </div>
  15.     <div class="flickity-section__carousel carousel-{{section.id }} text-center"
  16.         data-flickity='{
  17.          "cellAlign": "{{ cell_align }}",
  18.          "pageDots": false,
  19.          "freeScroll": true,
  20.          "contain": true,
  21.          "wrapAround": {{ wrap_around }}
  22.        }'>
  23.       {% for block in section.blocks %}
  24.         {% assign block_product = all_products[block.settings.featured_product] %}
  25.         {% assign block_first_variant = block_product.selected_or_first_available_variant %}
  26.         {% assign featured_img_src = block_first_variant.featured_img.src | default: block_product.featured_image.src %}
  27.         {% assign price = block_first_variant.price %}
  28.         {% assign compare_at_price = block_first_variant.compare_at_price %}
  29.         <div class="carousel__cell" style="width:{{ section.settings.cell_width }};margin-right:{{ section.settings.mr }}px">
  30.           {% if block.settings.featured_product != blank %}
  31.             <a href="{{ block_product.url }}">
  32.               <img src="{{ featured_img_src | img_url: img_width }}" alt="{{ block_product.featured_img.alt }}" />
  33.             </a>
  34.           {% else %}
  35.             {{ 'product-1' | placeholder_svg_tag: 'placeholder-svg' }}
  36.           {% endif %}
  37.           <a href="{{ block_product.url }}">
  38.             <h5>{{ block_product.title }}</h5>
  39.           </a>
  40.           {% if compare_at_price > price %}
  41.             <s class="block-product__compare-at-price">{{ compare_at_price | money }}</s>
  42.             <p class="block-product__product-price">{{ price | money }}</p>
  43.           {% else %}
  44.             <p class="block-product__product-price">{{ price | money }}</p>
  45.           {% endif %}
  46.         </div>
  47.       {% endfor %}
  48.     </div>
  49.   </div>
  50. </div>
  51.  
  52. {% schema %}
  53.   {
  54.     "name": "Flickity Product Section",
  55.     "settings": [
  56.       {
  57.         "type": "color",
  58.         "id": "bg",
  59.         "label": "Background Color"
  60.       },
  61.       {
  62.         "type": "text",
  63.         "id": "title",
  64.         "label": "Title",
  65.         "default": "Flickity Product Slider"
  66.       },
  67.       {
  68.         "type": "range",
  69.         "id": "img_width",
  70.         "min": 200,
  71.         "max": 600,
  72.         "step": 5,
  73.         "unit": "px",
  74.         "label": "Image Width",
  75.         "default": 200
  76.       },
  77.       {
  78.         "type": "select",
  79.         "id": "cell_align",
  80.         "label": "Slide Alignment",
  81.         "options": [
  82.           {
  83.             "value": "center",
  84.             "label": "Center"
  85.           },
  86.           {
  87.             "value": "left",
  88.             "label": "Left"
  89.           }
  90.         ],
  91.         "default": "center"
  92.       },
  93.       {
  94.         "type": "range",
  95.         "id": "title_mb",
  96.         "min": 30,
  97.         "max": 120,
  98.         "step": 1,
  99.         "unit": "px",
  100.         "label": "Title Margin Bottom",
  101.         "default": 48
  102.       },
  103.       {
  104.         "type": "select",
  105.         "id": "cell_width",
  106.         "label": "Choose number of slides to show on start",
  107.         "options": [
  108.           {
  109.             "value": "25%",
  110.             "label": "Four"
  111.           },
  112.           {
  113.             "value": "20%",
  114.             "label": "Five"
  115.           },
  116.           {
  117.             "value": "16.6666667%",
  118.             "label": "Six"
  119.           },
  120.           {
  121.             "value": "12.5%",
  122.             "label": "Eight"
  123.           }
  124.         ],
  125.         "default": "25%"
  126.       },
  127.       {
  128.         "type": "radio",
  129.         "id": "wrap_around",
  130.         "label": "Enable Wrap Around (endless scrolling)",
  131.         "options": [
  132.           {
  133.             "value": "true",
  134.             "label": "True"
  135.           },
  136.           {
  137.             "value": "false",
  138.             "label": "False"
  139.           }
  140.         ],
  141.         "default": "true"
  142.       },
  143.       {
  144.         "type": "range",
  145.         "id": "mr",
  146.         "min": 0,
  147.         "max": 48,
  148.         "step": 1,
  149.         "unit": "px",
  150.         "label": "Cell Margin Right",
  151.         "default": 16,
  152.         "info": "Save page to see changes."
  153.       }
  154.     ],
  155.     "blocks": [
  156.       {
  157.         "type": "slide",
  158.         "name": "slide",
  159.         "settings": [
  160.           {
  161.             "type": "product",
  162.             "id": "featured_product",
  163.             "label": "Choose a product"
  164.           }
  165.         ]
  166.       }
  167.     ],
  168.     "presets": [
  169.       {
  170.         "name": "Flickity Section",
  171.         "category": "Slider",
  172.         "blocks": [
  173.           {
  174.             "type": "slide"
  175.           },
  176.           {
  177.             "type": "slide"
  178.           },
  179.           {
  180.             "type": "slide"
  181.           },
  182.           {
  183.             "type": "slide"
  184.           }
  185.         ]
  186.       }
  187.     ]
  188.   }
  189. {% endschema %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement