-
Notifications
You must be signed in to change notification settings - Fork 829
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
Refactor/extract expose dialog utility components #1470
base: master
Are you sure you want to change the base?
Refactor/extract expose dialog utility components #1470
Conversation
Hey @brandongregoryscott Would you mind reviewing this PR? |
✅ Deploy Preview for evergreen-storybook ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
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 @shreedharbhat98! Thanks for the contribution. This one has been on my mind for a while now. I pulled it down and I'm playing around with it in Storybook, I think one thing that is crucially missing is the close
function from the render props provided by Overlay
. This is the 'behind-the-scenes' close handler that lets the Dialog close itself even if you don't pass any custom onCancel
or onConfirm
handlers.
I left some general cleanup comments for the structure of how the components are broken out, but I think I need to take a step back and figure out what the API for these utility components should look like. Ideally, I wanted them to be broken out in a way that you could pass them to the header
/footer
prop of the Dialog
and get the outer styling for free, something along the lines of:
<Dialog
header={
<Dialog.Header>
<Heading>Hello world</Heading>
<Link>View documentation</Link>
</Dialog.Header>
}
>
{/* ... */}
</Dialog>
However, the close
function that we get from the Overlay
's render props complicates this. It feels like we need some way to pass through this function from the Dialog
to the DialogHeader
and DialogFooter
components, but you wouldn't have it available in the above example ☝️ unless you used a function to pass it along, i.e:
<Dialog
header={({ close }) =>
<Dialog.Header>
<Heading>Hello world</Heading>
<Link>View documentation</Link>
<IconButton icon={CrossIcon} onClick={close}/>
</Dialog.Header>
}
>
{/* ... */}
</Dialog>
(and that might be okay, too. It's kinda how the header
prop works right now - you can pass arbitrary JSX, but you won't get the close functionality for free without using the function variant.)
Wanted to give you some initial feedback, but I'll try to report back here or on the original issue and tag you when I have more specific feedback on what the props/implementation should look like. Hope this helps for now!
…tility-components
Hey @shreedharbhat98 - sorry for the delay. I pushed out a branch on my fork that has the API design I was thinking of: The two major changes are the addition of the optional
Finally, for a better developer experience, I added a default Hope this helps! Let me know if I can add any additional context or clarification. |
Thanks for the suggestions @brandongregoryscott . I will try to implement this. Thanks a bunch |
…tility-components
Hey @brandongregoryscott As we use the |
Since these components are mostly used for composition and aren't really meant to be used on their own, I would say there's little value in building out new stories for them. |
Overview
Extracted the
renderHeader , renderChildren, renderFooter
JSX functions and exposed them as standalone components.Screenshots (if applicable)
Documentation