-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Modal] Add prop small to decrease Modal's width #4177
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
Conversation
|
👋 Thanks for opening your first pull request. A contributor should give feedback soon. If you haven’t already, please check out the contributing guidelines. |
|
🟡 This pull request modifies 6 files and might impact 5 other files. This is an average splash zone for a change, remember to tophat areas that could be affected. Details:All files potentially affected (total: 5)
📄
|
d92496a to
cc1c480
Compare
cc1c480 to
8ffee3f
Compare
| $minimal-width: rem(380px); | ||
| $small-width: rem(620px); | ||
| $large-width: rem(980px); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure if I could rename this, but ideally, we should have small | medium | large tokens instead.
| </Modal.Section> | ||
| </Modal> | ||
| </div> | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /** Increases the modal width */ | ||
| large?: boolean; | ||
| /** Decreases the modal width */ | ||
| small?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should add a prop width that takes in small | medium (default) | large and keep the prop large until we're good to deprecate it in future versions. I think that makes more sense because then we would avoid having these two props (small and large) being passed simultaneously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I think it makes more sense to have a width prop rather than small & large!
We've seen similar API bloat with the Button component. It has > 10 modifiers and depending on which ones you apply. Who knows what you'll get and what modifiers will be active 🤷
If we're confident moving forward with the width prop we can deprecate large now since it'll need to be deprecated for at least one major version cycle before it can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds good to me, we can then make sure any modals in admin using large are switched over to the new prop. (AFAIK we only have 1, possibly a second). I guess partners would be notified that they need to switch over as well.
@alex-page I remember you had a comment about this possibly being an issue. Are we good to go with this approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have the large prop. I would like to see two PR's one to ship small at this moment then a breaking change to replace small and large.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works for me. I can put up another PR for the breaking change next. Is this one good for adding the small prop?
| const classes = classNames( | ||
| styles.Modal, | ||
| small && styles.sizeSmall, | ||
| large && styles.sizeLarge, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case both small and large are passed to the component, large should override small. I wonder where would be the best place to warn about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me as a failsafe, although if we end up using a width prop, I don't believe we'll need to have this logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^ Yup! It'll look something like
styles.Modal,
styles[variationName('size', size)],
limitHeight && styles.limitHeight,| $vertical-spacing: 60px; | ||
| $horizontal-spacing: spacing(extra-loose) * 2; | ||
| $height-limit: 600px; | ||
| $minimal-width: rem(380px); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minimal is a little bit confusing. This isn't much better but might help?
| $minimal-width: rem(380px); | |
| $xsmall-width: rem(380px); |
8ffee3f to
85381c2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢 ✅
UNRELEASED.md
Outdated
| - Add `noScroll` prop to `Modal` which prevents modal contents from scrolling ([#4153](https://github.com/Shopify/polaris-react/pull/4153)) | ||
| - Added new `color` prop to ProgressBar ([#3415](https://github.com/Shopify/polaris-react/pull/3415)) | ||
| - Added `requiredIndicator` prop to `Label`, `Labelled`, `Select` and `TextField` ([#4119](https://github.com/Shopify/polaris-react/pull/4119)) | ||
| - Add `small` prop to `Modal` so that width can be decreased to 380px ([#4146](https://github.com/Shopify/polaris-react/pull/4146)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - Add `small` prop to `Modal` so that width can be decreased to 380px ([#4146](https://github.com/Shopify/polaris-react/pull/4146)) | |
| - Add `small` prop to `Modal` so that width can be decreased to 380px ([#4177](https://github.com/Shopify/polaris-react/pull/4177)) |
85381c2 to
eb911e5
Compare
|
🎉 Thanks for your contribution to Polaris React! |

WHY are these changes introduced?
Closes #4174
We'd like to be able to
decreaseModals' width similarly to how we're currently able to increase it through the proplarge.WHAT is this pull request doing?
This PR adds a prop
smallto theModalcomponent so that users are able to decrease Modals' width in a similar manner that they can increase it through the proplarge.We've considered adding a prop
widththat could receive eithersmall | medium(default) | large, which would avoid having two props that control width being passed into the component simultaneously, but that would break the current API. Therefore, if bothsmallandlargeare passed in at the same time, we'll default tolarge.How to 🎩
🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines
Another example with the code from README.md
Copy-paste this code in
playground/Playground.tsx:To see this addition live, just add a
smallprop to the Modal component. Please make sure the proplargeis not being passed simultaneously, as it would take priority over thesmallprop.🎩 checklist
README.mdwith documentation changes