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

Modal width #2592

Closed
kaoz70 opened this issue Feb 21, 2020 · 10 comments
Closed

Modal width #2592

kaoz70 opened this issue Feb 21, 2020 · 10 comments

Comments

@kaoz70
Copy link
Contributor

kaoz70 commented Feb 21, 2020

Hello, is there a way to set a modal's width, its currently set to 850px by CSS, but I would like to create a dialog with a small amount of text and its too big for this:

image

But it would be great to get this:

image

Without overriding the CSS, because I would still like to use large modals.

I checked the source code and the docs, it seems the only properties you can set are title and content.

@artf
Copy link
Member

artf commented Feb 25, 2020

I checked the source code and the docs, it seems the only properties you can set are title and content.

Correct, probably it would be great to let it pass custom attributes... a PR would be welcome

@kaoz70
Copy link
Contributor Author

kaoz70 commented Feb 27, 2020

OK, what I'm thinking is to create a function to be able to set the width like: setWidth('400px'), and also a method to set custom attributes: setAttributes({'data-custom-attribute': 123}).

I think 2 functions are needed because the width is controlled by CSS, and so is the modal's design, so just letting the user set the width is good enough in this case. The attribute function would be for any other case that's needed

What do you think?

@artf
Copy link
Member

artf commented Mar 2, 2020

Good idea, but to be honest, for now, I'd simply add a new attributes option to the open function and apply them to the main container by taking care of keeping the original class.
So, in your case, you'd add a new class on open and the additional CSS to make that modal larger

@sunnykgupta
Copy link

I can help with this, @artf, let me know if it is okay to contribute.

@artf
Copy link
Member

artf commented Apr 29, 2020

@sunnykgupta sure if @kaoz70 is not already on it, it would be great

@kaoz70
Copy link
Contributor Author

kaoz70 commented May 8, 2020

Hello, sorry I'm piled with work now, if @sunnykgupta can give this a shot it would be great.

@marcepoblet
Copy link

Correct, probably it would be great to let it pass custom attributes... a PR would be welcome

Hi,

This change was introduced in grapesjs?

we have some property to change the size of the modal?

@artf
Copy link
Member

artf commented Oct 9, 2020

I'll add the attributes option to the open() method in the next release

@artf artf added this to To do in Release v0.16.27 via automation Oct 9, 2020
@marcepoblet
Copy link

I'll add the attributes option to the open() method in the next release

Perfect thanks

@artf artf closed this as completed in c430eef Oct 13, 2020
Release v0.16.27 automation moved this from To do to Done Oct 13, 2020
@ronaldaug
Copy link

ronaldaug commented Jul 21, 2021

For those who don't know how to use modal attributes.
You can add option opts.attributes to modal's open method as below.

const modal = editor.Modal;
const opts = {
       attributes: { class:'my-custom-class', id:'my-custom-id' }
}
modal.open(opts);

Because I didn't find how to use it in the documentation here.

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

No branches or pull requests

5 participants