Guest User

code multicolumn

a guest
Oct 5th, 2021
8,088
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 10.11 KB | None | 0 0
  1. {{ 'section-multicolumn.css' | asset_url | stylesheet_tag }}
  2. <link rel="stylesheet" href="{{ 'component-slider.css' | asset_url }}" media="print" onload="this.media='all'">
  3. <noscript>{{ 'component-slider.css' | asset_url | stylesheet_tag }}</noscript>
  4.  
  5. <div class="multicolumn background-{{ section.settings.background_style }}{% if section.settings.title == blank %} no-heading{% endif %}">
  6.   <div class="page-width">
  7.     <div class="title-wrapper-with-link title-wrapper--self-padded-mobile{% if section.settings.title == blank %} title-wrapper-with-link--no-heading{% endif %}">
  8.       <h2 class="title">
  9.         {{ section.settings.title | escape }}
  10.       </h2>
  11.       {%- if section.settings.button_label != blank and section.settings.swipe_on_mobile -%}
  12.         <a href="{{ section.settings.button_link }}" class="link underlined-link large-up-hide">{{ section.settings.button_label | escape }}</a>
  13.       {%- endif -%}
  14.     </div>
  15.     <slider-component class="slider-mobile-gutter">
  16.       <ul class="multicolumn-list grid grid--1-col{% if section.blocks.size > 3 and section.settings.image_width != 'full' %} grid--2-col-tablet grid--4-col-desktop{% elsif section.blocks.size > 3 and section.settings.image_width == 'full' %} grid--2-col-tablet{% else %} grid--3-col-tablet{% endif %}{% if section.settings.swipe_on_mobile and section.blocks.size > 1 %} slider slider--mobile grid--peek{% endif %}"
  17.         id="Slider-{{ section.id }}"
  18.         role="list"
  19.       >
  20.         {%- liquid
  21.           assign highest_ratio = 0
  22.           for block in section.blocks
  23.             if block.settings.image.aspect_ratio > highest_ratio
  24.               assign highest_ratio = block.settings.image.aspect_ratio
  25.             endif
  26.           endfor
  27.         -%}
  28.         {%- for block in section.blocks -%}
  29.           <li class="multicolumn-list__item grid__item{% if section.settings.swipe_on_mobile %} slider__slide{% endif %}{% if section.settings.column_alignment == 'center' %} center{% endif %}" {{ block.shopify_attributes }}>
  30.             <div class="multicolumn-card">
  31.               <a href="{{ block.settings.button_link }}">
  32.               {%- if block.settings.image != blank -%}
  33.                 {% if section.settings.image_ratio == 'adapt' or section.settings.image_ratio == 'circle' %}
  34.                   {% assign spaced_image = true %}
  35.                 {% endif %}
  36.                 <div class="multicolumn-card__image-wrapper multicolumn-card__image-wrapper--{{ section.settings.image_width }}-width{% if section.settings.image_width != 'full' or spaced_image %} multicolumn-card-spacing{% endif %}">
  37.                   <div class="media media--transparent media--{{ section.settings.image_ratio }}"
  38.                    {% if section.settings.image_ratio == 'adapt' %}
  39.                      style="padding-bottom: {{ 1 | divided_by: highest_ratio | times: 100 }}%;"
  40.                    {% endif %}>
  41.                     <img
  42.                      srcset="{%- if block.settings.image.width >= 275 -%}{{ block.settings.image | img_url: '275x' }} 275w,{%- endif -%}
  43.                         {%- if block.settings.image.width >= 550 -%}{{ block.settings.image | img_url: '550x' }} 550w,{%- endif -%}
  44.                         {%- if block.settings.image.width >= 710 -%}{{ block.settings.image | img_url: '710x' }} 710w,{%- endif -%}
  45.                         {%- if block.settings.image.width >= 1420 -%}{{ block.settings.image | img_url: '1420x' }} 1420w,{%- endif -%}"
  46.                       src="{{ block.settings.image | img_url: '550x' }}"
  47.                       sizes="(min-width: 990px) {% if section.blocks.size <= 2 %}710px{% else %}550px{% endif %},
  48.                        (min-width: 750px) {% if section.blocks.size == 1 %}710px{% else %}550px{% endif %},
  49.                        calc(100vw - 30px)"
  50.                      alt="{{ block.settings.image.alt }}"
  51.                      height="{{ block.settings.image.height }}"
  52.                      width="{{ block.settings.image.width }}"
  53.                      loading="lazy"
  54.                    >
  55.                   </div>
  56.                 </div>
  57.               {%- endif -%}
  58.               <div class="multicolumn-card__info">
  59.                 {%- if block.settings.title != blank -%}
  60.                   <h3>{{ block.settings.title | escape }}</h3>
  61.                 {%- endif -%}
  62.                 {%- if block.settings.text != blank -%}
  63.                   <div class="rte">{{ block.settings.text }}</div>
  64.                 {%- endif -%}
  65.               </div>
  66.               </a>
  67.             </div>
  68.           </li>
  69.         {%- endfor -%}
  70.       </ul>
  71.  
  72.       {%- if section.settings.swipe_on_mobile -%}
  73.         <div class="slider-buttons no-js-hidden medium-hide{% if section.blocks.size < 2 %} small-hide{% endif %}">
  74.           <button type="button" class="slider-button slider-button--prev" name="previous" aria-label="{{ 'accessibility.previous_slide' | t }}">{% render 'icon-caret' %}</button>
  75.           <div class="slider-counter caption">
  76.             <span class="slider-counter--current">1</span>
  77.             <span aria-hidden="true"> / </span>
  78.             <span class="visually-hidden">{{ 'accessibility.of' | t }}</span>
  79.             <span class="slider-counter--total">{{ section.blocks.size }}</span>
  80.           </div>
  81.           <button type="button" class="slider-button slider-button--next" name="next" aria-label="{{ 'accessibility.next_slide' | t }}">{% render 'icon-caret' %}</button>
  82.         </div>
  83.       {%- endif -%}
  84.     </slider-component>
  85.     <div class="center{% if section.settings.swipe_on_mobile %} small-hide medium-hide{% endif %}">
  86.       {%- if section.settings.button_label != blank -%}
  87.         <a class="button button--primary"{% if section.settings.button_link == blank %} aria-disabled="true" role="link"{% else %} href="{{ section.settings.button_link }}"{% endif %}>
  88.           {{ section.settings.button_label | escape }}
  89.         </a>
  90.       {%- endif-%}
  91.     </div>
  92.   </div>
  93. </div>
  94. <style>
  95.   .multicolumn-card a{
  96.     text-decoration: none;
  97.     color: rgb(var(--color-foreground));
  98.   }
  99. </style>
  100. {% schema %}
  101. {
  102.   "name": "t:sections.multicolumn.name",
  103.   "class": "spaced-section spaced-section--full-width",
  104.   "tag": "section",
  105.   "settings": [
  106.     {
  107.       "type": "text",
  108.       "id": "title",
  109.       "default": "Multicolumn",
  110.       "label": "t:sections.multicolumn.settings.title.label"
  111.     },
  112.     {
  113.       "type": "select",
  114.       "id": "image_width",
  115.       "options": [
  116.         {
  117.           "value": "third",
  118.           "label": "t:sections.multicolumn.settings.image_width.options__1.label"
  119.         },
  120.         {
  121.           "value": "half",
  122.           "label": "t:sections.multicolumn.settings.image_width.options__2.label"
  123.         },
  124.         {
  125.           "value": "full",
  126.           "label": "t:sections.multicolumn.settings.image_width.options__3.label"
  127.         }
  128.       ],
  129.       "default": "full",
  130.       "label": "t:sections.multicolumn.settings.image_width.label"
  131.     },
  132.     {
  133.       "type": "select",
  134.       "id": "image_ratio",
  135.       "options": [
  136.         {
  137.           "value": "adapt",
  138.           "label": "t:sections.multicolumn.settings.image_ratio.options__1.label"
  139.         },
  140.         {
  141.           "value": "portrait",
  142.           "label": "t:sections.multicolumn.settings.image_ratio.options__2.label"
  143.         },
  144.         {
  145.           "value": "square",
  146.           "label": "t:sections.multicolumn.settings.image_ratio.options__3.label"
  147.         },
  148.         {
  149.           "value": "circle",
  150.           "label": "t:sections.multicolumn.settings.image_ratio.options__4.label"
  151.         }
  152.       ],
  153.       "default": "adapt",
  154.       "label": "t:sections.multicolumn.settings.image_ratio.label"
  155.     },
  156.     {
  157.       "type": "select",
  158.       "id": "column_alignment",
  159.       "options": [
  160.         {
  161.           "value": "left",
  162.           "label": "t:sections.multicolumn.settings.column_alignment.options__1.label"
  163.         },
  164.         {
  165.           "value": "center",
  166.           "label": "t:sections.multicolumn.settings.column_alignment.options__2.label"
  167.         }
  168.       ],
  169.       "default": "left",
  170.       "label": "t:sections.multicolumn.settings.column_alignment.label"
  171.     },
  172.     {
  173.       "type": "select",
  174.       "id": "background_style",
  175.       "options": [
  176.         {
  177.           "value": "none",
  178.           "label": "t:sections.multicolumn.settings.background_style.options__1.label"
  179.         },
  180.         {
  181.           "value": "primary",
  182.           "label": "t:sections.multicolumn.settings.background_style.options__2.label"
  183.         },
  184.         {
  185.           "value": "secondary",
  186.           "label": "t:sections.multicolumn.settings.background_style.options__3.label"
  187.         }
  188.       ],
  189.       "default": "primary",
  190.       "label": "t:sections.multicolumn.settings.background_style.label"
  191.     },
  192.     {
  193.       "type": "checkbox",
  194.       "id": "swipe_on_mobile",
  195.       "default": false,
  196.       "label": "t:sections.multicolumn.settings.swipe_on_mobile.label"
  197.     }
  198.   ],
  199.   "blocks": [
  200.     {
  201.       "type": "column",
  202.       "name": "t:sections.multicolumn.blocks.column.name",
  203.       "settings": [
  204.         {
  205.           "type": "image_picker",
  206.           "id": "image",
  207.           "label": "t:sections.multicolumn.blocks.column.settings.image.label"
  208.         },
  209.         {
  210.           "type": "text",
  211.           "id": "title",
  212.           "default": "Column",
  213.           "label": "t:sections.multicolumn.blocks.column.settings.title.label"
  214.         },
  215.         {
  216.           "type": "url",
  217.           "id": "button_link",
  218.           "label": "t:sections.multicolumn.settings.button_link.label"
  219.         },
  220.         {
  221.           "type": "richtext",
  222.           "id": "text",
  223.           "default": "<p>Pair text with an image to focus on your chosen product, collection, or blog post. Add details on availability, style, or even provide a review.</p>",
  224.           "label": "t:sections.multicolumn.blocks.column.settings.text.label"
  225.         }
  226.       ]
  227.     }
  228.   ],
  229.   "presets": [
  230.     {
  231.       "name": "t:sections.multicolumn.presets.name",
  232.       "blocks": [
  233.         {
  234.           "type": "column"
  235.         },
  236.         {
  237.           "type": "column"
  238.         },
  239.         {
  240.           "type": "column"
  241.         }
  242.       ]
  243.     }
  244.   ]
  245. }
  246. {% endschema %}
  247.  
Advertisement
Add Comment
Please, Sign In to add comment