Skip to content

Add size and directional props to modal #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from Oct 12, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions components/SLDSModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import SLDSButton from '../SLDSButton';
import {Icon} from '../SLDSIcons';
import {EventUtil} from '../utils';
import SLDSSettings from '../SLDSSettings';
import cx from 'classnames';


import Modal from 'react-modal';
Expand All @@ -40,13 +41,19 @@ const customStyles = {

module.exports = React.createClass( {

propTypes: {
size: React.PropTypes.oneOf(['medium', 'large'])
},

getDefaultProps () {
return {
title:'',
isOpen:false,
content:[],
footer:[],
returnFocusTo:null
returnFocusTo:null,
size:'medium',
directional: false
};
},

Expand Down Expand Up @@ -100,8 +107,19 @@ module.exports = React.createClass( {
},

getModal() {
const modalClass = {
'slds-modal': true,
'slds-fade-in-open':this.state.revealed,
'slds-modal--large':this.props.size === 'large'
};

const footerClass = {
'slds-modal__footer': true,
'slds-modal__footer--directional': this.props.directional
};

return <div
className={'slds-modal' +(this.state.revealed?' slds-fade-in-open':'')}
className={cx(modalClass)}
style={{pointerEvents:'inherit'}}
onClick={this.closeModal}
>
Expand All @@ -126,7 +144,7 @@ module.exports = React.createClass( {
{this.props.children}

</div>
<div className='slds-modal__footer'>
<div className={cx(footerClass)}>
{this.props.footer}
</div>

Expand All @@ -136,12 +154,17 @@ module.exports = React.createClass( {
},

render() {
const overlayClasses = {
'slds-modal-backdrop': true,
'slds-modal-backdrop--open':this.state.revealed
};

return (
<Modal
isOpen={this.props.isOpen}
onRequestClose={this.closeModal}
style={customStyles}
overlayClassName={'slds-modal-backdrop'+ (this.state.revealed?' slds-modal-backdrop--open':'')} >
overlayClassName={cx(overlayClasses)} >
{this.getModal()}
</Modal>
);
Expand Down