FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(Modal): Convert Modal component to typescript by jeff-phillips-18 · Pull Request #1942 · patternfly/patternfly-react · GitHub

feat(Modal): Convert Modal component to typescript - #1942

Merged
dlabaj merged 4 commits into
patternfly:masterfrom
jeff-phillips-18:modal-ts
May 17, 2019
Merged

feat(Modal): Convert Modal component to typescript#1942
dlabaj merged 4 commits into
patternfly:masterfrom
jeff-phillips-18:modal-ts

Conversation

jeff-phillips-18 commented May 7, 2019
edited
Loading

Copy link
Copy Markdown
Member

What: Convert Modal component to typescript

Additional issues: Allows specification of heading level on the ModalBoxHeader

Fixes #1736, #1996

Copy link
Copy Markdown
Collaborator

PatternFly-React preview: https://1942-pr-patternfly-react-patternfly.surge.sh

codecov-io commented May 7, 2019
edited
Loading

Copy link
Copy Markdown

Codecov Report

Merging #1942 into master will decrease coverage by 0.06%.
The diff coverage is 80.91%.

@@            Coverage Diff             @@
##           master    #1942      +/-   ##
==========================================
- Coverage    81.9%   81.84%   -0.07%     
==========================================
  Files         628      628              
  Lines        7053     7112      +59     
  Branches      201      236      +35     
==========================================
+ Hits         5777     5821      +44     
+ Misses       1167     1163       -4     
- Partials      109      128      +19
Flag Coverage Δ
#patternfly3 84.88% <ø> (ø) ⬆️
#patternfly4 77.8% <80.91%> (-0.07%) ⬇️
#patternflymisc 95.68% <ø> (ø) ⬆️
Impacted Files Coverage Δ
...4/react-core/src/components/Modal/ModalContent.tsx 67.74% <67.74%> (ø)
...4/react-core/src/components/Modal/ModalBoxBody.tsx 75% <75%> (ø)
...react-core/src/components/Modal/ModalBoxFooter.tsx 75% <75%> (ø)
...-core/src/components/Modal/ModalBoxCloseButton.tsx 75% <75%> (ø)
...react-core/src/components/Modal/ModalBoxHeader.tsx 83.33% <83.33%> (ø)
...ernfly-4/react-core/src/components/Modal/Modal.tsx 88.23% <88.23%> (ø)
...fly-4/react-core/src/components/Modal/ModalBox.tsx 92.3% <92.3%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5f9b092...793484d. Read the comment docs.

dlabaj added the PF4 label May 7, 2019

Copy link
Copy Markdown
Contributor

@jeff-phillips-18 can you also add integration tests for this component as outlined on this README?

Copy link
Copy Markdown
Member Author

Added integration tests and demo page

actions?: any,
/** A callback for when the close button is clicked */
onClose: PropTypes.func,
onClose?(): void;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Nitpicky, but we've been doing onClose?: () => void. Sometimes different docgen versions pick it up differently.

container?: HTMLDivElement = undefined;

static defaultProps = {
width: undefined as any,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can remove this line, width is by default undefined.

constructor(props: ModalProps) {
super(props);
const newId = Modal.currentId++;
this.id = `pf-modal-${newId}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

For AboutModal, I added this to state for lifecycle purposes instead of just this. Perhaps we should be consistent?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Personally I prefer it to just be an instance variable than on state. To me, the id is not stateful.

handleEscKeyClick = (event: KeyboardEvent): void => {
if (event.keyCode === KEY_CODES.ESCAPE_KEY && this.props.isOpen) {
this.props.onClose();
this.props.onClose!();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Let's set onClose = () => undefined as any in defaultProps (if we can) and avoid the ugly shebang!


componentDidMount() {
document.body.appendChild(this.container);
if (this.container) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I initialized the container here in AboutModal which makes more sense to do than in render() IMO. That way we don't rely on render being called before componentDidMount. See my AboutModal PR.

isLarge: PropTypes.bool,
/** Creates a small version of the Modal */
isSmall: PropTypes.bool,
onClose?(): void;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

onClose?: () => void;

ModalContent.propTypes = propTypes;
ModalContent.defaultProps = defaultProps;

export default ModalContent;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Remove this line.

id,
hideTitle = false,
actions = [],
onClose = () => undefined,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Probably will need to change to () => undefined as any

onClose = () => undefined,
isLarge = false,
isSmall = false,
width = -1,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I appreciate this instead of null.

cy.get('#showDefaultModalButton').then((modalButton: JQuery<HTMLButtonElement>) => {
cy.wrap(modalButton).click();
cy.get('.pf-c-modal-box').then(() => {
cy.get('.pf-c-modal-box .pf-c-button[aria-label="Close"]').then(closeButton => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Great tests. Thanks a lot!

tlabaj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks great. A couple of small things.

import styles from '@patternfly/patternfly/components/ModalBox/modal-box.css';

export interface ModalBoxProps extends React.HTMLProps<HTMLDivElement> {
/** content rendered inside the ModalBox. */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We have been updating our docs to use sentence case. Can you please update these comments.

import styles from '@patternfly/patternfly/components/ModalBox/modal-box.css';

export interface ModalBoxBodyProps extends React.HTMLProps<HTMLDivElement> {
/** content rendered inside the ModalBoxBody */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Same comment about Sentence case here and for all other exported interfaces.

/** Flag to hide the title */
hideTitle?: boolean;
/** the heading level to use */
headingLevel?: TitleLevel;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We should be using a union of the strings here as was decided upon by the team.

tlabaj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

dlabaj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks @jeff-phillips-18 looks great!

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Successfully merging this pull request may close these issues.

Modal - heading level prop

7 participants


Back | FazBrowse Home | New Git URL