Another Mithril JS modal window component; written in ES6 and compiled with Babel. This component has no dependencies outside of Mithril and aims to make no assumptions about CSS or transitions. When minified this component is around 1kb =D.
Include, require or import the Modal class.
import Modal from ('./dist/m-modal.js')
var example = {
controller: function() {
this.modal = new Modal({
state: false
});
},
view: function(ctrl) {
return [
m.component(cmodal, ctrl.modal)
]
}
}
var cmodal = {
controller: function(options) {
this.component = options.component;
},
view: function(ctrl) {
return m.component(ctrl.component(), {
view: function(mctrl) {
return m('.modal-content', [
m('h3', 'This is some modal content...')
]);
}
});
}
};
Name | Type | Value |
---|---|---|
State | Boolean | false |
Toggle the modal window display.
this.modal = new Modal({
state: false
});
this.modal.toggle()