Skip to content

Commit

Permalink
#5054 support for breeze theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Radik Kurmanaev committed Jan 13, 2023
1 parent dd560b6 commit 491887d
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "magenable/module-top-bar-notification",
"description": "Magento 2 extension to display simple notice at the top of the page",
"type": "magento2-module",
"version": "1.3.2",
"version": "1.3.3",
"license": "MIT",
"require": {
"php": ">=7.1.0",
Expand Down
26 changes: 26 additions & 0 deletions view/frontend/layout/breeze_default.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0"?>
<!--
/**
* Magenable
*
* @category Magenable
* @package Magenable_TopBarNotification
* @copyright Copyright (c) Magenable (https://magenable.com.au/)
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="breeze.js">
<arguments>
<argument name="bundles" xsi:type="array">
<item name="default" xsi:type="array">
<item name="items" xsi:type="array">
<item name="notification" xsi:type="string">Magenable_TopBarNotification/js/breeze/notification</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
</body>
</page>
34 changes: 34 additions & 0 deletions view/frontend/web/css/breeze/_default.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Magenable
*
* @category Magenable
* @package Magenable_TopBarNotification
* @copyright Copyright (c) Magenable (https://magenable.com.au/)
*/
.top-bar-notification {
position: relative;

&.tbn-type-text {
display: flex;
justify-content: center;
align-items: center;
text-align: center;
padding: 15px 0;
}
&.tbn-type-html {
min-height: 30px;
}
&.hidden {
display: none;
}
.tbn-close-btn {
background: url('@{baseDir}/Magenable_TopBarNotification/images/icon-close.png') no-repeat;
background-size: cover;
cursor: pointer;
width: 20px;
height: 20px;
position: absolute;
right: 5px;
top: 5px;
}
}
34 changes: 34 additions & 0 deletions view/frontend/web/js/breeze/notification.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(function () {
'use strict';

function init(config, element) {
if (!checkUrl(config.includePages, config.excludePages)) {
return false;
}
if (!$.mage.cookies.get('top_bar_notification_closed')) {
$(element).removeClass('hidden');
}
$(config.closeBtnSelector).on('click', function() {
$(element).fadeOut(300);
$.mage.cookies.set('top_bar_notification_closed', true);
});
}

function checkUrl(includePages, excludePages) {
function inArrayCheck(url) {
return url === document.location.pathname;
}
if (includePages) {
return includePages.split('\r\n').some(inArrayCheck);
}
if (excludePages) {
return !excludePages.split('\r\n').some(inArrayCheck);
}

return true;
}

$(document).on('breeze:mount:notification', (e, data) => {
init(data.settings, data.el)
})
})();

0 comments on commit 491887d

Please sign in to comment.