init
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @var \Esun\Homepage\Block\Resin $block
|
||||
* @var \Magento\Framework\Escaper $escaper
|
||||
*/
|
||||
|
||||
$products = $block->getProducts();
|
||||
if (!$products) {
|
||||
return;
|
||||
}
|
||||
|
||||
$backgroundImageUrl = $block->getBackgroundImageUrl();
|
||||
$exploreAllUrl = $block->getExploreAllUrl();
|
||||
?>
|
||||
<section class="esun-resin" aria-labelledby="esun-resin-title">
|
||||
<div class="esun-resin__heading">
|
||||
<h2 class="typo-section-title" id="esun-resin-title"><?= $escaper->escapeHtml(__('3D Resin')) ?></h2>
|
||||
<a class="esun-resin__explore"
|
||||
href="<?= $exploreAllUrl ? $escaper->escapeUrl($exploreAllUrl) : '#' ?>"
|
||||
<?= $exploreAllUrl ? '' : 'role="link" aria-disabled="true" onclick="return false;"' ?>>
|
||||
<?= $escaper->escapeHtml(__('Explore All')) ?>
|
||||
<span aria-hidden="true">></span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="esun-resin__banner"
|
||||
<?php if ($backgroundImageUrl): ?>
|
||||
style="background-image: url('<?= $escaper->escapeUrl($backgroundImageUrl) ?>');"
|
||||
<?php endif; ?>>
|
||||
<ol class="esun-resin__products">
|
||||
<?php foreach ($products as $product): ?>
|
||||
<?php
|
||||
$colorSwatches = $block->getColorSwatches($product);
|
||||
$visibleSwatches = array_slice($colorSwatches, 0, 3);
|
||||
$remainingSwatches = max(0, count($colorSwatches) - count($visibleSwatches));
|
||||
$shortDescription = $block->getShortDescription($product);
|
||||
?>
|
||||
<li class="esun-resin__item">
|
||||
<article class="esun-resin__card" data-role="esun-product-card">
|
||||
<a class="esun-resin__image"
|
||||
href="<?= $escaper->escapeUrl($product->getProductUrl()) ?>"
|
||||
data-role="esun-product-image"
|
||||
aria-label="<?= $escaper->escapeHtmlAttr($product->getName()) ?>">
|
||||
<?= /* @noEscape */ $block->getImage($product, 'category_page_grid')->toHtml() ?>
|
||||
</a>
|
||||
|
||||
<div class="esun-resin__details">
|
||||
<h3>
|
||||
<a href="<?= $escaper->escapeUrl($product->getProductUrl()) ?>">
|
||||
<?= $escaper->escapeHtml($product->getName()) ?>
|
||||
</a>
|
||||
</h3>
|
||||
|
||||
<?php if ($shortDescription): ?>
|
||||
<p class="esun-resin__description">
|
||||
<?= $escaper->escapeHtml($shortDescription) ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="esun-resin__price">
|
||||
<span class="esun-resin__final-price">
|
||||
<?= $escaper->escapeHtml($block->getFormattedFinalPrice($product)) ?>
|
||||
</span>
|
||||
<?php if ($block->hasRegularPrice($product)): ?>
|
||||
<span class="esun-resin__regular-price">
|
||||
<?= $escaper->escapeHtml($block->getFormattedRegularPrice($product)) ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="esun-resin__footer">
|
||||
<?php if ($colorSwatches): ?>
|
||||
<div class="esun-resin__swatches"
|
||||
data-role="esun-product-swatches"
|
||||
aria-label="<?= $escaper->escapeHtmlAttr(__('Available Colors')) ?>">
|
||||
<?php foreach ($visibleSwatches as $swatch): ?>
|
||||
<span class="esun-resin__swatch"
|
||||
data-child-image="<?= $escaper->escapeUrl($swatch['product_image']) ?>"
|
||||
title="<?= $escaper->escapeHtmlAttr($swatch['label']) ?>"
|
||||
aria-label="<?= $escaper->escapeHtmlAttr($swatch['label']) ?>">
|
||||
<?php if ($swatch['image']): ?>
|
||||
<img src="<?= $escaper->escapeUrl($swatch['image']) ?>"
|
||||
alt="<?= $escaper->escapeHtmlAttr($swatch['label']) ?>">
|
||||
<?php elseif ($swatch['value']): ?>
|
||||
<span style="background-color: <?= $escaper->escapeHtmlAttr($swatch['value']) ?>"></span>
|
||||
<?php else: ?>
|
||||
<span></span>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($remainingSwatches > 0): ?>
|
||||
<span class="esun-resin__swatch-more">
|
||||
+<?= (int) $remainingSwatches ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<a class="esun-resin__cart"
|
||||
href="<?= $escaper->escapeUrl($product->getProductUrl()) ?>"
|
||||
title="<?= $escaper->escapeHtmlAttr(__('View Product')) ?>">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path d="M3 4h2l2.2 10.2a2 2 0 0 0 2 1.6h7.7a2 2 0 0 0 2-1.6L20 8H7M10 20a1 1 0 1 1-2 0 1 1 0 0 1 2 0Zm8 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z" />
|
||||
</svg>
|
||||
<span class="esun-resin__visually-hidden">
|
||||
<?= $escaper->escapeHtml(__('View Product')) ?>
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script type="text/x-magento-init">
|
||||
{
|
||||
".esun-resin": {
|
||||
"Esun_Homepage/js/product-swatch-image": {}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user