Closed andershol closed 6 years ago
You always need to pass the instance of a component, there is no way around it.
I thought I was passing a component (as they use the term here https://mithril.js.org/#components ), i.e. a js object with a "view" property. But I guess my concern is (buried in) the second part: Are there a good way of accessing the component state from the dialog buttons? In your dialog example ( https://jsfiddle.net/ArthurClemens/0g6010eu/ ) it seems that you have just made the state global which seems non-optimal, especially if I want to encapsulate the dialog content.
Currently I can do something like this, where the body of the dialog is set to a bit of hyperscript: http://jsbin.com/suwohaloxo/1/edit?js,output But if I understand the documentation, at https://github.com/ArthurClemens/polythene/blob/master/docs/components/dialog.md , correctly, I should be able to use a component as the body by writing "body: DialogComponent," instead of "body: m(DialogComponent),", but this do not work (the js-console in Firefox says "vnode.tag is undefined"): http://jsbin.com/xonefikixi/1/edit?js,output (and then I might even be able to avoid sending the dialog options as a function?)
But I think, that I really would like to be able to write something like this, where I made up the DialogLayout component (maybe this is basically what the DialogPane does today), so I can access the state from the buttons and keep the buttons as part of the component. http://jsbin.com/nejagenoze/1/edit?js,output I'm not sure if you could make it so that attributes like "title" and "backdrop" could be passed to both Dialog.show and DialogLayout: