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

Customize modal component when programmatically invoked #17001

Closed
1 task done
byzyk opened this issue Jun 6, 2019 · 4 comments
Closed
1 task done

Customize modal component when programmatically invoked #17001

byzyk opened this issue Jun 6, 2019 · 4 comments
Assignees

Comments

@byzyk
Copy link
Contributor

byzyk commented Jun 6, 2019

  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

In our application, we've created a couple of custom components as a wrapper on top of the Modal, with different styles and slightly enhanced API. We're facing a scenario where we need to programmatically invoke different types of Modals (like Modal.error()). Unfortunately, the is no convenient way to specify a custom component which we've created earlier.

What does the proposed API look like?

The way I see it is that a new option can be added to #Modal.method() config, something like Modal.error({ component: MyCustomErrorModal }). Make this flag optional or even add a new method, something like Modal.custom().

@zombieJ
Copy link
Member

zombieJ commented Jun 7, 2019

It's not a good place to set customize component with Modal.xxx. It's a simple function an will not provide much customize component support. You can make your own Modal static function instead.

@zombieJ zombieJ closed this as completed Jun 7, 2019
@byzyk
Copy link
Contributor Author

byzyk commented Jun 7, 2019

You can make your own Modal static function instead.

Yes this is how I initially wanted to approach it, but looking at the source code I've noticed that static function doesn't re-use code of Modal's component, so making my own static function is not very trivia unless I just copy/paste antd source code.

That's why I thought it'd be a nice opportunity to refactor modal component a bit, make it more DRY and easier to customize eventually.

Perhaps I'm missing something, but is there a way to wrap programmatically invoked Modal with my own custom component?

@zombieJ
Copy link
Member

zombieJ commented Jun 7, 2019

Modal.xxx internal wrap a ConfirmDialog component. It contains the mainly logic and pass some computed props to sub Dialog component. It's coupling. It will get more concern about component usage instead of getting benefit.
And for design side, Modal.xxx is aim on providing antd style modal and not wish user to much flexible about Modal component. Provides component is what we don't want.

In this case, yes, you may to code your static function own. You can copy full of the code or part of it or realize with own logic.

@byzyk
Copy link
Contributor Author

byzyk commented Jun 7, 2019

Ok, thanks for getting back to me and your clarifications

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

No branches or pull requests

3 participants