-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dialogs and popovers #67
Comments
@b-laporte this is much needed discussions and I'm going to have several remarks. At the beginning I would like to focus on dialogs / modals as I think that getting them right will make it easier to deal with popovers / tooltips and the like. But before diving into more details, I would like to know more about this statement:
Why do you feel that passing them from a controller is "bad"? Ar there any practical downsides of such approach? For me this is very important to get it right and personally I would favor passing options from a controller instead of introducing Generally speaking IMO the problem is a bit larger and we need to think about concerns like those:
In any case at this point I'm trying to understand how the proposal could / would work with all the use-cases I've encountered while working on the modals so far. But yeh, before discussing syntax details I would like to better understand why you feel like passing options from a controller might cause problems. |
Well, I am not necessarily against offering the possibility to pass the dialog options from the controller - e.g. through:
But those options belong to the 'view' - and not to the controller. As such it should be possible (and to me preferable) to pass them from the 'view', and not (only) from the controller. Having said that, and to answer your points - in this proposal:
Btw. a template that uses a component for the dialog decoration would look like this:
|
For dialogs (and popovers) i think we should in the first place, try everything that is doable with only what we have today (ie templates, controllers, and css positioning). PS: on top of that we should also have a mandatory look at the html5 specification for dialog/popup, because again everything that we are detailing here might only be a matter of polyfills (that probably already exists.....) EDIT: it already exists !! https://github.com/GoogleChrome/dialog-polyfill |
One of the important (still) missing feature in hashspace is the support of dialogs (and popovers) - so here is a proposal on how I see it:
Dialogs
First I think dialogs should be as easy to use a dialog as using normal templates. This is why I think opening a dialog could be done in a similar way as calling render():
The difference with render() is that show() shouldn't take a DOM element or DOM element id as argument - as hashspace should automatically create a poping div to host the template content. However hashspace should not generate any special surrounding HTML elements to frame the template content - as we should let the template choose how the dialog frame should be rendered (e.g. by using a 3rd party component).
The next question that comes to mind is then: how to pass dialog arguments (e.g. modal, center-horizontal, center-vertical, etc.). I don't think it should be passed as show() argument as it is not the controller's role to determine those rendering options. As a consequence, I would prefer going for a new {dialog-options} statement, that could look like this:
Of course {dialog-options} should be ignored if the template is not called in a dialog context (and if multiple dialog-options are found in the template stack, the first one should be used). The arguments could be a JSON structure, without the surrounding curly brackets (btw. syntax should be similar to CSS expressions that should be updated as well to match this syntax).
As you can read, the next problem to solve is: how to close a dialog, and pass a closing argument (e.g. 'ok' or 'cancel'). For this, I think hashspace should automatically create a dialog object accessible in the template scope. This dialog object would let the template know that it is in 'dialog mode' and would expose the dialog properties. It would also expose a close() method that would allow to callback the dialog caller, if a callback is provided as show() argument:
Of course, hashspace should automatically manage the 'ESC' key to close a dialog and call the callback in cancel mode (i.e. without any argument) - this default behaviour could also be overridden through a dialog-options argument.
The dialog object structure could look like this:
Popovers
Even though popovers are a bit different from dialogs, I think we should also be able to manage them in a similar way:
As dialog and popovers have many arguments that are not common (e.g. modal, center, etc.), I would suggest to have a 2nd context object (i.e. popover) instead of reusing dialog.
Of course, it should be possible to call it from a component's controller:
... so - what do you think?
The text was updated successfully, but these errors were encountered: