Global error messages (#261)

* Remove global error rendering

* Added basic Toasts

* Auto-close toasts

* 💚

* Flow fix, more reliable CI
This commit is contained in:
Tom Moor
2017-09-23 18:58:34 -04:00
committed by GitHub
parent aa38510abc
commit 53c0c9180b
9 changed files with 136 additions and 22 deletions

View File

@ -0,0 +1,39 @@
// @flow
import React, { Component } from 'react';
import { inject, observer } from 'mobx-react';
import styled from 'styled-components';
import { layout } from 'styles/constants';
import Toast from './components/Toast';
@observer class Toasts extends Component {
handleClose = index => {
this.props.errors.remove(index);
};
render() {
const { errors } = this.props;
return (
<List>
{errors.data.map((error, index) => (
<Toast
key={index}
onRequestClose={this.handleClose.bind(this, index)}
message={error}
/>
))}
</List>
);
}
}
const List = styled.ol`
position: fixed;
left: ${layout.hpadding};
bottom: ${layout.vpadding};
list-style: none;
margin: 0;
padding: 0;
`;
export default inject('errors')(Toasts);