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

Dialog component #480

Closed
mxstbr opened this issue Jun 24, 2019 · 2 comments
Closed

Dialog component #480

mxstbr opened this issue Jun 24, 2019 · 2 comments

Comments

@mxstbr
Copy link
Contributor

mxstbr commented Jun 24, 2019

For our internal project, we will require a modal. I have to build it anyway, so I figured I'd kick off a discussion about upstreaming it to @primer/components!

Here is the API I was thinking about using:

<Dialog title="String" isOpen={true} onDismiss={() => {}}>
  <Text>Content</Text>
</Dialog>

This would render a dialog like this as a React portal:

Screenshot 2019-06-24 at 09 56 46

Clicking either the X Octicon or the background overlay calls onDismiss, which should close the dialog.

Initial questions:

  • Should the title prop be able to accept any React node, do we render e.g. icons in dialog titles anywhere?

  • I specifically avoided adding padding automatically to the contents, as that would make it hard to e.g. render an alert in the dialog like we do in the "Delete repo" dialog (reference below). To make sure users set the spacing correctly, we could add a DialogBody component that does nothing but sets padding: 16px around its children?

    Screenshot 2019-06-24 at 09 58 21

  • I would like to use @reach/dialog to make sure we get the a11y correct. Would that be alright?

@colebemis
Copy link
Contributor

This API looks good to me! 👍 Thanks, @mxstbr 🎉

Should the title prop be able to accept any React node, do we render e.g. icons in dialog titles anywhere?

I could go either way on this one but I'm leaning towards constraining the title prop to only accept strings.

To make sure users set the spacing correctly, we could add a DialogBody component that does nothing but sets padding: 16px around its children?

I'm not opposed to a DialogBody component but <Box p={3}> is already pretty concise. If we're going for a "Minimal API," we can probably leave out DialogBody.

I would like to use @reach/dialog to make sure we get the a11y correct. Would that be alright?

@emplums would know better than me, but I'm fine with using @reach/dialog. I'm not sure if we have the proper loaders to import the Reach stylesheet (https://ui.reach.tech/styling). So you might have to set that up.

@mxstbr
Copy link
Contributor Author

mxstbr commented Jun 24, 2019

Agree with everything you said @colebemis! We should be able to integrate the Reach styles with styled-components fairly easily if we can import them as a string, I can definitely set that up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants