Skip to content

Commit b6b186f

Browse files
committed
Fix mobile menu
1 parent 29fb1ee commit b6b186f

24 files changed

Lines changed: 286 additions & 59 deletions

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,25 @@ bin/magento module:enable Loki_Theme
88
```
99

1010
## What this is
11-
This module removes legacy Luma JavaScript (RequireJS, Knockout.js, jQuery, jQuery UI) and replaces it with custom JavaScript where needed.
11+
This module removes legacy Luma JavaScript (RequireJS, Knockout.js, jQuery, jQuery UI) and replaces it with custom JavaScript where needed. The following variations for this rewrite exist - taking in mind that this module tries to make as little template override as possible:
12+
13+
- No JavaScript, just plain HTML and CSS;
14+
- Simple JavaScript functions;
15+
- Alpine.js components (with or without custom template);
1216

1317
Currently, the following components are built-in:
1418

1519
- Messages
1620
- Cookie notice
1721
- Top navigation
22+
- Mobile navigation
1823
- Top links (customer welcome)
1924
- Minicart
2025
- Newsletter subscribe
2126
- Add-to-cart (product page)
2227
- Add-to-cart (category page)
2328
- Tabs (product page)
29+
- Currency switcher
2430

2531
Make sure to carefully read the docs at [https://loki-extensions.com/docs/theme](https://loki-extensions.com/docs/theme)
2632

etc/frontend/di.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
<type name="Loki\Theme\Observer\AddAlpineComponents">
2626
<arguments>
2727
<argument name="componentDefinitions" xsi:type="array">
28-
<item name="product.info.details" xsi:type="string">LumaTabs</item>
2928
<item name="form.subscribe" xsi:type="string">LumaNewsletter</item>
3029
<item name="catalog.topnav" xsi:type="string">LumaMainMenu</item>
3130
<item name="minicart" xsi:type="string">LumaMiniCart</item>

view/frontend/layout/loki_theme_catalog_category_view.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:View/Layout:etc/page_configuration.xsd">
33
<body>
44
<referenceContainer name="before.body.end">
5-
<block name="loki.script.components.category.addtocart" template="Loki_Theme::script/components/category/add-to-cart.phtml"/>
6-
<block name="loki.script.components.category.layered-navigation" template="Loki_Theme::script/components/category/layered-navigation.phtml"/>
7-
<block name="loki.script.components.category.add-to-wishlist" template="Loki_Theme::script/components/category/add-to-wishlist.phtml"/>
8-
<block name="loki.script.components.category.add-to-compare" template="Loki_Theme::script/components/category/add-to-compare.phtml"/>
5+
<block name="loki.script.component.category.addtocart" template="Loki_Theme::script/component/category/add-to-cart.phtml"/>
6+
<block name="loki.script.component.category.layered-navigation" template="Loki_Theme::script/component/category/layered-navigation.phtml"/>
7+
<block name="loki.script.component.category.add-to-wishlist" template="Loki_Theme::script/component/category/add-to-wishlist.phtml"/>
8+
<block name="loki.script.component.category.add-to-compare" template="Loki_Theme::script/component/category/add-to-compare.phtml"/>
99
</referenceContainer>
1010
</body>
1111
</page>

view/frontend/layout/loki_theme_catalog_product_view.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:View/Layout:etc/page_configuration.xsd">
33
<body>
44
<referenceContainer name="before.body.end">
5-
<block name="loki.script.components.product.addtocart" template="Loki_Theme::script/components/product/addtocart.phtml"/>
6-
<block name="loki.script.components.tabs" template="Loki_Theme::script/components/tabs.phtml"/>
5+
<block name="loki.script.component.product.addtocart" template="Loki_Theme::script/component/product/addtocart.phtml"/>
6+
<block name="loki.script.component.tabs" template="Loki_Theme::script/component/tabs.phtml"/>
77
</referenceContainer>
88
</body>
99
</page>

view/frontend/layout/loki_theme_default.xml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,22 @@
33
<update handle="loki_base"/>
44

55
<body>
6+
<referenceContainer name="loki.script">
7+
<block name="loki.script.function.toggle" template="Loki_Theme::script/function/toggle.phtml"/>
8+
<block name="loki.script.function.tabs" template="Loki_Theme::script/function/tabs.phtml"/>
9+
<block name="loki.script.function.data-post" template="Loki_Theme::script/function/data-post.phtml"/>
10+
</referenceContainer>
11+
612
<referenceContainer name="loki.components">
7-
<block name="loki.script.component.main-menu" template="Loki_Theme::script/components/main-menu.phtml"/>
8-
<block name="loki.script.component.newsletter" template="Loki_Theme::script/components/newsletter.phtml"/>
9-
<block name="loki.script.component.messages" template="Loki_Theme::script/components/messages.phtml"/>
10-
<block name="loki.script.component.minicart" template="Loki_Theme::script/components/minicart.phtml"/>
11-
<block name="loki.script.component.top-links" template="Loki_Theme::script/components/top-links.phtml"/>
12-
<block ifconfig="web/cookie/cookie_restriction" name="loki.script.component.cookie-notice" template="Loki_Theme::script/components/cookie-notice.phtml"/>
13+
<block name="loki.script.component.dropdown" template="Loki_Theme::script/component/dropdown.phtml"/>
14+
<block name="loki.script.component.main-menu" template="Loki_Theme::script/component/main-menu.phtml"/>
15+
<block name="loki.script.component.mobile-menu" template="Loki_Theme::script/component/mobile-menu.phtml"/>
16+
<block name="loki.script.component.newsletter" template="Loki_Theme::script/component/newsletter.phtml"/>
17+
<block name="loki.script.component.messages" template="Loki_Theme::script/component/messages.phtml"/>
18+
<block name="loki.script.component.minicart" template="Loki_Theme::script/component/minicart.phtml"/>
19+
<block name="loki.script.component.top-links" template="Loki_Theme::script/component/top-links.phtml"/>
20+
<block name="loki.script.component.currency-switcher" template="Loki_Theme::script/component/currency-switcher.phtml"/>
21+
<block ifconfig="web/cookie/cookie_restriction" name="loki.script.component.cookie-notice" template="Loki_Theme::script/component/cookie-notice.phtml"/>
1322
</referenceContainer>
1423

1524
<referenceContainer name="minicart.addons">

view/frontend/templates/script/components/category/add-to-cart.phtml renamed to view/frontend/templates/script/component/category/add-to-cart.phtml

File renamed without changes.

view/frontend/templates/script/components/category/add-to-compare.phtml renamed to view/frontend/templates/script/component/category/add-to-compare.phtml

File renamed without changes.

view/frontend/templates/script/components/category/add-to-wishlist.phtml renamed to view/frontend/templates/script/component/category/add-to-wishlist.phtml

File renamed without changes.

view/frontend/templates/script/components/category/layered-navigation.phtml renamed to view/frontend/templates/script/component/category/layered-navigation.phtml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<?php
22
declare(strict_types=1);
33

4-
/** @version 0.0.7 */
5-
64
use Magento\Framework\View\Element\Template;
75

6+
/** @version 0.0.7 */
87
/** @var Template $block */
98
?>
109
<script>
@@ -20,8 +19,10 @@ use Magento\Framework\View\Element\Template;
2019

2120
[...(document.getElementsByClassName('filter-options-title'))].forEach(element => {
2221
element.addEventListener('click', function(event) {
23-
const content = event.target.parentNode.querySelector('[data-role="content"]');
24-
content.style.display = content.style.display === 'block' ? 'none' : 'block';
22+
LokiToggle.toggleElement(
23+
element,
24+
event.target.parentNode.querySelector('[data-role="content"]')
25+
);
2526
})
2627
});
2728
})();

view/frontend/templates/script/components/cookie-notice.phtml renamed to view/frontend/templates/script/component/cookie-notice.phtml

File renamed without changes.

0 commit comments

Comments
 (0)