Created
August 22, 2018 08:27
-
-
Save shakyShane/addad2da7bd46c65a5ff2cf9397b11bb to your computer and use it in GitHub Desktop.
Ui Component example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="global-underlay" | |
data-bind=" | |
css: {'global-underlay--active': state().underlayActive}, | |
click: close | |
" | |
></div> | |
<div class="global-overlay" | |
data-bind=" | |
css: { | |
'global-overlay--active': state().overlayActive, | |
'global-overlay--loading': state().loading, | |
'global-overlay--ready': state().ready, | |
}"> | |
<div class="global-overlay__loader" | |
data-bind="css: {'global-overlay__loader--active': state().loading}"> | |
<p data-bind="text: loadingText"></p> | |
</div> | |
<button | |
type="button" | |
class="global-overlay__close" | |
data-bind="click: close"> | |
<svg class="svg-icon"><use xlink:href="#svg-close"></use></svg> | |
</button> | |
<div class="global-overlay__content" | |
data-ui-id="overlay-content" | |
data-bind="css: {'global-overlay__content--active': state().ready}"></div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
"uiComponent", | |
"jquery", | |
"ko", | |
"underscore", | |
"mage/translate", | |
], function(Component, $, ko, _, $t) { | |
return Component.extend({ | |
defaults: { | |
template: 'Simmi_Theme/account.html', | |
loadingText: $t('Please wait...'), | |
}, | |
initialize: function() { | |
var self = this; | |
self._super(); | |
// any other init code here | |
} | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div data-bind="scope: 'accountOverlay'" id="account-overlay"> | |
<!-- ko template: getTemplate() --><!-- /ko --> | |
</div> | |
<script type="text/x-magento-init"> | |
{ | |
"*": { | |
"Magento_Ui/js/core/app": { | |
"components": { | |
"accountOverlay": { | |
"component": "Simmi_Theme/js/account" | |
} | |
} | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment