From c293ce051bf93a2148be502fe784a35d39024456 Mon Sep 17 00:00:00 2001 From: Donielle Berg Date: Mon, 9 Nov 2015 15:11:28 -0800 Subject: [PATCH 1/3] Restyle alert vs toast notifications --- components/SLDSModal/index.jsx | 10 ++- components/SLDSNotification/index.js | 96 +++++++++++++++------ demo/pages/HomePage/ModalSection.jsx | 23 +++-- demo/pages/HomePage/NotificationSection.jsx | 4 + 4 files changed, 99 insertions(+), 34 deletions(-) diff --git a/components/SLDSModal/index.jsx b/components/SLDSModal/index.jsx index 226c9696a4..1a71487efd 100644 --- a/components/SLDSModal/index.jsx +++ b/components/SLDSModal/index.jsx @@ -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
{this.footerComponent()} @@ -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 = (
{this.props.footer}
); } @@ -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') diff --git a/components/SLDSNotification/index.js b/components/SLDSNotification/index.js index bd34c9b099..599f326d95 100644 --- a/components/SLDSNotification/index.js +++ b/components/SLDSNotification/index.js @@ -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 ; + 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 ; + } + } + + 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 } } @@ -39,28 +60,47 @@ class SLDSNotification extends React.Component { this.setState({isOpen:false}); } + renderAlertContent(){ + if(this.props.variant === 'alert'){ + return( +

+ {this.renderIcon()} + {this.props.content} +

+ ); + } + } + + renderToastContent(){ + if(this.props.variant === 'toast'){ + return( +
+ {this.renderIcon()} +
+

{this.props.content}

+
+
+ ); + } + } + + 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(
- - {this.props.theme} - -
- {this.renderIcon()} -

{this.props.content}

-
- + {this.renderClose()} + {this.renderAlertContent()} + {this.renderToastContent()}
); @@ -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; diff --git a/demo/pages/HomePage/ModalSection.jsx b/demo/pages/HomePage/ModalSection.jsx index 2a0845dea9..1b3f859254 100644 --- a/demo/pages/HomePage/ModalSection.jsx +++ b/demo/pages/HomePage/ModalSection.jsx @@ -24,7 +24,8 @@ module.exports = React.createClass( { getInitialState () { return { - modalIsOpen: false + modalIsOpen: false, + promptIsOpen:false }; }, @@ -32,6 +33,10 @@ module.exports = React.createClass( { this.setState({modalIsOpen: true}); }, + togglePrompt () { + this.setState({promptIsOpen: !this.state.promptIsOpen}); + }, + closeModal () { this.setState({modalIsOpen: false}); }, @@ -133,10 +138,7 @@ module.exports = React.createClass( {
- + {this.getModalContent()} + + + Service Unavailable} + footer={[ ]} + > + Sit nulla est ex deserunt exercitation anim occaecat. Nostrud ullamco deserunt aute id consequat veniam incididunt duis in sint irure nisi. +
); diff --git a/demo/pages/HomePage/NotificationSection.jsx b/demo/pages/HomePage/NotificationSection.jsx index 2e58ea0262..d1acc4a3a2 100644 --- a/demo/pages/HomePage/NotificationSection.jsx +++ b/demo/pages/HomePage/NotificationSection.jsx @@ -79,6 +79,7 @@ module.exports = React.createClass( { render() { let successMsg = ['New contact added ', Sara Smith]; let errorMsg = 'There was a problem updating the record.'; + let offlineMsg = 'Sandbox: TestOrg123'; let toastStyle = { display: 'inline-block'}; return ( @@ -102,6 +103,9 @@ module.exports = React.createClass( {
{this.state.modalIsOpen ? null: }
+
+ {this.state.modalIsOpen ? null: } +
From 3d35e8b217a36904ffec504bbad7b1fac51cc1d4 Mon Sep 17 00:00:00 2001 From: Donielle Berg Date: Mon, 9 Nov 2015 15:21:28 -0800 Subject: [PATCH 2/3] Add in prompt as modal prop --- demo/pages/HomePage/ModalSection.jsx | 42 ++++++++++++++++------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/demo/pages/HomePage/ModalSection.jsx b/demo/pages/HomePage/ModalSection.jsx index 1b3f859254..b8da11f482 100644 --- a/demo/pages/HomePage/ModalSection.jsx +++ b/demo/pages/HomePage/ModalSection.jsx @@ -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'; @@ -137,7 +137,8 @@ module.exports = React.createClass( { {require("raw-loader!../../code-snippets/SLDSModal.txt")} -
+
+

Base

- - Service Unavailable} - footer={[ ]} - > - Sit nulla est ex deserunt exercitation anim occaecat. Nostrud ullamco deserunt aute id consequat veniam incididunt duis in sint irure nisi. -
+ +
+

Prompt

+ + Service Unavailable} + footer={[ ]} + > + Sit nulla est ex deserunt exercitation anim occaecat. Nostrud ullamco deserunt aute id consequat veniam incididunt duis in sint irure nisi. + +
+
); } From 2fb261ed9065c9019043a59b9dc535436c3b4c33 Mon Sep 17 00:00:00 2001 From: Donielle Berg Date: Mon, 9 Nov 2015 15:40:52 -0800 Subject: [PATCH 3/3] Update code snippets --- demo/code-snippets/SLDSModal.txt | 20 +++++++++++++------- demo/code-snippets/SLDSNotification.txt | 16 +++++++++------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/demo/code-snippets/SLDSModal.txt b/demo/code-snippets/SLDSModal.txt index b3a2a0a365..51fd2513ca 100644 --- a/demo/code-snippets/SLDSModal.txt +++ b/demo/code-snippets/SLDSModal.txt @@ -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 - - + ]} onRequestClose={this.closeModal} - > +> {this.getModalContent()} + + +Service Unavailable} + footer={[ ]} +> + Sit nulla est ex deserunt exercitation anim occaecat. Nostrud ullamco deserunt aute id consequat veniam incididunt duis in sint irure nisi. + diff --git a/demo/code-snippets/SLDSNotification.txt b/demo/code-snippets/SLDSNotification.txt index 58648ebb48..d03a1b0f8b 100644 --- a/demo/code-snippets/SLDSNotification.txt +++ b/demo/code-snippets/SLDSNotification.txt @@ -1,17 +1,19 @@ - +Alerts - + +Toasts + } + toast={} title={Lightning Design System: Style with Ease} footer={[ , - ]} - onRequestClose={this.closeModal} - > - {this.getModalContent()} + ]} + onRequestClose={this.closeModal} + > + {this.getModalContent()}