Anand Doshi | da858cc | 2015-02-24 17:50:44 +0530 | [diff] [blame] | 1 | {% macro product_image_square(website_image, css_class="") %} |
Rushabh Mehta | 440650d | 2016-11-14 13:13:53 +0530 | [diff] [blame] | 2 | <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 Doshi | da858cc | 2015-02-24 17:50:44 +0530 | [diff] [blame] | 7 | </div> |
| 8 | {% endmacro %} |
| 9 | |
Shivam Mishra | a0954e6 | 2020-08-07 14:34:54 +0530 | [diff] [blame] | 10 | {% macro product_image(website_image, css_class="", alt="") %} |
prssanna | eb0e596 | 2020-12-24 11:40:33 +0530 | [diff] [blame^] | 11 | <div class="border text-center rounded h-100 {{ css_class }}" style="overflow: hidden;"> |
Shivam Mishra | a0954e6 | 2020-08-07 14:34:54 +0530 | [diff] [blame] | 12 | <img itemprop="image" class="website-image h-100 w-100" alt="{{ alt }}" src="{{ frappe.utils.quoted(website_image or 'no-image.jpg') | abs_url }}"> |
prssanna | eb0e596 | 2020-12-24 11:40:33 +0530 | [diff] [blame^] | 13 | </div> |
Rushabh Mehta | 156ce60 | 2015-09-11 18:49:59 +0530 | [diff] [blame] | 14 | {% endmacro %} |
pratu16x7 | 60fe77c | 2017-02-13 21:52:43 +0530 | [diff] [blame] | 15 | |
| 16 | {% macro media_image(website_image, name, css_class="") %} |
pratu16x7 | 0e94b4b | 2017-02-14 16:32:48 +0530 | [diff] [blame] | 17 | <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 %} |
prssanna | eb0e596 | 2020-12-24 11:40:33 +0530 | [diff] [blame^] | 21 | {% if website_image -%} |
pratu16x7 | 60fe77c | 2017-02-13 21:52:43 +0530 | [diff] [blame] | 22 | <a href="{{ frappe.utils.quoted(website_image) }}"> |
pratu16x7 | 0e94b4b | 2017-02-14 16:32:48 +0530 | [diff] [blame] | 23 | <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%;"> |
pratu16x7 | 60fe77c | 2017-02-13 21:52:43 +0530 | [diff] [blame] | 25 | </a> |
prssanna | eb0e596 | 2020-12-24 11:40:33 +0530 | [diff] [blame^] | 26 | {%- endif %} |
| 27 | </div> |
pratu16x7 | 60fe77c | 2017-02-13 21:52:43 +0530 | [diff] [blame] | 28 | {% endmacro %} |
Faris Ansari | 5f8b358 | 2019-03-19 11:48:32 +0530 | [diff] [blame] | 29 | |
| 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 %} |
| 43 | <div class="website-image-lazy" data-class="card-img-top h-100" data-src="{{ card.image }}" data-alt="{{ card.title }}"></div> |
| 44 | {% 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 Ansari | b8eaa3d | 2019-06-01 20:56:37 +0530 | [diff] [blame] | 48 | <p class="card-text">{{ card.content or '' | truncate(140, True) }}</p> |
Faris Ansari | 5f8b358 | 2019-03-19 11:48:32 +0530 | [diff] [blame] | 49 | </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 | |
prssanna | eb0e596 | 2020-12-24 11:40:33 +0530 | [diff] [blame^] | 60 | {% endmacro %} |
| 61 | |
| 62 | {%- macro item_card(title, image, url, description, rate, category, is_featured=False, is_full_width=False, align="Left") -%} |
| 63 | {%- 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 -%} |
| 69 | {% if is_featured %} |
| 70 | <div class="col-sm-{{ col_size*2 }} item-card"> |
| 71 | <div class="card featured-item {{ align_items_class }}"> |
| 72 | {% if image %} |
| 73 | <div class="row no-gutters"> |
| 74 | <div class="col-md-6"> |
| 75 | <img class="card-img" src="{{ image }}" alt="{{ title }}"> |
| 76 | </div> |
| 77 | <div class="col-md-6"> |
| 78 | {{ item_card_body(title, description, url, rate, category, is_featured, align) }} |
| 79 | </div> |
| 80 | </div> |
| 81 | {% else %} |
| 82 | <div class="col-md-12"> |
| 83 | {{ item_card_body(title, description, url, rate, category, is_featured, align) }} |
| 84 | </div> |
| 85 | {% endif %} |
| 86 | </div> |
| 87 | </div> |
| 88 | {% else %} |
| 89 | <div class="col-sm-{{ col_size }} item-card"> |
| 90 | <div class="card {{ align_items_class }}"> |
| 91 | {% if image %} |
| 92 | <img class="card-img" src="{{ image }}" alt="{{ title }}"> |
| 93 | {% endif %} |
| 94 | {{ item_card_body(title, description, url, rate, category, is_featured, align) }} |
| 95 | </div> |
| 96 | </div> |
| 97 | {% endif %} |
| 98 | {%- endmacro -%} |
| 99 | |
| 100 | {%- macro item_card_body(title, description, url, rate, category, is_featured, align) -%} |
| 101 | {%- set align_class = resolve_class({ |
| 102 | 'text-right': align == 'Right', |
| 103 | 'text-center': align == 'Center' and not is_featured, |
| 104 | 'text-left': align == 'Left' or is_featured, |
| 105 | }) -%} |
| 106 | <div class="card-body {{ align_class }}"> |
| 107 | <div class="product-title">{{ title or '' }}</div> |
| 108 | {% if is_featured %} |
| 109 | <div class="product-price">{{ rate or '' }}</div> |
| 110 | <div class="product-description ellipsis">{{ description or '' }}</div> |
| 111 | {% else %} |
| 112 | <div class="product-category">{{ category or '' }}</div> |
| 113 | <div class="product-price">{{ rate or '' }}</div> |
| 114 | {% endif %} |
| 115 | </div> |
| 116 | <a href="{{ url or '#' }}" class="stretched-link"></a> |
| 117 | {%- endmacro -%} |