1
1
import React , { PropTypes , Component } from 'react'
2
2
import ReactTransitionGroup from 'react-addons-transition-group'
3
3
4
- const getStyles = ( props ) => ( {
4
+ const styles = {
5
5
root : {
6
6
width : '100vw' ,
7
7
height : '100vh' ,
@@ -11,106 +11,98 @@ const getStyles = (props) => ({
11
11
zIndex : 1500 ,
12
12
background : '#fafafa'
13
13
}
14
- } )
14
+ }
15
15
16
16
class TransitionItem extends Component {
17
- static propTypes = {
18
- children : PropTypes . node ,
19
- style : PropTypes . object ,
20
- } ;
21
-
22
- state = {
23
- style : {
24
- opacity : 0 ,
25
- transition : 'all 225ms cubic-bezier(0.0, 0.0, 0.2, 1)' ,
26
- transform : 'translate(0, 56px)'
27
- } ,
28
- } ;
17
+ constructor ( props ) {
18
+ super ( props )
19
+ this . state = {
20
+ style : {
21
+ opacity : 0 ,
22
+ transition : 'all 225ms cubic-bezier(0.0, 0.0, 0.2, 1)' ,
23
+ transform : 'translate(0, 56px)'
24
+ }
25
+ }
26
+ }
29
27
30
- componentWillUnmount ( ) {
31
- clearTimeout ( this . enterTimeout ) ;
32
- clearTimeout ( this . leaveTimeout ) ;
28
+ componentWillUnmount ( ) {
29
+ clearTimeout ( this . enterTimeout )
30
+ clearTimeout ( this . leaveTimeout )
33
31
}
34
32
35
- componentWillEnter ( callback ) {
36
- this . componentWillAppear ( callback ) ;
33
+ componentWillEnter ( callback ) {
34
+ this . componentWillAppear ( callback )
37
35
}
38
36
39
- componentWillAppear ( callback ) {
37
+ componentWillAppear ( callback ) {
40
38
this . enterTimeout = setTimeout ( ( ) => {
41
39
this . setState ( {
42
40
style : {
43
41
opacity : 1 ,
44
42
transition : 'all 225ms cubic-bezier(0.0, 0.0, 0.2, 1)' ,
45
- transform : 'translate(0, 0px)' ,
43
+ transform : 'translate(0, 0px)'
46
44
}
47
45
} )
48
- this . enterTimeout = setTimeout ( callback , 225 ) ; // matches transition duration
46
+ this . enterTimeout = setTimeout ( callback , 225 ) // matches transition duration
49
47
} )
50
48
}
51
49
52
- componentWillLeave ( callback ) {
50
+ componentWillLeave ( callback ) {
53
51
this . setState ( {
54
52
style : {
55
53
opacity : 0 ,
56
54
transition : 'all 195ms cubic-bezier(0.4, 0.0, 1, 1)' ,
57
55
transform : 'translate(0, 56px)'
58
- } ,
59
- } ) ;
56
+ }
57
+ } )
60
58
61
- this . leaveTimeout = setTimeout ( callback , 195 ) ; // matches transition duration
59
+ this . leaveTimeout = setTimeout ( callback , 195 ) // matches transition duration
62
60
}
63
61
64
- render ( ) {
62
+ render ( ) {
65
63
const {
66
64
style,
67
65
children,
68
66
...other
69
- } = this . props ;
67
+ } = this . props
70
68
71
69
return (
72
70
< div { ...other } style = { { ...style , ...this . state . style } } >
73
71
{ children }
74
72
</ div >
75
- ) ;
73
+ )
76
74
}
77
75
}
78
76
79
- export default class FullscreenDialogFrame extends Component {
80
- render ( ) {
81
- const styles = getStyles ( this . props )
82
-
83
- const {
84
- children,
85
- style,
86
- title,
87
- titleStyle,
88
- } = this . props
77
+ TransitionItem . propTypes = {
78
+ children : PropTypes . node ,
79
+ style : PropTypes . object
80
+ }
89
81
90
- return (
91
- < ReactTransitionGroup
92
- component = 'div'
93
- transitionAppear = { true }
94
- transitionAppearTimeout = { 225 }
95
- transitionEnter = { true }
96
- transitionEnterTimeout = { 225 }
97
- >
98
- { this . props . open && (
99
- < TransitionItem style = { {
100
- ... styles . root ,
101
- ...style
102
- } }
103
- >
104
- { this . props . children }
105
- </ TransitionItem >
106
- ) }
107
- </ ReactTransitionGroup >
108
- )
109
- }
82
+ export default function FullscreenDialogFrame ( { children , open , style } ) {
83
+ return (
84
+ < ReactTransitionGroup
85
+ component = 'div'
86
+ transitionAppear
87
+ transitionAppearTimeout = { 225 }
88
+ transitionEnter
89
+ transitionEnterTimeout = { 225 }
90
+ >
91
+ { open && (
92
+ < TransitionItem style = { {
93
+ ...styles . root ,
94
+ ... style
95
+ } }
96
+ >
97
+ { children }
98
+ </ TransitionItem >
99
+ ) }
100
+ </ ReactTransitionGroup >
101
+ )
110
102
}
111
103
112
104
FullscreenDialogFrame . propTypes = {
113
- children : PropTypes . node ,
105
+ children : PropTypes . node ,
114
106
open : PropTypes . bool . isRequired ,
115
107
style : PropTypes . object
116
108
}
0 commit comments