Last active
August 27, 2015 00:20
-
-
Save DrBoolean/60a7c2625842edd0254c to your computer and use it in GitHub Desktop.
Blog post about salesforce design system + react 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Notification = function(variant) { | |
var comp = React.createClass({ | |
render: function() { | |
var theme = this.props.theme || 'info'; | |
var themeClass = 'slds-theme--' + theme; | |
var className = "slds-notify slds-notify--" + variant + ' ' + themeClass; | |
return ( | |
<div className="slds-notify-container"> | |
<div className={className} role="alert"> | |
<span className="slds-assistive-text">{theme}</span> | |
<button className="slds-button slds-notify__close slds-icon--small"> | |
<svg aria-hidden="true" className="slds-button__icon slds-button__icon--inverse" dangerouslySetInnerHTML={{__html:'<use xlink:href="/assets/icons/action-sprite/svg/symbols.svg#close"></use>'}}> | |
</svg> | |
<span className="slds-assistive-text">Close</span> | |
</button> | |
{this.props.children} | |
</div> | |
</div> | |
); | |
} | |
}); | |
comp.propTypes = {theme: React.PropTypes.oneOf(['success', 'warn', 'error', 'info'])}; | |
return comp; | |
} | |
Notification.Alert = Notification('alert'); | |
Notification.Toast = Notification('toast'); | |
module.exports = Notification; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment