File tree Expand file tree Collapse file tree 6 files changed +240
-0
lines changed
Expand file tree Collapse file tree 6 files changed +240
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ const Example = React . createClass ( {
3+ getInitialState ( ) {
4+ return { show : true } ;
5+ } ,
6+
7+ toggle ( ) {
8+ this . setState ( { show : ! this . state . show } ) ;
9+ } ,
10+
11+ render ( ) {
12+ const style = {
13+ position : 'absolute' ,
14+ backgroundColor : '#EEE' ,
15+ border : '1px solid #CCC' ,
16+ borderRadius : 3 ,
17+ marginLeft : 5 ,
18+ padding : 10
19+ } ;
20+
21+ return (
22+ < div style = { { height : 100 , position : 'relative' } } >
23+ < Button ref = 'target' onClick = { this . toggle } >
24+ I am an Overlay target
25+ </ Button >
26+
27+ < Overlay
28+ show = { this . state . show }
29+ onHide = { ( ) => this . setState ( { show : false } ) }
30+ placement = "right"
31+ container = { this }
32+ target = { props => React . findDOMNode ( this . refs . target ) }
33+ >
34+ < div style = { style } >
35+ < strong > Holy guacamole!</ strong > Check this info.
36+ </ div >
37+ </ Overlay >
38+ </ div >
39+ ) ;
40+ }
41+ } ) ;
42+
43+ React . render ( < Example /> , mountNode ) ;
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import classnames from 'classnames' ;
3+
4+ class ModalBody extends React . Component {
5+ render ( ) {
6+ return (
7+ < div { ...this . props } className = { classnames ( this . props . className , this . props . modalClassName ) } >
8+ { this . props . children }
9+ </ div >
10+ ) ;
11+ }
12+ }
13+
14+ ModalBody . propTypes = {
15+ /**
16+ * A css class applied to the Component
17+ */
18+ modalClassName : React . PropTypes . string
19+ } ;
20+
21+ ModalBody . defaultProps = {
22+ modalClassName : 'modal-body'
23+ } ;
24+
25+
26+ export default ModalBody ;
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import classnames from 'classnames' ;
3+
4+
5+ class ModalFooter extends React . Component {
6+
7+ render ( ) {
8+ return (
9+ < div { ...this . props } className = { classnames ( this . props . className , this . props . modalClassName ) } >
10+ { this . props . children }
11+ </ div >
12+ ) ;
13+ }
14+ }
15+
16+ ModalFooter . propTypes = {
17+ /**
18+ * A css class applied to the Component
19+ */
20+ modalClassName : React . PropTypes . string
21+ } ;
22+
23+ ModalFooter . defaultProps = {
24+ modalClassName : 'modal-footer'
25+ } ;
26+
27+ export default ModalFooter ;
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import classnames from 'classnames' ;
3+
4+ class ModalHeader extends React . Component {
5+
6+ render ( ) {
7+ return (
8+ < div
9+ { ...this . props }
10+ className = { classnames ( this . props . className , this . props . modalClassName ) }
11+ >
12+ { this . props . closeButton &&
13+ < button
14+ className = 'close'
15+ aria-label = { this . props [ 'aria-label' ] || 'Close' }
16+ onClick = { this . props . onHide }
17+ style = { { marginTop : - 2 } }
18+ >
19+ < span aria-hidden = "true" >
20+ ×
21+ </ span >
22+ </ button >
23+ }
24+ { this . props . children }
25+ </ div >
26+ ) ;
27+ }
28+ }
29+
30+ //used in liue of parent contexts right now to auto wire the close button
31+ ModalHeader . __isModalHeader = true ;
32+
33+ ModalHeader . propTypes = {
34+ /**
35+ * A css class applied to the Component
36+ */
37+ modalClassName : React . PropTypes . string ,
38+ /**
39+ * Specify whether the Component should contain a close button
40+ */
41+ closeButton : React . PropTypes . bool ,
42+ /**
43+ * A Callback fired when the close button is clicked. If used directly inside a Modal component, the onHide will automatically
44+ * be propagated up to the parent Modal `onHide`.
45+ */
46+ onHide : React . PropTypes . func
47+ } ;
48+
49+ ModalHeader . defaultProps = {
50+ modalClassName : 'modal-header' ,
51+ closeButton : false
52+ } ;
53+
54+
55+ export default ModalHeader ;
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import classnames from 'classnames' ;
3+
4+ class ModalTitle extends React . Component {
5+
6+ render ( ) {
7+ return (
8+ < h4 { ...this . props } className = { classnames ( this . props . className , 'modal-title' ) } >
9+ { this . props . children }
10+ </ h4 >
11+ ) ;
12+ }
13+ }
14+
15+ ModalTitle . propTypes = {
16+ /**
17+ * A css class applied to the Component
18+ */
19+ modalClassName : React . PropTypes . string
20+ } ;
21+
22+ ModalTitle . defaultProps = {
23+ modalClassName : 'modal-title'
24+ } ;
25+
26+ export default ModalTitle ;
Original file line number Diff line number Diff line change 1+ /*eslint-disable object-shorthand, react/prop-types */
2+ import React from 'react' ;
3+ import Portal from './Portal' ;
4+ import Position from './Position' ;
5+ import RootCloseWrapper from './RootCloseWrapper' ;
6+
7+ class Overlay extends React . Component {
8+
9+ constructor ( props , context ) {
10+ super ( props , context ) ;
11+ }
12+
13+ render ( ) {
14+ let {
15+ container
16+ , containerPadding
17+ , target
18+ , placement
19+ , rootClose
20+ , ...props } = this . props ;
21+
22+ let positionedChild = (
23+ < Position { ...{ container, containerPadding, target, placement } } >
24+ { this . props . children }
25+ </ Position >
26+ ) ;
27+
28+ if ( rootClose ) {
29+ positionedChild = (
30+ < RootCloseWrapper onRootClose = { this . props . onHide } >
31+ { positionedChild }
32+ </ RootCloseWrapper >
33+ ) ;
34+ }
35+
36+ return (
37+ < Portal container = { container } rootClose = { rootClose } onRootClose = { this . props . onHide } >
38+ { props . show &&
39+ positionedChild
40+ }
41+ </ Portal >
42+ ) ;
43+ }
44+ }
45+
46+ Overlay . propTypes = {
47+ ...Portal . propTypes ,
48+ ...Position . propTypes ,
49+ /**
50+ * Set the visibility of the Overlay
51+ */
52+ show : React . PropTypes . bool ,
53+ /**
54+ * Specify whether the overlay should trigger onHide when the user clicks outside the overlay
55+ */
56+ rootClose : React . PropTypes . bool ,
57+ /**
58+ * A Callback fired by the Overlay when it wishes to be hidden.
59+ */
60+ onHide : React . PropTypes . func
61+ } ;
62+
63+ export default Overlay ;
You can’t perform that action at this time.
0 commit comments