11import React , { PureComponent } from 'react'
2- import ReactDOM , { findDOMNode } from 'react-dom'
3- import Transition from 'react-transition-group/Transition' ;
4- import { Manager , Target , Popper , Arrow } from '../src/react-popper '
2+ import { findDOMNode } from 'react-dom'
3+ import Transition from 'react-transition-group/Transition'
4+ import PropTypes from 'prop-types '
55import outy from 'outy'
6+ import { Manager , Target , Popper } from '../src/react-popper'
67
78const duration = 300
89
@@ -13,7 +14,7 @@ const defaultStyle = {
1314
1415const transitionStyles = {
1516 entering : { opacity : 0 } ,
16- entered : { opacity : 1 } ,
17+ entered : { opacity : 1 } ,
1718}
1819
1920const CustomTarget = ( { innerRef, ...props } ) => (
@@ -36,6 +37,10 @@ const CustomTarget = ({ innerRef, ...props }) => (
3637 />
3738)
3839
40+ CustomTarget . propTypes = {
41+ innerRef : PropTypes . func ,
42+ }
43+
3944const CustomPopper = ( { innerRef, style, ...props } ) => (
4045 < div
4146 ref = { innerRef }
@@ -54,6 +59,11 @@ const CustomPopper = ({ innerRef, style, ...props }) => (
5459 />
5560)
5661
62+ CustomPopper . propTypes = {
63+ innerRef : PropTypes . func ,
64+ style : PropTypes . object ,
65+ }
66+
5767class AnimatedExample extends PureComponent {
5868 state = {
5969 isOpen : false ,
@@ -87,7 +97,7 @@ class AnimatedExample extends PureComponent {
8797 this . outsideTap = outy (
8898 elements ,
8999 [ 'click' , 'touchstart' ] ,
90- this . _handleOutsideTap
100+ this . _handleOutsideTap ,
91101 )
92102 }
93103
@@ -101,36 +111,36 @@ class AnimatedExample extends PureComponent {
101111
102112 render ( ) {
103113 return (
104- < div >
105- < h2 > Animated Example</ h2 >
106- < Manager >
107- < Target
108- innerRef = { c => ( this . target = findDOMNode ( c ) ) }
109- component = { CustomTarget }
110- onClick = { this . _handleTargetClick }
114+ < div >
115+ < h2 > Animated Example</ h2 >
116+ < Manager >
117+ < Target
118+ innerRef = { c => ( this . target = findDOMNode ( c ) ) }
119+ component = { CustomTarget }
120+ onClick = { this . _handleTargetClick }
121+ >
122+ Click { this . state . isOpen ? 'outside to hide' : 'to show' } popper
123+ </ Target >
124+ < Transition in = { this . state . isOpen } timeout = { duration } >
125+ { state => (
126+ < Popper
127+ key = "popper"
128+ component = { CustomPopper }
129+ innerRef = { c => {
130+ this . popper = findDOMNode ( c )
131+ } }
132+ placement = "bottom"
133+ style = { {
134+ ...defaultStyle ,
135+ ...transitionStyles [ state ] ,
136+ } }
111137 >
112- Click { this . state . isOpen ? 'outside to hide' : 'to show' } popper
113- </ Target >
114- < Transition in = { this . state . isOpen } timeout = { duration } >
115- { state => (
116- < Popper
117- key = "popper"
118- component = { CustomPopper }
119- innerRef = { c => {
120- this . popper = findDOMNode ( c )
121- } }
122- placement = "bottom"
123- style = { {
124- ...defaultStyle ,
125- ...transitionStyles [ state ]
126- } }
127- >
128- < div > Animated Popper 🎉</ div >
129- </ Popper >
130- ) }
131- </ Transition >
132- </ Manager >
133- </ div >
138+ < div > Animated Popper 🎉</ div >
139+ </ Popper >
140+ ) }
141+ </ Transition >
142+ </ Manager >
143+ </ div >
134144 )
135145 }
136146}
0 commit comments