blob: 743daaf7e19d7c106bf71f4f51cea4730801dd51 [file] [log] [blame]
Anand Doshida858cc2015-02-24 17:50:44 +05301{% macro product_image_square(website_image, css_class="") %}
Rushabh Mehta440650d2016-11-14 13:13:53 +05302<div class="product-image product-image-square
3 {% if not website_image -%} missing-image {%- endif %} {{ css_class }}"
4 {% if website_image -%}
5 style="background-image: url('{{ frappe.utils.quoted(website_image) | abs_url }}');"
6 {%- endif %}>
Anand Doshida858cc2015-02-24 17:50:44 +05307</div>
8{% endmacro %}
9
prssanna11eae6d2021-02-01 20:01:37 +053010{% macro product_image(website_image, css_class="product-image", alt="") %}
Shivam Mishra45a56282020-12-30 15:51:50 +053011 <div class="border text-center rounded {{ css_class }}" style="overflow: hidden;">
Shivam Mishraa0954e62020-08-07 14:34:54 +053012 <img itemprop="image" class="website-image h-100 w-100" alt="{{ alt }}" src="{{ frappe.utils.quoted(website_image or 'no-image.jpg') | abs_url }}">
prssannaeb0e5962020-12-24 11:40:33 +053013 </div>
Rushabh Mehta156ce602015-09-11 18:49:59 +053014{% endmacro %}
pratu16x760fe77c2017-02-13 21:52:43 +053015
16{% macro media_image(website_image, name, css_class="") %}
pratu16x70e94b4b2017-02-14 16:32:48 +053017 <div class="product-image sidebar-image-wrapper {{ css_class }}">
18 {% if not website_image -%}
19 <div class="sidebar-standard-image"> <div class="standard-image" style="background-color: rgb(250, 251, 252);">{{name}}</div> </div>
20 {%- endif %}
prssannaeb0e5962020-12-24 11:40:33 +053021 {% if website_image -%}
pratu16x760fe77c2017-02-13 21:52:43 +053022 <a href="{{ frappe.utils.quoted(website_image) }}">
pratu16x70e94b4b2017-02-14 16:32:48 +053023 <img itemprop="image" src="{{ frappe.utils.quoted(website_image) | abs_url }}"
24 class="img-responsive img-thumbnail sidebar-image" style="min-height:100%; min-width:100%;">
pratu16x760fe77c2017-02-13 21:52:43 +053025 </a>
prssannaeb0e5962020-12-24 11:40:33 +053026 {%- endif %}
27 </div>
pratu16x760fe77c2017-02-13 21:52:43 +053028{% endmacro %}
Faris Ansari5f8b3582019-03-19 11:48:32 +053029
30{% macro render_homepage_section(section) %}
31
32{% if section.section_based_on == 'Custom HTML' and section.section_html %}
33 {{ section.section_html }}
34{% elif section.section_based_on == 'Cards' %}
35<section class="container my-5">
36 <h3>{{ section.name }}</h3>
37
38 <div class="row">
39 {% for card in section.section_cards %}
40 <div class="col-md-{{ section.column_value }} mb-4">
41 <div class="card h-100 justify-content-between">
42 {% if card.image %}
Mohamed Almubarakf7ea3402021-01-28 10:02:13 +030043 <div class="website-image-lazy" data-class="card-img-top h-75" data-src="{{ card.image }}" data-alt="{{ card.title }}"></div>
Faris Ansari5f8b3582019-03-19 11:48:32 +053044 {% endif %}
45 <div class="card-body">
46 <h5 class="card-title">{{ card.title }}</h5>
47 <p class="card-subtitle mb-2 text-muted">{{ card.subtitle or '' }}</p>
Faris Ansarib8eaa3d2019-06-01 20:56:37 +053048 <p class="card-text">{{ card.content or '' | truncate(140, True) }}</p>
Faris Ansari5f8b3582019-03-19 11:48:32 +053049 </div>
50 <div class="card-body flex-grow-0">
51 <a href="{{ card.route }}" class="card-link">{{ _('More details') }}</a>
52 </div>
53 </div>
54 </div>
55 {% endfor %}
56 </div>
57</section>
58{% endif %}
59
prssannaeb0e5962020-12-24 11:40:33 +053060{% endmacro %}
61
marination4f64d1c2021-03-11 21:24:47 +053062{%- macro item_card(item, is_featured=False, is_full_width=False, align="Left") -%}
prssannaeb0e5962020-12-24 11:40:33 +053063{%- set align_items_class = resolve_class({
64 'align-items-end': align == 'Right',
65 'align-items-center': align == 'Center',
66 'align-items-start': align == 'Left',
67}) -%}
68{%- set col_size = 3 if is_full_width else 4 -%}
marination4f64d1c2021-03-11 21:24:47 +053069{%- set title = item.item_name or item.item_code -%}
70{%- set image = item.website_image or item.image -%}
71{%- set description = item.website_description or item.description-%}
72
prssannaeb0e5962020-12-24 11:40:33 +053073{% if is_featured %}
74<div class="col-sm-{{ col_size*2 }} item-card">
75 <div class="card featured-item {{ align_items_class }}">
76 {% if image %}
77 <div class="row no-gutters">
78 <div class="col-md-6">
79 <img class="card-img" src="{{ image }}" alt="{{ title }}">
80 </div>
81 <div class="col-md-6">
marination4f64d1c2021-03-11 21:24:47 +053082 {{ item_card_body(title, description, item, is_featured, align) }}
prssannaeb0e5962020-12-24 11:40:33 +053083 </div>
84 </div>
85 {% else %}
86 <div class="col-md-12">
marination4f64d1c2021-03-11 21:24:47 +053087 {{ item_card_body(title, description, item, is_featured, align) }}
prssannaeb0e5962020-12-24 11:40:33 +053088 </div>
89 {% endif %}
90 </div>
91</div>
92{% else %}
93<div class="col-sm-{{ col_size }} item-card">
94 <div class="card {{ align_items_class }}">
95 {% if image %}
marination16b9c8c2021-03-11 10:56:00 +053096 <div class="card-img-container">
marination4f64d1c2021-03-11 21:24:47 +053097 <a href="/{{ item.route or '#' }}" style="text-decoration: none;">
marination16b9c8c2021-03-11 10:56:00 +053098 <img class="card-img" src="{{ image }}" alt="{{ title }}">
99 </a>
100 </div>
prssannab00eb1b2021-01-20 17:52:54 +0530101 {% else %}
marination4f64d1c2021-03-11 21:24:47 +0530102 <a href="/{{ item.route or '#' }}" style="text-decoration: none;">
marination16b9c8c2021-03-11 10:56:00 +0530103 <div class="card-img-top no-image">
104 {{ frappe.utils.get_abbr(title) }}
105 </div>
106 </a>
prssannaeb0e5962020-12-24 11:40:33 +0530107 {% endif %}
marination4f64d1c2021-03-11 21:24:47 +0530108 {{ item_card_body(title, description, item, is_featured, align) }}
prssannaeb0e5962020-12-24 11:40:33 +0530109 </div>
110</div>
111{% endif %}
112{%- endmacro -%}
113
marination4f64d1c2021-03-11 21:24:47 +0530114{%- macro item_card_body(title, description, item, is_featured, align) -%}
prssannaeb0e5962020-12-24 11:40:33 +0530115{%- set align_class = resolve_class({
116 'text-right': align == 'Right',
117 'text-center': align == 'Center' and not is_featured,
118 'text-left': align == 'Left' or is_featured,
119}) -%}
marination16b9c8c2021-03-11 10:56:00 +0530120<div class="card-body {{ align_class }}" style="width:100%">
121
122 <div style="margin-top: 16px; display: flex;">
marination4f64d1c2021-03-11 21:24:47 +0530123 <a href="/{{ item.route or '#' }}">
marination16b9c8c2021-03-11 10:56:00 +0530124 <div class="product-title">{{ title or '' }}</div>
125 </a>
marination4f64d1c2021-03-11 21:24:47 +0530126 {% if item.in_stock %}
127 <span class="indicator {{ item.in_stock }} card-indicator"></span>
marination16b9c8c2021-03-11 10:56:00 +0530128 {% endif %}
marination4f64d1c2021-03-11 21:24:47 +0530129 {% if not item.has_variants %}
marination4f64d1c2021-03-11 21:24:47 +0530130 <div class="like-action"
marination96cc5062021-03-14 17:28:49 +0530131 data-item-code="{{ item.item_code }}" data-price="{{ item.price }}">
marination4f64d1c2021-03-11 21:24:47 +0530132 <svg class="icon sm">
marination96cc5062021-03-14 17:28:49 +0530133 {%- set icon_class = "wished" if item.wished else "not-wished"-%}
134 <use class="{{ icon_class }} wish-icon" href="#icon-heart"></use>
marination4f64d1c2021-03-11 21:24:47 +0530135 </svg>
136 </div>
137 {% endif %}
marination16b9c8c2021-03-11 10:56:00 +0530138 </div>
prssannaeb0e5962020-12-24 11:40:33 +0530139 {% if is_featured %}
marination4f64d1c2021-03-11 21:24:47 +0530140 <div class="product-price">{{ item.formatted_price or '' }}</div>
prssannaeb0e5962020-12-24 11:40:33 +0530141 <div class="product-description ellipsis">{{ description or '' }}</div>
142 {% else %}
marination4f64d1c2021-03-11 21:24:47 +0530143 <div class="product-category">{{ item.item_group or '' }}</div>
marination16b9c8c2021-03-11 10:56:00 +0530144 <div style="display: flex;">
marination4f64d1c2021-03-11 21:24:47 +0530145 {% if item.formatted_price %}
146 <div class="product-price">{{ item.formatted_price or '' }}</div>
marination16b9c8c2021-03-11 10:56:00 +0530147 {% endif %}
marination4f64d1c2021-03-11 21:24:47 +0530148 {% if item.has_variants %}
149 <a href="/{{ item.route or '#' }}">
150 <div class="btn btn-sm btn-explore-variants">
151 {{ _('Explore') }}
152 </div>
153 </a>
154 {% else %}
155 <div id="{{ item.name }}" class="btn btn-sm btn-add-to-cart-list not-added"
156 data-item-code="{{ item.item_code }}">
157 {{ _('Add to Cart') }}
158 </div>
159 {% endif %}
marination16b9c8c2021-03-11 10:56:00 +0530160 </div>
prssannaeb0e5962020-12-24 11:40:33 +0530161 {% endif %}
162</div>
Ankush Menat4551d7d2021-08-19 13:41:10 +0530163{%- endmacro -%}