Skip to content

Instantly share code, notes, and snippets.

@DrBoolean
Last active August 27, 2015 00:20
Show Gist options
  • Save DrBoolean/60a7c2625842edd0254c to your computer and use it in GitHub Desktop.
Save DrBoolean/60a7c2625842edd0254c to your computer and use it in GitHub Desktop.
Blog post about salesforce design system + react 7
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