Skip to content

Commit

Permalink
Merge pull request DefinitelyTyped#17983 from ttamminen/react-modal
Browse files Browse the repository at this point in the history
[React-Modal] Added support for providing object to class names
  • Loading branch information
RyanCavanaugh authored Jul 14, 2017
2 parents 6193386 + 43560c3 commit 2a3c0b2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
19 changes: 14 additions & 5 deletions types/react-modal/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Type definitions for react-modal 1.6
// Project: https://github.com/reactjs/react-modal
// Definitions by: Rajab Shakirov <https://github.com/radziksh>, Drew Noakes <https://github.com/drewnoakes>, Thomas B Homburg <https://github.com/homburg>
// Definitions by: Rajab Shakirov <https://github.com/radziksh>,
// Drew Noakes <https://github.com/drewnoakes>,
// Thomas B Homburg <https://github.com/homburg>
// Tatu Tamminen <https://github.com/ttamminen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3

Expand All @@ -20,6 +23,12 @@ declare namespace ReactModal {
};
}

interface Classes {
base?: string;
afterOpen?: string;
beforeClose?: string;
}

interface Props {
/* Boolean describing if the modal should be shown or not. Defaults to false. */
isOpen: boolean;
Expand All @@ -39,10 +48,10 @@ declare namespace ReactModal {
shouldCloseOnOverlayClick?: boolean;
/* String className to be applied to the portal. Defaults to "ReactModalPortal". */
portalClassName?: string;
/* String className to be applied to the overlay. */
overlayClassName?: string;
/* String className to be applied to the modal content. */
className?: string;
/* String or object className to be applied to the overlay. */
overlayClassName?: string | Classes;
/* String or object className to be applied to the modal content. */
className?: string | Classes;
/* String indicating how the content container should be announced to screenreaders. */
contentLabel?: string;
/* String indicating the role of the modal, allowing the 'dialog' role to be applied if desired. */
Expand Down
12 changes: 12 additions & 0 deletions types/react-modal/react-modal-tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,25 @@ class ExampleOfUsingReactModal extends React.Component {
padding: '20px'
}
};
const customClasses = {
afterOpen: 'afterOpen',
base: 'base',
beforeClose: 'beforeClose'
};
const customOverlayClasses = {
afterOpen: 'afterOpen',
base: 'base',
beforeClose: 'beforeClose'
};
return (
<ReactModal
isOpen={true}
onAfterOpen={onAfterOpenFn}
onRequestClose={onRequestCloseFn}
closeTimeoutMS={1000}
style={customStyle}
className={customClasses}
overlayClassName={customOverlayClasses}
>
<h1>Modal Content</h1>
<p>Etc.</p>
Expand Down

0 comments on commit 2a3c0b2

Please sign in to comment.