-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
adding some composition options for modals #15084
Conversation
started the job as gitpod-build-bmh-scrollable-modal-content.2 because the annotations in the pull request description changed |
@@ -14,8 +15,8 @@ export default function Modal(props: { | |||
specify?: string; | |||
title?: string; | |||
hideDivider?: boolean; | |||
buttons?: React.ReactChild[] | React.ReactChild; | |||
children: React.ReactChild[] | React.ReactChild; | |||
buttons?: ReactNode; |
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.
ReactNode
type encompasses arrays or single children, but also allows for null
.
(props.className || "") | ||
} | ||
className={cn( | ||
"flex flex-col max-h-screen relative bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-800 rounded-xl p-6 max-w-lg mx-auto text-left ", |
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 allows the modal container to adjust height, while being height constrained to the screen viewport
Good catch - I think this is from not using an |
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.
LGTM
Looking at this now! 👀 |
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.
Hey @selfcontained! Welcome to the team, and thanks for opening this! ✨
Left a few non-blocking comments below that we can split into separate follow-up issues.
Some thoughts on the UX changes of this PR:
- The responsive design of the dashboard is being tracked in Epic: Improve dashboard responsive layout #4050. 💡
- Improvements like creating more flexible and compact components like Replace the editor selection cards with the new dropdown component used in the start with options new workspace modal #13116 could help in some cases, see early designs in IDE selection modal window not fiting in screen #10747 (comment). 💡
- Generally, we could aim for making the viewport scrollable when the modal content extends below the viewport. 💭
- But making the modal contents scroll here sounds like a good, boring (simple) MVC solution here and will also resolve issues like IDE selection modal window not fiting in screen #10747. 🛹
- If scrolling is needed, this may be a good indicator to consider opening the content in a new page instead. So far, the modal component and pattern has suited well our needs, and we just started experimenting with opening content in new pages in the new access tokens product are, see
/new
and/edit
flows in/tokens
. 💡
Since code changes have been approved from two WebApp team members and there are no blocking UX comments, let's take a bias for action, merge this, and open any follow-up issues if needed. ✔️
@@ -291,8 +291,8 @@ function GitProviders() { | |||
{editModal && ( | |||
// TODO: Use title and buttons props | |||
<Modal visible={true} onClose={() => setEditModal(undefined)}> | |||
<h3 className="pb-2">Edit Permissions</h3> | |||
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-2 -mx-6 px-6 py-4"> | |||
<ModalHeader>Edit Permissions</ModalHeader> |
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.
suggestion: Since you've replaced the modal contents here could we also replace the contents for the New Git integration modal which is also much needed, see L750
below. If this is not as straightforward as the other instances, let's open a follow-up to keep track of this. 🏓
<h3 className="pb-2">{mode === "new" ? "New Git Integration" : "Git Integration"}</h3> |
(props.className || "") | ||
} | ||
className={cn( | ||
"flex flex-col max-h-screen relative bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-800 rounded-xl p-6 max-w-lg mx-auto text-left ", |
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.
thought: This will also resolve #10747. I've updated the PR description to also include that issue.
<ModalHeader>{props.title}</ModalHeader> | ||
<ModalBody hideDivider={props.hideDivider}>{props.children}</ModalBody> | ||
<ModalFooter>{props.buttons}</ModalFooter> |
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.
praise: Not sure if this introduces unnecessary complexity, but more structure like this is definitely needed! ✨
</div> | ||
<div className="flex justify-end mt-6 space-x-2">{props.buttons}</div> | ||
<ModalHeader>{props.title}</ModalHeader> | ||
<ModalBody hideDivider={props.hideDivider}>{props.children}</ModalBody> |
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.
fyi: Not sure where to add this comment, but one modal I'd love to improve after thes changes is the feedback modal. Cross-posting follow up issue (#10307) for visibility.
/unhold |
Description
The intention here is to fix the linked issue below so modals are more responsive, and the body of a modal can shrink and scroll when needed. To accomplish that, I needed to add a few css classes to the modal container and body wrapper. In order to allow us to have these sections of a modal consistently rendered, I created a few sub-components so we can compose our Modals a bit as well.
<Modal/>
s can still use thetitle
prop andbuttons
prop, which will get wrapped automatically like they were. It might be a good idea to unify how we render modals though at some point, and always compose them like below, but not an urgent change we have to make. These changes should provide a responsive modal w/ scrollable body for any pre-existing modal that was passing in atitle
prop as well.I've also moved the
classnames
dependency from devDeps to normal deps as I wanted to use it for some conditional class names. I'm happy to adjust that back though if we explicitly don't want to useclassnames
outside of tests though.We can iterate on this, and add built-in behavior to support pinned error messages on a modal that I saw in at least one place (when adding a new integration). This would allow that style of modal to also render responsively for smaller screen sizes.
Related Issue(s)
Fixes #12899, #10747
How to test
Navigate to Settings/Integrations and edit one of the integrations to open the modal.
* I've applied the same updates to the Environment Variables modal.
Release Notes
Documentation
Werft options:
If enabled this will build
install/preview
Valid options are
all
,workspace
,webapp
,ide
,jetbrains
,vscode
,ssh