summaryrefslogtreecommitdiffstats
path: root/components/ErrorMessage.js
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2017-09-21 15:39:12 -0400
committerWes Bos <wesbos@gmail.com>2017-09-21 15:39:12 -0400
commit3b45dd7b593825721ec9ee9f6a49c732601b1ae0 (patch)
treea2e8e73d6b6b6bc32eda2bb79af817397e4304f5 /components/ErrorMessage.js
parent1450e579c67e3d969cb099dfe6c1cefd1e313fb5 (diff)
Cha Ching
Diffstat (limited to 'components/ErrorMessage.js')
-rw-r--r--components/ErrorMessage.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/components/ErrorMessage.js b/components/ErrorMessage.js
new file mode 100644
index 0000000..12de51d
--- /dev/null
+++ b/components/ErrorMessage.js
@@ -0,0 +1,32 @@
+import styled from 'styled-components';
+import React from 'react';
+
+import PropTypes from 'prop-types';
+
+const StyledError = styled.div`
+ background: pink;
+ border: 2px solid red;
+ padding: 20px;
+ display: flex;
+ p {
+ margin: 0;
+ flex: 1 0 auto;
+ }
+`;
+
+const DisplayError = props => {
+ if (!props.error || !props.error.message) return null;
+ return (
+ <StyledError>
+ <p>{props.error.message}</p>
+ <button onClick={props.onButtonClick}>&times;</button>
+ </StyledError>
+ );
+};
+
+DisplayError.propTypes = {
+ error: PropTypes.object.isRequired,
+ onButtonClick: PropTypes.func.isRequired,
+};
+
+export default DisplayError;