File size: 6,926 Bytes
09a1836
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
{#
  Shared fragments. The product card reproduces the source
  .ProductThumbnail_container contract recorded in scope/notes/02-recon-plp.md.
#}

{% macro stars(rating) %}
<span class="Rating_ratings Rating_small" aria-label="Rating: {{ '%.1f'|format(rating or 0) }} out of 5 stars">
  <span class="Rating_top" style="width: {{ ((rating or 0) / 5 * 100)|round(2) }}%"><i>★</i><i>★</i><i>★</i><i>★</i><i>★</i></span>
  <span class="Rating_bottom"><i>★</i><i>★</i><i>★</i><i>★</i><i>★</i></span>
</span>
{% endmacro %}

{% macro price_block(product) %}
<div class="ProductThumbnail_price">
  {% if product.price_low != product.price_high %}
    <span class="screenreader">Price range from: ${{ '%.2f'|format(product.price_low) }} to: ${{ '%.2f'|format(product.price_high) }}</span>
    <span class="sale">${{ '%.2f'|format(product.price_low) }}</span>-<span>${{ '%.2f'|format(product.price_high) }}</span>
  {% else %}
    <span class="screenreader">Price: ${{ '%.2f'|format(product.price_low) }}</span>
    <span>${{ '%.2f'|format(product.price_low) }}</span>
  {% endif %}
</div>
{% endmacro %}

{% macro product_card(product) %}
<li class="ProductThumbnail_container">
  <div class="ProductThumbnail_wrapper">
    <div class="ProductThumbnail_product">
      <a href="/llb/shop/{{ product.product_id }}{% if product.slug %}?page={{ product.slug }}{% endif %}">
        <img src="{{ product.grid_image }}" width="302" height="352" loading="lazy"
             alt="{{ product.grid_image_alt }}">
      </a>
    </div>
  </div>
  {% if product.colors %}
  <div class="ColorSwatches_wrapper">
    <div class="ColorSwatches_swatch-list">
      <fieldset>
        <legend class="screenreader">Colors</legend>
        <ul class="ColorSwatches_list-container">
          {% for color in product.colors[:6] %}
          <li title="{{ color.name }}">
            <a href="/llb/shop/{{ product.product_id }}?color={{ color.name|urlencode }}"
               aria-label="{{ color.name }}, color {{ loop.index }} of {{ product.colors|length }}">
              {% if color.swatch %}<img src="{{ color.swatch }}" width="18" height="18" alt="{{ color.name }}">
              {% else %}<span class="ColorSwatches_dot" data-color="{{ color.bucket or 'Other' }}"></span>{% endif %}
            </a>
          </li>
          {% endfor %}
        </ul>
      </fieldset>
    </div>
  </div>
  {% endif %}
  <a class="ProductThumbnail_name Anchor_not-underlined Anchor_anchor"
     href="/llb/shop/{{ product.product_id }}{% if product.slug %}?page={{ product.slug }}{% endif %}">{{ product.name }}</a>
  {{ price_block(product) }}
  {% if product.color_count %}
  <div class="ProductThumbnail_color-count">{{ product.color_count }} colors available</div>
  {% endif %}
  {{ stars(product.rating) }}
  <a class="Rating_count Anchor_anchor" href="/llb/shop/{{ product.product_id }}#reviews">{{ product.review_count }}</a>
</li>
{% endmacro %}

{% macro product_grid(items) %}
<ul class="ProductThumbnailList_list">
  {% for product in items %}{{ product_card(product) }}{% endfor %}
</ul>
{% endmacro %}

{#
  The panel renders only the facets the source shows for this collection, in the
  source's order. Every facet here filters against real local data, so no control
  is inert.
#}
{% macro checkbox_group(title, name, options, selected) %}
{% if options %}
<div class="Filter_group">
  <h3>{{ title }}</h3>
  {% for opt in options %}
  <label class="Filter_option">
    <input type="checkbox" name="{{ name }}" value="{{ opt.name }}" {% if opt.name in selected %}checked{% endif %}>
    {% if name == 'color' %}<span class="ColorSwatches_dot" data-color="{{ opt.name }}"></span>{% endif %}
    {{ opt.name }} ({{ opt.count }})
  </label>
  {% endfor %}
</div>
{% endif %}
{% endmacro %}

{% macro facet_panel(facets, selected, sort_options, action, hidden) %}
<form class="FilterNavigation_panel" method="get" action="{{ action }}">
  {% for key, value in (hidden or {}).items() %}<input type="hidden" name="{{ key }}" value="{{ value }}">{% endfor %}
  <h2 class="Filters_heading">Filter By:</h2>

  <div class="Filter_group">
    <h3>Sort</h3>
    <select name="sort_field" class="SortOptions_select" aria-label="Sort">
      {% for key, label in sort_options.items() %}
      <option value="{{ key }}" {% if selected.sort_field == key %}selected{% endif %}>{{ label }}</option>
      {% endfor %}
    </select>
  </div>

  {% for key in facets.order %}
    {% if key == 'percent_off' %}
      {{ checkbox_group('% Off', 'percent_off', facets.percent_off, selected.percent_off) }}
    {% elif key == 'sale' and facets.sale %}
      <div class="Filter_group">
        <h3>Sale</h3>
        <label class="Filter_option">
          <input type="checkbox" name="sale" value="1" {% if selected.sale %}checked{% endif %}>
          Sale ({{ facets.sale.count }})
        </label>
      </div>
    {% elif key == 'new' and facets.new %}
      <div class="Filter_group">
        <h3>New Arrivals</h3>
        <label class="Filter_option">
          <input type="checkbox" name="new" value="1" {% if selected.new %}checked{% endif %}>
          New Arrivals ({{ facets.new.count }})
        </label>
      </div>
    {% elif key == 'gender' %}
      {{ checkbox_group('Gender', 'gender', facets.gender, selected.gender) }}
    {% elif key == 'size' %}
      {{ checkbox_group('Size', 'size', facets.size, selected.size) }}
    {% elif key == 'material' %}
      {{ checkbox_group('Material', 'material', facets.material, selected.material) }}
    {% elif key == 'color' %}
      {{ checkbox_group('Color', 'color', facets.color, selected.color) }}
    {% elif key == 'price' %}
      {{ checkbox_group('Price', 'price', facets.price, selected.price) }}
    {% elif key == 'brand' %}
      {{ checkbox_group('Brand', 'brand', facets.brand, selected.brand) }}
    {% endif %}
  {% endfor %}

  <div class="Filter_actions">
    <button class="Button_buttonComponent Button_primary" type="submit">Apply Filters</button>
    <a class="Filter_clear" href="{{ action }}">Clear All</a>
  </div>
</form>
{% endmacro %}

{% macro load_more(batch, action, params) %}
{% if batch.has_more %}
<form class="ProductThumbnailList_more" method="get" action="{{ action }}">
  {% for key, value in params.items() %}
    {% if value is iterable and value is not string %}
      {% for entry in value %}<input type="hidden" name="{{ key }}" value="{{ entry }}">{% endfor %}
    {% else %}<input type="hidden" name="{{ key }}" value="{{ value }}">{% endif %}
  {% endfor %}
  <input type="hidden" name="start" value="{{ batch.next_start }}">
  <input type="hidden" name="viewCount" value="{{ batch.view_count }}">
  <input type="hidden" name="isLoadMore" value="true">
  <button class="Button_buttonComponent Button_primary Button_large" type="submit">LOAD {{ [batch.view_count, batch.remaining]|min }} MORE</button>
</form>
{% endif %}
{% endmacro %}