Skip to content

Conversation

@BinaryMuse
Copy link
Contributor

@BinaryMuse BinaryMuse commented Mar 30, 2020

This PR extracts the Dialog header into a separate component, thus making it optional and more customizable. It also shifts default props around so that default styling is not affected, but users can still customize the background and flex properties of the header.

Since the original incarnation had specific styling for string titles, I've extracted the header into two components: Dialog.Header for fully custom headers, and Dialog.HeaderText for headers with only text that should match the original styles. I'm not a huge fan of this solution and am open to other ideas. JK this is fixed.

Finally, the close button has been placed as the first child inside StyledDialog so that it retains initial focus when the dialog is opened.

Closes #730

Merge checklist

  • Added or updated TypeScript definitions (index.d.ts) if necessary
  • Added/updated tests
  • Added/updated documentation
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Breaking changes

This PR introduces a breaking change.

Migration strategy

Change any Dialog component with a title prop set as follows:

<Dialog title="...title...">
  ...content...
</Dialog>

to

<Dialog>
  <Dialog.Header>...title...</Dialog.Header>
  ...content...
</Dialog>

@BinaryMuse BinaryMuse requested a review from emplums March 30, 2020 21:38
@vercel
Copy link

vercel bot commented Mar 30, 2020

This pull request is being automatically deployed with ZEIT Now (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://zeit.co/primer/primer-components/664ijgvj2
✅ Preview: https://primer-components-git-mkt-dialog-header-extraction.primer.now.sh

@vercel vercel bot temporarily deployed to Preview March 30, 2020 21:45 Inactive
@vercel vercel bot temporarily deployed to Preview March 30, 2020 21:47 Inactive
@vercel vercel bot temporarily deployed to Preview March 30, 2020 21:48 Inactive
Copy link
Contributor

@colebemis colebemis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, @BinaryMuse! I like this API a lot better ❤️

@vercel vercel bot temporarily deployed to Preview April 1, 2020 20:34 Inactive
@emplums emplums changed the base branch from master to major April 1, 2020 21:25
Copy link

@emplums emplums left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just left a couple comments!


const Dialog = ({title, children, ...props}) => {
function DialogHeader({theme, children, ...rest}) {
if (React.Children.toArray(children).every(ch => typeof ch === 'string')) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

@emplums emplums added the major release breaking changes label Apr 1, 2020
@emplums emplums mentioned this pull request Apr 1, 2020
8 tasks
@vercel vercel bot temporarily deployed to Preview April 1, 2020 21:47 Inactive
@BinaryMuse BinaryMuse merged commit be6ed30 into major Apr 1, 2020
@BinaryMuse BinaryMuse deleted the mkt/dialog-header-extraction branch April 1, 2020 21:58
@BinaryMuse BinaryMuse mentioned this pull request Apr 1, 2020
acknosyn added a commit to acknosyn/components that referenced this pull request Apr 14, 2020
…der-extraction"

Extract Dialog header into separate component

- (Edit) add commit be6ed3
@BinaryMuse BinaryMuse mentioned this pull request Apr 14, 2020
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

major release breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dialog changes

4 participants