1
1
import React from 'react' ;
2
+ import Modal from 'react-overlays/lib/Modal' ;
3
+
2
4
import { render } from 'react-dom' ;
3
5
4
6
import globalizeLocalizer from 'react-big-calendar/globalize-localizer' ;
@@ -28,8 +30,44 @@ function EventAgenda(props) {
28
30
return < em > { props . event . title } </ em >
29
31
}
30
32
31
- const Example = React . createClass ( {
32
33
34
+ let rand = ( ) => ( Math . floor ( Math . random ( ) * 20 ) - 10 ) ;
35
+
36
+ const modalStyle = {
37
+ position : 'fixed' ,
38
+ zIndex : 1040 ,
39
+ top : 0 , bottom : 0 , left : 0 , right : 0
40
+ } ;
41
+
42
+ const backdropStyle = {
43
+ ...modalStyle ,
44
+ zIndex : 'auto' ,
45
+ backgroundColor : '#000' ,
46
+ opacity : 0.5
47
+ } ;
48
+
49
+ const dialogStyle = function ( ) {
50
+ // we use some psuedo random coords so modals
51
+ // don't sit right on top of each other.
52
+ let top = 50 + rand ( ) ;
53
+ let left = 50 + rand ( ) ;
54
+
55
+ return {
56
+ position : 'absolute' ,
57
+ width : 400 ,
58
+ top : top + '%' , left : left + '%' ,
59
+ transform : `translate(-${ top } %, -${ left } %)` ,
60
+ border : '1px solid #e5e5e5' ,
61
+ backgroundColor : 'white' ,
62
+ boxShadow : '0 5px 15px rgba(0,0,0,.5)' ,
63
+ padding : 20
64
+ } ;
65
+ } ;
66
+
67
+ const Example = React . createClass ( {
68
+ getInitialState ( ) {
69
+ return { showModal : false } ;
70
+ } ,
33
71
render ( ) {
34
72
35
73
return (
@@ -39,6 +77,7 @@ const Example = React.createClass({
39
77
selectable
40
78
popup
41
79
events = { events }
80
+ onSelectEvent = { this . open }
42
81
defaultDate = { new Date ( 2015 , 3 , 1 ) }
43
82
eventPropGetter = { e => ( { className : 'hi-event' } ) }
44
83
components = { {
@@ -49,8 +88,27 @@ const Example = React.createClass({
49
88
} }
50
89
/>
51
90
</ main >
91
+ < Modal
92
+ aria-labelledby = 'modal-label'
93
+ style = { modalStyle }
94
+ backdropStyle = { backdropStyle }
95
+ show = { this . state . showModal }
96
+ onHide = { this . close }
97
+ >
98
+ < div style = { dialogStyle ( ) } >
99
+ < h4 id = 'modal-label' > Text in a modal</ h4 >
100
+ < p > Duis mollis, est non commodo luctus, nisi erat porttitor ligula.</ p >
101
+ </ div >
102
+ </ Modal >
52
103
</ div >
53
104
) ;
105
+ } ,
106
+ close ( ) {
107
+ this . setState ( { showModal : false } ) ;
108
+ } ,
109
+
110
+ open ( ) {
111
+ this . setState ( { showModal : true } ) ;
54
112
}
55
113
} ) ;
56
114
0 commit comments