Skip to content
This repository has been archived by the owner on Mar 9, 2021. It is now read-only.

[WIP] feat: add dialog component #251

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft

[WIP] feat: add dialog component #251

wants to merge 1 commit into from

Conversation

schne324
Copy link
Member

@schne324 schne324 commented Jan 2, 2020

To address this TODO and move towards removing repeated code, I've gone ahead and created a new <Dialog /> component. The <Modal /> and <Alert /> components can be replaced by <Dialog /> and <Dialog alert /> respectively.

Moving forward we have a few options that I'd like to discuss...

  1. deprecate <Modal /> and <Alert /> and mark this as a BREAKING CHANGE
  2. have all 3 (<Dialog />, <Modal /> and <Alert />) and update <Modal /> and <Alert /> to be simple wrappers which just call <Dialog /> under-the-hood
  3. same as above option except we make <Dialog /> a "private" component (as in we don't export it and don't have a demo page for it)
  4. scrap this proposed change and solve the repeated code problem in a different way

fwiw, I strongly prefer option 1 and am happy to discuss why I feel this way

Once we make a decision I will take this PR out of draft / make any necessary updates / write unit tests :)

Reviewer checks

Required fields, to be filled out by PR reviewer(s)

  • Follows the commit message policy, appropriate for next version
  • Tested for accessibility
  • Code is reviewed for security

@scurker
Copy link
Member

scurker commented Jan 3, 2020

My vote is for 1 as well.

An alert/modal would be for convenience methods anyway, so if we're going to break things I'd rather we break things to make the best possible thing.

initialFocus: alert
? '.dqpl-dialog-inner'
: '.dqpl-dialog-show .dqpl-modal-heading',
allowOutsideClick: () => false
Copy link
Member

Choose a reason for hiding this comment

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

We have ClickOutsideListener used elsewhere. It would be nice to converge on a single thing. I think we should evaluate the other places we use ClickOutsideListener to see if they need focus traps and adjust accordingly, maybe as a tech debt thing.

</button>
)}
</div>
{children}
Copy link
Member

Choose a reason for hiding this comment

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

Just being nitpicky here, but do you think this should be wrapped with a class? Alert has dqpl-content so wouldn't we want to possibly style all dialog content as well? I see there's <DialogContent> which I guess lets you opt in, but it feels reductive.

level: 2
};
DialogHeading.propTypes = {
level: PropTypes.number,
Copy link
Member

Choose a reason for hiding this comment

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

Consider using PropTypes.oneOf([1,2,3,4,5,6]), since level={500} is invalid.

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

Successfully merging this pull request may close these issues.

3 participants