Skip to content

Commit

Permalink
https://github.com/cabinetsbay/core/issues/6
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed May 7, 2024
1 parent e1645d5 commit 05bc054
Show file tree
Hide file tree
Showing 11 changed files with 307 additions and 0 deletions.
20 changes: 20 additions & 0 deletions view/frontend/templates/category/item.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
# 2024-03-25
# "Refactor `app/design/frontend/Cabinetsbay/cabinetsbay_default/Magento_Catalog/templates/category/header.phtml`":
# https://github.com/cabinetsbay/site/issues/105
use Magento\Catalog\Model\Category as C;
/** @var C $c */
?>
<a href='<?= $c->getUrl() ?>'>
<div><?= $c->getName() ?></div>
<?php if ($set = $c['cb_kitchen_set']) { ?>
<div class='size-price'>
<b><?= $set ?></b><?= $c['cb_kitchen_price'] ?>
</div>
<?php } ?>
<img border='0' src='<?= $c->getImageUrl() ?>'/>
</a>
<div>
<a href='<?= $c->getUrl() ?>'>Shop cabinets</a>
<a href='<?= $c['cb_door_sample_link'] ?>'>Order sample</a>
</div>
21 changes: 21 additions & 0 deletions view/frontend/templates/category/l2/bottom.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
# 2024-03-15
# "Refactor `app/design/frontend/Cabinetsbay/cabinetsbay_default/Magento_Catalog/templates/category/view.phtml`":
# https://github.com/cabinetsbay/site/issues/112
use Sharapov\Cabinetsbay\Block\Category\View as B;
/** @var B $b */
$id = $b->isRTA() ? 'rta' : 'pa'; /** @var string $id */
?>
<div class='product-page-faq' id='faq-purchase'>
<?= df_cms_block("product-page-faq-{$id}-welcome") ?>
</div>
<div class='product-page-faq'>
<?= df_cms_block("product-page-faq-{$id}-body") ?>
</div>
<div class='product-page-how-to-shop mobile-view' id='how-to-shop'>
<?= df_cms_block("product-page-{$id}-how-to-shop") ?>
<a href='#products_list' class='scrollTo'>Click here to start shopping</a>
</div>
<div class="product-page-info mobile-view">
<?= df_cms_block("product-page-{$id}-info") ?>
</div>
10 changes: 10 additions & 0 deletions view/frontend/templates/category/l2/l3.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
# 2024-03-14
# "Refactor `app/design/frontend/Cabinetsbay/cabinetsbay_default/Magento_Catalog/templates/category/view.phtml`":
# https://github.com/cabinetsbay/site/issues/112
use Magento\Catalog\Model\ResourceModel\Category\Collection as CC;
use Sharapov\Cabinetsbay\Block\Category\View as B;
/** @var B $b */
$cc = df_category_children($b->getCurrentCategory())->setOrder('position', 'ASC'); /** @var CC $cc */
echo df_block_output('CabinetsBay_Core', 'catalog/category/l2/l3/filters', ['cc' => $cc]);
echo df_block_output('CabinetsBay_Core', 'catalog/category/l2/l3/items', ['cc' => $cc]);
63 changes: 63 additions & 0 deletions view/frontend/templates/category/l2/l3/filters.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
# 2024-03-14
# "Refactor `app/design/frontend/Cabinetsbay/cabinetsbay_default/Magento_Catalog/templates/category/view.phtml`":
# https://github.com/cabinetsbay/site/issues/112
use Magento\Catalog\Model\Category as C;
use Magento\Catalog\Model\ResourceModel\Category\Collection as CC;
/** @var CC $cc */
$options = function(string $k) use($cc):string {
$all = ['<li data-style="all">All</li>'];
return df_cc_n(array_merge($all, df_map(
# 2024-03-24
# "Some values are duplicated in filter dropdowns on the «Ready to Assemble Cabinets» page":
# https://github.com/cabinetsbay/site/issues/115
array_unique(df_map($cc, function(C $c) use($k):string {return $c["cb_kitchen_{$k}"];}))
,function(string $s):string {return df_tag('li', ['data-style' => $s], $s);}
)));
};
?>
<div class="category-filterblock short-first">
<div>
<label>Filter</label>
</div>
<div>
<div id="dropdown-price" class="category-filter-dropdown" data-mage-init='{"dropdown":{}}'>
<span class="action toggle" data-toggle="dropdown" aria-haspopup="true">
<span>Price</span>
</span>
<ul class="dropdown">
<li data-sortby="asc">Low-High</li>
<li data-sortby="desc">High-Low</li>
</ul>
</div>
</div>
<div>
<div id="dropdown-color" class="category-filter-dropdown" data-mage-init='{"dropdown":{}}'>
<span class="action toggle" data-toggle="dropdown" aria-haspopup="true">
<span>Color</span>
</span>
<ul class="dropdown">
<li data-sortby="lighter">Lighter</li>
<li data-sortby="darker">Darker</li>
</ul>
</div>
</div>
<div>
<div id="dropdown-style" class="category-filter-dropdown" data-mage-init='{"dropdown":{}}'>
<span class="action toggle" data-toggle="dropdown" aria-haspopup="true">
<span>Style (All)</span>
</span>
<ul class="dropdown">
<?= $options('style') ?>
</ul>
</div>
</div>
<div>
<div id="dropdown-construction" class="category-filter-dropdown" data-mage-init='{"dropdown":{}}'>
<span class="action toggle" data-toggle="dropdown" aria-haspopup="true">
<span>Cabinet Construction (All)</span>
</span>
<ul class="dropdown"><?= $options('type'); ?></ul>
</div>
</div>
</div>
24 changes: 24 additions & 0 deletions view/frontend/templates/category/l2/l3/items.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
# 2024-03-14
# "Refactor `app/design/frontend/Cabinetsbay/cabinetsbay_default/Magento_Catalog/templates/category/view.phtml`":
# https://github.com/cabinetsbay/site/issues/112
use Magento\Catalog\Model\Category as C;
use Magento\Catalog\Model\ResourceModel\Category\Collection as CC;
/** @var CC $cc */
if (count($cc)) { ?>
<div class='c-products-grid'>
<ul id='products_list'>
<?php foreach ($cc as $c) {/** @var C $c */ ?>
<li
data-sortercolor='<?= $c['cb_kitchen_color'] ?>'
data-sorterconstruction='<?= $c['cb_kitchen_type'] ?>'
data-sorterprice='<?= preg_replace('/[^0-9.]+/', '', $c['cb_kitchen_price']) ?>'
data-sorterstyle='<?= $c['cb_kitchen_style'] ?>'
>
<?= df_block_output('CabinetsBay_Core', 'catalog/category/item', ['c' => $c]) ?>
</li>
<?php } ?>
</ul>
</div>
<?php
}
19 changes: 19 additions & 0 deletions view/frontend/templates/category/l2/top.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
# 2024-03-14
# "Refactor `app/design/frontend/Cabinetsbay/cabinetsbay_default/Magento_Catalog/templates/category/view.phtml`":
# https://github.com/cabinetsbay/site/issues/112
use Sharapov\Cabinetsbay\Block\Category\View as B;
/** @var B $b */
[$id, $title] = $b->isRTA() ? ['rta', 'RTA'] : ['pa', 'Pre-Assembled']; /** @var string $id */ /** @var string $title */
?>
<!-- 2024-04-14
"Titles are incorrectly displayed on the `/pre-assembled-cabinets.html` and `/ready-to-assemble-cabinets.html` pages":
https://github.com/cabinetsbay/site/issues/135 -->
<div class='cb-faq'>Frequently Asked Questions about <?= $title ?> Cabinets
<a href="#faq-purchase" class="scrollTo">Learn More...</a>
</div>
<div class='product-page-info'><?= df_cms_block("product-page-{$id}-info") ?></div>
<div class='product-page-how-to-shop'>
<?= df_cms_block("product-page-{$id}-how-to-shop") ?>
<a class='scrollTo' href='#how-to-shop'>Learn More...</a>
</div>
51 changes: 51 additions & 0 deletions view/frontend/templates/category/tabs.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
# 2024-03-25
# "Refactor `app/design/frontend/Cabinetsbay/cabinetsbay_default/Magento_Catalog/templates/category/header.phtml`":
# https://github.com/cabinetsbay/site/issues/105
use Sharapov\Cabinetsbay\Block\Category\View as B;
$tabs = [
# 2024-04-14
# "Delete the useless «Product Overview» title from the frontend category pages":
# https://github.com/cabinetsbay/site/issues/133
'overview'=> ['content' => 'block']
,'specifications' => ['content' => 'cb_specs', 'title' => 'Specifications']
,'cabinet-assembly' => ['content' => 'cb_assembly', 'title' => 'Cabinet Assembly']
,'matching-styles' => ['content' => 'block', 'title' => 'Matching Styles']
]; /** @var string => array(string => string) $tabs */
/** @var B $b */
# 2024-03-25 These tabs are visible on wide screens only.
echo df_tag('ul', 'category-menu', df_map_k(function(string $k, array $v):string {return df_tag('li',
['data-role' => 'title']
, df_tag('a', [
# 2024-03-25
# "The contents of the tabs «Product Overview», «Specifications», «Cabinet Assembly», «Matching Styles»
# should be always visible": https://github.com/cabinetsbay/site/issues/120
'class' => 'scrollTo'
,'href' => "#$k"
], $v['title'])
# 2024-04-14
# "Delete the useless «Product Overview» tab from the frontend category pages": https://github.com/cabinetsbay/site/issues/132
);}, df_tail($tabs)));
foreach ($tabs as $k => $v) {/** @var string $k */ /** @var array(string => string) $v */ ?>
<!-- 2024-03-25
1) "The contents of the tabs «Product Overview», «Specifications», «Cabinet Assembly», «Matching Styles»
should be always visible": https://github.com/cabinetsbay/site/issues/120
2) I added the `active` class. -->
<div id='<?= $k ?>' class='active category-tab' data-role='content'>
<!-- 2024-03-25
1) "The contents of the tabs «Product Overview», «Specifications», «Cabinet Assembly», «Matching Styles»
should be always visible": https://github.com/cabinetsbay/site/issues/120
2) I removed the code:
<span class='submenu-toggle' data-role='trigger' tabindex='0'></span>
https://github.com/cabinetsbay/core/blob/0.1.4/view/frontend/templates/catalog/category/tabs.phtml#L30
2024-04-14 "Delete the useless «Product Overview» title from the frontend category pages":
https://github.com/cabinetsbay/site/issues/133 -->
<?= df_tag_if_ne(dfa($v, 'title', ''), 'label') ?>
<div class='content'>
<?= 'block' === ($c = $v['content'])
? df_block_output('CabinetsBay_Core', "catalog/category/tabs/$k", ['b' => $b])
: $b->l3a($c)
?>
</div>
</div>
<?php } ?>
7 changes: 7 additions & 0 deletions view/frontend/templates/category/tabs/cabinet-assembly.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
# 2024-03-25
# "Refactor `app/design/frontend/Cabinetsbay/cabinetsbay_default/Magento_Catalog/templates/category/header.phtml`":
# https://github.com/cabinetsbay/site/issues/105
use Magento\Catalog\Model\Category as C;
use Sharapov\Cabinetsbay\Block\Category\View as B;
/** @var B $b */
20 changes: 20 additions & 0 deletions view/frontend/templates/category/tabs/matching-styles.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
# 2024-03-25
# "Refactor `app/design/frontend/Cabinetsbay/cabinetsbay_default/Magento_Catalog/templates/category/header.phtml`":
# https://github.com/cabinetsbay/site/issues/105
use Magento\Catalog\Model\Category as C;
use Sharapov\Cabinetsbay\Block\Category\View as B;
/** @var B $b */
echo $b->l3a('cb_styles');
if (count($cc = $b->l3p())) { /** @var C[] $cc */ ?>
<div class='c-products-grid'>
<ul>
<?php foreach ($cc as $c) {/** @var C $c */ ?>
<li>
<?= df_block_output('CabinetsBay_Core', 'catalog/category/item', ['c' => $c]) ?>
</li>
<?php } ?>
</ul>
</div>
<?php
}
65 changes: 65 additions & 0 deletions view/frontend/templates/category/tabs/overview.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
# 2024-03-25
# "Refactor `app/design/frontend/Cabinetsbay/cabinetsbay_default/Magento_Catalog/templates/category/header.phtml`":
# https://github.com/cabinetsbay/site/issues/105
use Magento\Catalog\Model\Category as C;
use Sharapov\Cabinetsbay\Block\Category\View as B;
/** @var B $b */
df_assert($l3 = $b->l3()); /** @var C $l3 */
?>
<div class='category-info'>
<div class='category-tab-left'>
<?php if ($ii = $b->images()) { ?>
<ul id='category-gallery' class='gallery list-unstyled cS-hidden'>
<?=
df_cc_n(df_map_k($ii, function(string $f, string $t):string {return
df_tag('li', [
'data-src' => $u = df_media_path2url("wysiwyg/catalog-carousel-images/$f")
,'data-thumb' => $u
], df_tag('img', ['alt' => $t,'src' => $u, 'title' => $t]))
;}))
?>
</ul>
<script>
require(['jquery', 'domReady!'], function($) {
let totalWidth = 0;
$('.owl-thumb-item').each(function() {
totalWidth += parseInt($(this).width(), 10);
});
$('.owl-thumbs').css('width', (totalWidth + 20)+'px');
});
</script>
<?php }
else {
try {
if ($url = $l3->getImageUrl()) {
echo df_catalog_output()->categoryAttribute(
$l3
,df_tag('div', 'category-image', df_tag('img', [
'alt' => $l3->getName()
,'class' => 'image'
,'src' => $url
,'title' => $l3->getName()
]))
,'image'
);
}
} catch (\Magento\Framework\Exception\LocalizedException $e) {}
}
?>
</div>
<div class="category-tab-right">
<?php if ($_description = $l3->getDescription()): ?>
<div class="category-description">
<?= df_catalog_output()->categoryAttribute($l3, $_description, 'description') ?>
</div>
<?php endif; ?>
<div class="category-subdescription">
<div class="table-view">
<a href="/sample-doors.html">Order Sample</a>
<a href="/kitchen-design-assistance.html">Free Design</a>
</div>
<a class="scrollTo" href="#layer-product-list">Shop Cabinets Below <i></i></a>
</div>
</div>
</div>
7 changes: 7 additions & 0 deletions view/frontend/templates/category/tabs/specifications.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
# 2024-03-25
# "Refactor `app/design/frontend/Cabinetsbay/cabinetsbay_default/Magento_Catalog/templates/category/header.phtml`":
# https://github.com/cabinetsbay/site/issues/105
use Magento\Catalog\Model\Category as C;
use Sharapov\Cabinetsbay\Block\Category\View as B;
/** @var B $b */

0 comments on commit 05bc054

Please sign in to comment.