upmostly / modali

A delightful modal dialog component for React, built from the ground up to support React Hooks.
213 stars 23 forks source link

Controlling position #16

Closed yairEO closed 5 years ago

yairEO commented 5 years ago

There's not a single word about position in the README, and all demos open the modal at the top of the window and not in the center, where it's more common.

I cannot use this lovely component until it has support for positioning it in the center..

jcrowson commented 5 years ago

@yairEO Great suggestion! I'm going to add this to the next release. Thoughts on what positions you'd like, or what the syntax should be? Off the top of my head, I'm leaning more towards it being an option of course, but there are various ways we could implement this:

const [example, toggleExample] = useModali({
    position: 'center'
    ...
});

This allows for other positions to be passed, such as bottom, left, `right, etc. I don't know if a modal should be positioned in anything but top or center, however...

OR

const [example, toggleExample] = useModali({
    isCentered: true,
    ...
});

This means that the option is pretty much boolean. It's top (by default) or centered.

@yairEO Thoughts?

jcrowson commented 5 years ago

I ended up going for:

const [example, toggleExample] = useModali({
    centered: true,
    ...
});

For a few reasons:

  1. The syntax matches the other prop syntax.
  2. There are only two positions: top (default) and center. So boolean makes sense here.

Added to v1.2 branch.