react-toolbox/spec/components/snackbar.js

44 lines
981 B
JavaScript
Raw Normal View History

2015-10-20 06:25:35 +03:00
import React from 'react';
2015-10-20 18:27:22 +03:00
import Button from '../../components/button';
2015-10-20 06:25:35 +03:00
import Snackbar from '../../components/snackbar';
2015-10-22 02:31:17 +03:00
class SnackbarTest extends React.Component {
state = {
2017-01-26 20:05:32 +03:00
active: false,
};
handleSnackbarClick = () => {
2017-01-26 20:05:32 +03:00
this.setState({ active: false });
2015-11-12 07:25:14 +03:00
};
handleSnackbarTimeout = () => {
2017-01-26 20:05:32 +03:00
this.setState({ active: false });
2015-11-12 07:25:14 +03:00
};
handleClick = () => {
2017-01-26 20:05:32 +03:00
this.setState({ active: true });
2015-10-22 02:31:17 +03:00
};
2015-10-20 18:27:22 +03:00
2017-01-26 20:05:32 +03:00
render() {
2015-10-20 06:25:35 +03:00
return (
<section>
<h5>Snackbars & Toasts</h5>
<p>lorem ipsum...</p>
2017-01-26 20:05:32 +03:00
<Button label="Show snackbar" primary raised onClick={this.handleClick} />
2015-10-20 18:27:22 +03:00
<Snackbar
2017-01-26 20:05:32 +03:00
action="Hide"
2015-11-12 07:25:14 +03:00
active={this.state.active}
timeout={2000}
2015-11-12 07:25:14 +03:00
onClick={this.handleSnackbarClick}
onTimeout={this.handleSnackbarTimeout}
2017-01-26 20:05:32 +03:00
type="warning"
2016-10-08 13:27:57 +03:00
>
Snackbar action <strong>cancel</strong>
</Snackbar>
2015-10-20 06:25:35 +03:00
</section>
);
}
2015-10-21 05:58:11 +03:00
}
2015-10-22 02:31:17 +03:00
export default SnackbarTest;