Skip to content

Commit

Permalink
Merge pull request #315 from damonsson/2.0
Browse files Browse the repository at this point in the history
performance optimizations, split templates, lazyload some images
  • Loading branch information
damonsson authored Nov 29, 2024
2 parents 6be3fc2 + 90d3be6 commit deac68d
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 4 deletions.
5 changes: 2 additions & 3 deletions config/packages/sylius_twig_hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ sylius_twig_hooks:
component: 'sylius_shop:product:list'
props:
limit: 4
template: '@SyliusShop/product/common/list.html.twig'
template: '@SyliusShop/homepage/list_deals.html.twig'
configuration:
title: 'sylius.homepage.latest_deals'
test_attribute: 'latest-deals'
Expand All @@ -67,6 +67,5 @@ sylius_twig_hooks:
component: 'sylius_shop:product:list'
props:
limit: 8
template: '@SyliusShop/homepage/latest_products.html.twig'
template: '@SyliusShop/homepage/list_products.html.twig'
priority: 0

Binary file modified public/favicon.ico
Binary file not shown.
8 changes: 8 additions & 0 deletions templates/bundles/SyliusShopBundle/homepage/banner.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="mb-6">
<div class="overflow-hidden">
<div class="d-flex justify-content-center align-items-center position-relative">
<img src="{{ asset('build/shop/images/homepage-banner.webp', 'shop') }}" width="1920" height="793" class="img-fluid" alt="Home">
<img src="{{ asset('build/shop/images/homepage-banner-logo.webp', 'shop') }}" class="position-absolute" style="max-width: 40vw" alt="New collection">
</div>
</div>
</div>
31 changes: 31 additions & 0 deletions templates/bundles/SyliusShopBundle/homepage/card_deals.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<div {{ sylius_test_html_attribute('product', '%s'|format(product.code)) }} >
<a class="link-reset" href="{{ path('sylius_shop_product_show', {'slug': product.slug, '_locale': product.translation.locale}) }}" {{ sylius_test_html_attribute('product-content') }}>
<div class="mb-4">
<div class="overflow-auto bg-light rounded-3" style="aspect-ratio: 3/4; ">
{% if key == 1 %}
{{ component('sylius_shop:main_image', {
product: product,
class: "w-100 h-100 object-fit-cover",
filter: 'sylius_shop_product_small_thumbnail'
}) }}
{% else %}
{{ component('sylius_shop:main_image', {
product: product,
class: "w-100 h-100 object-fit-cover",
loading: 'lazy',
filter: 'sylius_shop_product_small_thumbnail'
}) }}
{% endif %}
</div>
</div>
<div class="h6 text-break" {{ sylius_test_html_attribute('product-name', product.name) }}>
{{ product.name }}
</div>
</a>
<div>
{% if not product.enabledVariants.empty() %}
{{ component('sylius_shop:catalog_promotions', { variant: variant, appliedPromotions: applied_promotions, withDescription: false }) }}
{{ component('sylius_shop:product:card:price', { variant: variant, template: '@SyliusShop/product/common/price.html.twig' }) }}
{% endif %}
</div>
</div>
11 changes: 11 additions & 0 deletions templates/bundles/SyliusShopBundle/homepage/list_deals.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="container mb-6">
<h2 class="mb-5">{{ hookable_metadata.configuration.title|default('sylius.ui.latest_products')|trans }}</h2>

<div {{ sylius_test_html_attribute(hookable_metadata.configuration.test_attribute|default('latest-products')) }}>
<div class="products-grid">
{% for key,product in latest_products %}
<div>{{ component('sylius_shop:product:card', { key: loop.index, product: product, template: '@SyliusShop/homepage/card_deals.html.twig' }) }}</div>
{% endfor %}
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div {{ sylius_test_html_attribute(hookable_metadata.configuration.test_attribute|default('latest-products')) }}>
<div class="products-grid">
{% for product in latest_products %}
<div>{{ component('sylius_shop:product:card', { product: product, template: '@SyliusShop/homepage/product_card.html.twig' }) }}</div>
<div>{{ component('sylius_shop:product:card', { key: loop.index, product: product, template: '@SyliusShop/homepage/card_products.html.twig' }) }}</div>
{% endfor %}
</div>
</div>
Expand Down

0 comments on commit deac68d

Please sign in to comment.