Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 6 additions & 4 deletions components/SLDSModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ module.exports = React.createClass( {
const modalClass = {
'slds-modal': true,
'slds-fade-in-open':this.state.revealed,
'slds-modal--large':this.props.size === 'large'
'slds-modal--large':this.props.size === 'large',
'slds-modal--prompt':this.isPrompt()
};

return <div
Expand All @@ -135,7 +136,6 @@ module.exports = React.createClass( {

{this.props.children}

{this.isPrompt() ? this.props.footer : null}
</div>

{this.footerComponent()}
Expand Down Expand Up @@ -167,12 +167,13 @@ module.exports = React.createClass( {

const footerClass = {
'slds-modal__footer': true,
'slds-modal__footer--directional': this.props.directional
'slds-modal__footer--directional': this.props.directional,
'slds-theme--default': this.isPrompt()
};

const hasFooter = this.props.footer && this.props.footer.length > 0;

if (!this.isPrompt() && hasFooter ) {
if (hasFooter ) {
footer = (<div className={cx(footerClass)}>{this.props.footer}</div>);
}

Expand All @@ -191,6 +192,7 @@ module.exports = React.createClass( {

if (this.isPrompt()) {
headerClasses.push(`slds-theme--${this.props.prompt}`);
headerClasses.push('slds-theme--alert-texture');
headingClasses.push('slds-text-heading--small');
} else {
headingClasses.push('slds-text-heading--medium')
Expand Down
96 changes: 71 additions & 25 deletions components/SLDSNotification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,38 @@ class SLDSNotification extends React.Component {
this.state = { isOpen: true };
}

getClassName() {
return classNames(this.props.className, 'slds-notify ', {
[`slds-notify--${this.props.variant}`]: this.props.variant,
[`slds-theme--${this.props.theme}`]: this.props.theme,
[`slds-theme--alert-texture-animated`]: this.props.texture,
});
}

renderIcon(){
if(this.props.icon){
return <Icon category='utility' name={this.props.icon} size='small' className='slds-m-right--x-small slds-col slds-no-flex' />;
let classes = '';
if(this.props.variant === 'alert') {
classes = 'slds-m-right--x-small';
}
else if(this.props.variant === 'toast') {
classes = 'slds-m-right--small slds-col slds-no-flex';
}
return <Icon category='utility' name={this.props.icon} size='small' className={classes} />;
}
}

renderClose(){
let that = this;
if(this.props.dismissible){
let size = '';
if(this.props.variant === 'alert') {
size = 'medium';
}
else if(this.props.variant === 'toast') {
size = 'large';
}
return <SLDSButton
label='Dismiss Notification'
variant='icon'
iconName='close'
iconSize={size}
inverse={true}
className='slds-button slds-notify__close'
onClick={that.onDismiss.bind(that)}
/>
}
}

Expand All @@ -39,28 +60,47 @@ class SLDSNotification extends React.Component {
this.setState({isOpen:false});
}

renderAlertContent(){
if(this.props.variant === 'alert'){
return(
<h2>
{this.renderIcon()}
{this.props.content}
</h2>
);
}
}

renderToastContent(){
if(this.props.variant === 'toast'){
return(
<section className="notify__content slds-grid">
{this.renderIcon()}
<div className="slds-col slds-align-middle">
<h2 className="slds-text-heading--small ">{this.props.content}</h2>
</div>
</section>
);
}
}

getClassName() {
return classNames(this.props.className, 'slds-notify ', {
[`slds-notify--${this.props.variant}`]: this.props.variant,
[`slds-theme--${this.props.theme}`]: this.props.theme,
[`slds-theme--alert-texture-animated`]: this.props.texture,
});
}

render(){
if(this.state.isOpen){
return(
<div className="slds-notify-container">
<div className={this.getClassName()} role="alert">
<SLDSButton
label='Dismiss Notification'
variant='icon'
iconName='close'
iconSize='large'
inverse={true}
className='slds-button slds-notify__close'
onClick={this.onDismiss.bind(this)}
/>

<span className="slds-assistive-text">{this.props.theme}</span>

<section className="notify__content slds-grid">
{this.renderIcon()}
<h2 className="slds-col slds-align-middle slds-text-heading--small">{this.props.content}</h2>
</section>

{this.renderClose()}
{this.renderAlertContent()}
{this.renderToastContent()}
</div>
</div>
);
Expand All @@ -75,7 +115,13 @@ SLDSNotification.propTypes = {
variant: React.PropTypes.oneOf(['alert', 'toast']),
theme: React.PropTypes.oneOf(['success', 'warning', 'error', 'offline']),
texture: React.PropTypes.bool,
dismissible: React.PropTypes.bool,
onDismiss: React.PropTypes.func,
};

SLDSNotification.defaultProps = {
dismissible: true
};

module.exports = SLDSNotification;

20 changes: 13 additions & 7 deletions demo/code-snippets/SLDSModal.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ Default Props Prop Values
* directional=false [true, false] If true, aligns buttons left and right in Footer
* tagline='' Optional tagline underneath Header title

<SLDSButton
label='Open Modal'
variant='brand'
onClick={this.openModal}
/>

<SLDSButton label='Open Modal' variant='brand' onClick={this.openModal} />
<SLDSModal
directional={true}
isOpen={this.state.modalIsOpen}
Expand All @@ -20,6 +15,17 @@ Default Props Prop Values
<SLDSButton key='nextBtn' label='Next' variant='brand' onClick={this.handleSubmitModal} />
]}
onRequestClose={this.closeModal}
>
>
{this.getModalContent()}
</SLDSModal>

<SLDSButton label='Open Prompt' variant='neutral' onClick={this.togglePrompt} />
<SLDSModal
prompt='error'
size='medium'
isOpen={this.state.promptIsOpen}
title={<span>Service Unavailable</span>}
footer={[ <SLDSButton label='Got it' variant='neutral' onClick={this.togglePrompt} /> ]}
>
Sit nulla est ex deserunt exercitation anim occaecat. Nostrud ullamco deserunt aute id consequat veniam incididunt duis in sint irure nisi.
</SLDSModal>
16 changes: 9 additions & 7 deletions demo/code-snippets/SLDSNotification.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@

Alerts
<SLDSNotification variant='alert' theme='success' icon='notification' texture={true} content={successMsg} onDismiss={this.dismissToast} />
<SLDSNotification variant='alert' theme='error' icon='warning' texture={true} content={errorMsg} onDismiss={this.dismissToast} />
<SLDSNotification variant='toast' theme='success' icon='notification' content={successMsg} />
<SLDSNotification variant='alert' icon='user' content={offlineMsg} dismissible={false} onDismiss={this.dismissToast} />

Toasts
<SLDSNotification variant='toast' theme='success' icon='notification' content={successMsg} onDismiss={this.dismissToast} />
<SLDSModal
isOpen={this.state.modalIsOpen}
toast={<SLDSNotification variant='toast' theme='error' icon='warning' texture={true} content={errorMessage} />}
toast={<SLDSNotification variant='toast' theme='error' icon='warning' content={errorMsg} onDismiss={this.dismissToast} />}
title={<span>Lightning Design System: Style with Ease</span>}
footer={[
<SLDSButton key='cancelBtn' label='Cancel' variant='neutral' onClick={this.closeModal} />,
<SLDSButton key='saveBtn' label='Save' variant='brand' onClick={this.handleSubmitModal} />
]}
onRequestClose={this.closeModal}
>
{this.getModalContent()}
]}
onRequestClose={this.closeModal}
>
{this.getModalContent()}
</SLDSModal>
45 changes: 32 additions & 13 deletions demo/pages/HomePage/ModalSection.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
Copyright (c) 2015, salesforce.com, inc. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
Copyright (c) 2015, salesforce.com, inc. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

'use strict';

Expand All @@ -24,14 +24,19 @@ module.exports = React.createClass( {

getInitialState () {
return {
modalIsOpen: false
modalIsOpen: false,
promptIsOpen:false
};
},

openModal () {
this.setState({modalIsOpen: true});
},

togglePrompt () {
this.setState({promptIsOpen: !this.state.promptIsOpen});
},

closeModal () {
this.setState({modalIsOpen: false});
},
Expand Down Expand Up @@ -132,11 +137,9 @@ module.exports = React.createClass( {
{require("raw-loader!../../code-snippets/SLDSModal.txt")}
</PrismCode>

<div className='slds-p-vertical--large'>
<SLDSButton
label='Open Modal'
variant='brand'
onClick={this.openModal} />
<div className='slds-p-vertical--medium'>
<h4 className="slds-text-heading--small ">Base</h4>
<SLDSButton label='Open Modal' variant='brand' onClick={this.openModal} />
<SLDSModal
size='medium'
directional={true}
Expand All @@ -150,7 +153,23 @@ module.exports = React.createClass( {
onRequestClose={this.closeModal}>
{this.getModalContent()}
</SLDSModal>

</div>

<div className='slds-p-vertical--medium'>
<h4 className="slds-text-heading--small">Prompt</h4>
<SLDSButton label='Open Prompt' variant='neutral' onClick={this.togglePrompt} />
<SLDSModal
prompt='error'
size='medium'
isOpen={this.state.promptIsOpen}
title={<span>Service Unavailable</span>}
footer={[ <SLDSButton label='Got it' variant='neutral' onClick={this.togglePrompt} /> ]}
>
Sit nulla est ex deserunt exercitation anim occaecat. Nostrud ullamco deserunt aute id consequat veniam incididunt duis in sint irure nisi.
</SLDSModal>
</div>

</div>
);
}
Expand Down
4 changes: 4 additions & 0 deletions demo/pages/HomePage/NotificationSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ module.exports = React.createClass( {
render() {
let successMsg = ['New contact added ', <a href="#" key="0123">Sara Smith</a>];
let errorMsg = 'There was a problem updating the record.';
let offlineMsg = 'Sandbox: TestOrg123';
let toastStyle = { display: 'inline-block'};
return (

Expand All @@ -102,6 +103,9 @@ module.exports = React.createClass( {
<div className="slds-p-bottom--small">
{this.state.modalIsOpen ? null: <SLDSNotification variant='alert' theme='error' icon='warning' texture={true} content={errorMsg} onDismiss={this.dismissToast} />}
</div>
<div className="slds-p-bottom--small">
{this.state.modalIsOpen ? null: <SLDSNotification variant='alert' icon='user' content={offlineMsg} dismissible={false} onDismiss={this.dismissToast} />}
</div>
</div>
</div>

Expand Down