stack/src/components/items/category-item/category-item.twig line 1

Open in your IDE?
  1. {% set input_types = ["radio"] %}
  2. {%- set class_name = [
  3.   "i-category",
  4.   "d-flex align-items-center",
  5.   "u-cursor-pointer u-posr h-100",
  6.   props.active ? "--active" : null,
  7.   props.disabled ? "--disabled" : null,
  8.   props.as in input_types ? "--input --" ~ props.as ~ " u-posr" : null,
  9. ]|join(' ')|trim -%}
  10. {%- set attrs = [
  11.   'class="' ~ class_name ~ '"',
  12. ] -%}
  13. {%- if props.url is defined %}
  14.   {%- set attrs = attrs|merge(['href="' ~ props.url ~ '"']) -%}
  15.   {%- set attrs = attrs|merge(['title="' ~ props.title ~ '"']) -%}
  16. {%- endif -%}
  17. {%- if props.onclick is defined %}
  18.   {%- set attrs = attrs|merge(['onclick="' ~ props.onclick ~ '"']) -%}
  19. {%- endif -%}
  20. {% set tag = props.url ? "a" : "label" %}
  21. {% if props.as in input_types %}
  22.   {% if props.id %}
  23.     {%- set attrs = attrs|merge(['for="' ~ props.id ~ '"']) -%}
  24.   {% endif %}
  25. {% endif %}
  26. {%- set attrs = attrs|join(' ')|trim -%}
  27. {% set img_props = {
  28.   is_placeholder: true,
  29.   width: 56,
  30.   height: 56,
  31.   ratio: "1-1",
  32. } %}
  33. <{{tag}} {{ attrs|raw }}>
  34.   {% if props.is_family %}
  35.     <div class="i-category__image flex-shrink-0">
  36.       {% if props.img %}
  37.         {% include "@Components/img/img.twig" with {props: props.img|merge(img_props)} %}
  38.       {% else %}
  39.         {% include "@Components/img/img.twig" with {props: {
  40.           src: base_path ~ "images/content/placeholder.png",
  41.         }|merge(img_props)} %}
  42.       {% endif %}
  43.     </div>
  44.   {% endif %}
  45.   {% if props.title %}
  46.     <div class="i-category__title u-fw-600 u-fz-sm py-1 px-2">{{ props.title }}</div>
  47.   {% endif %}
  48.   {% if props.as in input_types %}
  49.     <input type="{{ props.as }}" name="{{ props.name }}" id="{{ props.id }}" value="{{ props.value }}" data-filter-title="{{ props.title }}" {{ props.checked ? "checked" : null }} {{ props.disabled ? "disabled" : null }} class="i-category__input u-posa u-left-0 u-bottom-0">
  50.   {% endif %}
  51. </{{tag}}>