Use ClassNames in Snackbar

old
Javi Velasco 2015-11-28 20:15:26 +01:00
parent e328ffc5dd
commit 95162002de
5 changed files with 22 additions and 34 deletions

View File

@ -130,21 +130,19 @@
}
.neutral:not([disabled]) {
&:not(.inverse) {
&.raised, &.floating {
color: $button-neutral-color-contrast;
background-color: $button-neutral-color;
}
&.flat, &.toggle {
color: $button-neutral-color-contrast;
&:focus:not(:active) {
background: $button-neutral-color-hover;
}
}
&.flat:hover {
&.raised, &.floating {
color: $button-neutral-color-contrast;
background-color: $button-neutral-color;
}
&.flat, &.toggle {
color: $button-neutral-color-contrast;
&:focus:not(:active) {
background: $button-neutral-color-hover;
}
}
&.flat:hover {
background: $button-neutral-color-hover;
}
&.inverse {
&.raised, &.floating {

View File

@ -1,4 +1,5 @@
import React from 'react';
import ClassNames from 'classnames';
import Button from '../button';
import FontIcon from '../font_icon';
import Overlay from '../overlay';
@ -25,29 +26,18 @@ class Snackbar extends React.Component {
}
}
renderButton () {
if (this.props.action) {
return (
<Button
className={style.button}
label={this.props.action}
onClick={this.props.onClick}
/>
);
}
}
render () {
let className = `${style.root} ${style[this.props.type]}`;
if (this.props.active) className += ` ${style.active}`;
if (this.props.className) className += ` ${this.props.className}`;
const {action, active, icon, label, onClick, type } = this.props;
const className = ClassNames([style.root, style[type]], {
[style.active]: active
}, this.props.className);
return (
<Overlay active={this.props.active} opacity={0}>
<Overlay active={active} opacity={0}>
<div data-react-toolbox='snackbar' className={className}>
{this.props.icon ? <FontIcon value={this.props.icon} className={style.icon} /> : null}
<span className={style.label}>{this.props.label}</span>
{this.renderButton()}
{icon ? <FontIcon value={icon} className={style.icon} /> : null}
<span className={style.label}>{label}</span>
{action ? <Button className={style.button} label={action} onClick={onClick}/> : null}
</div>
</Overlay>
);

View File

@ -21,7 +21,7 @@ class SnackbarTest extends React.Component {
<Button label='Show Snackbar' raised onClick={this.handleClick} />
<Snackbar
action='Nice'
icon='question-answer'
icon='question_answer'
label='A new developer started using React Toolbox'
onClick={this.handleSnackbarClick}
ref='snackbar'

View File

@ -24,7 +24,7 @@ class SnackbarTest extends React.Component {
<Snackbar
action='Dismiss'
active={this.state.active}
icon='question-answer'
icon='question_answer'
label='Snackbar action cancel'
timeout={2000}
onClick={this.handleSnackbarClick}

View File

@ -28,7 +28,7 @@ class SnackbarTest extends React.Component {
<Snackbar
action='Hide'
active={this.state.active}
icon='question-answer'
icon='question_answer'
label='Snackbar action cancel'
timeout={2000}
onClick={this.handleSnackbarClick}