Skip to content
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

[feature request] Pass custom class to modal #818

Closed
jspizziri opened this issue Sep 29, 2016 · 6 comments
Closed

[feature request] Pass custom class to modal #818

jspizziri opened this issue Sep 29, 2016 · 6 comments

Comments

@jspizziri
Copy link

Perhaps I missed something when looking through the code; however, it would be nice if it were possible to pass custom classes on the modal with NgbModalOptions, that would then be applied to the modal template.

Thanks!

@pkozlowski-opensource
Copy link
Member

I'm very, very hesitant to go down this path. The thing is that modal window and backdrop creates many elements so if we want to allow users to customise most things the number of options would explode.

I understand the need but at this point your best option is just to fork the directive and maintain your own fork that would suit your particular needs. We want to support some form of customisation in the future but probably sth more sophisticated than just adding CSS classes.

Going to keep this one open as I understand the need but don't hold your breath and expect movement on this issue any time soon. What we need is design for something more flexible.

@jspizziri
Copy link
Author

@pkozlowski-opensource, I appreciate the desire for an abstract solutuon. Perhaps we can begin a discussion on the design by articulating all the requirements of customization. I would rather begin a discussion and potentially try and contribute then form my own little tribe by forking, as I'm entirely disinterested in maintaining my own fork 😊

@pkozlowski-opensource
Copy link
Member

@jspizziri sure, feel free to start a design doc and link it here. You can find an example of a design doc for other modal part here

As for requirements / flexibility we will have really hard time predicting what / where users might want to add. So ideally we would allow them to provide a custom window component and the custom one should replace the default one: https://github.com/ng-bootstrap/ng-bootstrap/blob/master/src/modal/modal-window.ts

As you can see the current modal window has quite a bit of functionality so this would have to be moved to some other place so providing custom components is easy. Ideally users should just provide the template bit (

<div [class]="'modal-dialog' + (size ? ' modal-' + size : '')" role="document">
<div class="modal-content" (click)="stopPropagation($event)"><ng-content></ng-content></div>
</div>
) but I'm not sure how to do this, technically speaking

Of course there are other ways of solving the customization problem so let your creativity go wild :-)

Just to set expectations: customization capabilities are on the roadmap but we will start to seriously look into those topics only after 1.0 release (and this means that things like animations, keyboard navigation and accessibility got priority). Of course if anyone wants to step in and drive customisability efforts then things might happen sooner.

@colinmorelli
Copy link
Contributor

I have a similar need. While I definitely understand the desire to have a flexible and abstract solution to customization, I think most needs (likely related to style) can be met by simply allowing a custom class to be attached to the window and backdrop. CSS selectors can then target any child elements that ng-bootstrap may add fairly easily.

Is this something that would be considered until a larger solution can be made?

@pkozlowski-opensource
Copy link
Member

Is this something that would be considered until a larger solution can be made?

Yeh, this sounds like a potentially good short-term solution...

@DenisDremkov
Copy link

openModal () {
this.modalService.open(StageSettingsComponent, {backdropClass: 'backdrop-class'});
}

// SCSS (global)
.backdrop-class + .modal {
.modal-dialog {
.....
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants