Skip to content

Commit

Permalink
style(Portal): update typings and propTypes usage (Semantic-Org#1300)
Browse files Browse the repository at this point in the history
  • Loading branch information
layershifter authored and harel committed Feb 18, 2017
1 parent 618fbb5 commit a886aaa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
28 changes: 13 additions & 15 deletions src/addons/Portal/Portal.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@ import ReactDOM from 'react-dom'

import {
AutoControlledComponent as Component,
keyboardKey,
isBrowser,
keyboardKey,
makeDebugger,
META,
} from '../../lib'

const debug = makeDebugger('portal')

const _meta = {
name: 'Portal',
type: META.TYPES.ADDON,
}

/**
* A component that allows you to render children outside their parent.
* @see Modal
Expand All @@ -29,14 +24,6 @@ class Portal extends Component {
/** Additional classes. */
className: PropTypes.string,

/**
* Controls whether or not the portal should close on a click on the portal background.
* NOTE: This differs from closeOnDocumentClick:
* - DocumentClick - any click not within the portal
* - RootNodeClick - a click not within the portal but within the portal's wrapper
*/
closeOnRootNodeClick: PropTypes.bool,

/** Controls whether or not the portal should close when the document is clicked. */
closeOnDocumentClick: PropTypes.bool,

Expand All @@ -50,6 +37,14 @@ class Portal extends Component {
*/
closeOnPortalMouseLeave: PropTypes.bool,

/**
* Controls whether or not the portal should close on a click on the portal background.
* NOTE: This differs from closeOnDocumentClick:
* - DocumentClick - any click not within the portal
* - RootNodeClick - a click not within the portal but within the portal's wrapper
*/
closeOnRootNodeClick: PropTypes.bool,

/** Controls whether or not the portal should close on blur of the trigger. */
closeOnTriggerBlur: PropTypes.bool,

Expand Down Expand Up @@ -132,7 +127,10 @@ class Portal extends Component {
'open',
]

static _meta = _meta
static _meta = {
name: 'Portal',
type: META.TYPES.ADDON,
}

state = {}

Expand Down
13 changes: 9 additions & 4 deletions src/addons/Portal/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import * as React from 'react';

export interface PortalProps {
[key: string]: any;

/** Primary content. */
children?: React.ReactNode;

/** Additional classes. */
className?: string;

Expand Down Expand Up @@ -52,31 +57,31 @@ export interface PortalProps {
* @param {SyntheticEvent} event - React's original SyntheticEvent.
* @param {object} data - All props.
*/
onClose?: React.MouseEventHandler<HTMLDivElement>;
onClose?: (event: React.MouseEvent<HTMLElement>, data: PortalProps) => void;

/**
* Called when the portal is mounted on the DOM
*
* @param {null}
* @param {object} data - All props.
*/
onMount?: (nothing: null, props: PortalProps) => void;
onMount?: (nothing: null, data: PortalProps) => void;

/**
* Called when an open event happens
*
* @param {SyntheticEvent} event - React's original SyntheticEvent.
* @param {object} data - All props.
*/
onOpen?: React.MouseEventHandler<HTMLDivElement>;
onOpen?: (event: React.MouseEvent<HTMLElement>, data: PortalProps) => void;

/**
* Called when the portal is unmounted from the DOM
*
* @param {null}
* @param {object} data - All props.
*/
onUnmount?: (nothing: null, props: PortalProps) => void;
onUnmount?: (nothing: null, data: PortalProps) => void;

/** Controls whether or not the portal is displayed. */
open?: boolean;
Expand Down

0 comments on commit a886aaa

Please sign in to comment.