From 80edf4a693f4a861fc8c26b9f02452eedf744547 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Wed, 3 Aug 2016 15:32:04 +0300 Subject: [PATCH] Added Alert component --- frontend/components/Alert/Alert.js | 35 ++++++++++++++++++++++++++++ frontend/components/Alert/Alert.scss | 28 ++++++++++++++++++++++ frontend/components/Alert/index.js | 2 ++ frontend/components/Layout/Layout.js | 21 +++++++++-------- package.json | 1 + 5 files changed, 77 insertions(+), 10 deletions(-) create mode 100644 frontend/components/Alert/Alert.js create mode 100644 frontend/components/Alert/Alert.scss create mode 100644 frontend/components/Alert/index.js diff --git a/frontend/components/Alert/Alert.js b/frontend/components/Alert/Alert.js new file mode 100644 index 00000000..69e0863c --- /dev/null +++ b/frontend/components/Alert/Alert.js @@ -0,0 +1,35 @@ +import React, { PropTypes } from 'react'; + +import { Flex } from 'reflexbox'; + +import styles from './Alert.scss'; +import classNames from 'classnames/bind'; +const cx = classNames.bind(styles); + +class Alert extends React.Component { + static propTypes = { + children: PropTypes.node.isRequired, + danger: PropTypes.bool, + warning: PropTypes.bool, + success: PropTypes.bool, + info: PropTypes.bool, + offline: PropTypes.bool, + } + + render() { + let alertType; + if (this.props.danger) alertType = 'danger'; + if (this.props.warning) alertType = 'warning'; + if (this.props.success) alertType = 'success'; + if (this.props.offline) alertType = 'offline'; + if (!alertType) alertType = 'info'; // default + + return ( + + { this.props.children } + + ); + } +} + +export default Alert; diff --git a/frontend/components/Alert/Alert.scss b/frontend/components/Alert/Alert.scss new file mode 100644 index 00000000..7a1570d9 --- /dev/null +++ b/frontend/components/Alert/Alert.scss @@ -0,0 +1,28 @@ +@import '~styles/constants.scss'; + +.container { + height: $headerHeight; + color: #ffffff; + font-size: 14px; + line-height: 1; +} + +.danger { + background-color: #f04124; +} + +.warning { + background-color: #f08a24; +} + +.success { + background-color: #43AC6A; +} + +.info { + background-color: #a0d3e8; +} + +.offline { + background-color: #000000; +} diff --git a/frontend/components/Alert/index.js b/frontend/components/Alert/index.js new file mode 100644 index 00000000..08bde8f9 --- /dev/null +++ b/frontend/components/Alert/index.js @@ -0,0 +1,2 @@ +import Alert from './Alert'; +export default Alert; diff --git a/frontend/components/Layout/Layout.js b/frontend/components/Layout/Layout.js index f4a8f551..9653a132 100644 --- a/frontend/components/Layout/Layout.js +++ b/frontend/components/Layout/Layout.js @@ -8,6 +8,7 @@ import _ from 'lodash'; import DropdownMenu, { MenuItem } from 'components/DropdownMenu'; import Flex from 'components/Flex'; import LoadingIndicator from 'components/LoadingIndicator'; +import Alert from 'components/Alert'; import { Avatar } from 'rebass'; import styles from './Layout.scss'; @@ -17,6 +18,7 @@ const cx = classNames.bind(styles); @observer(['user']) class Layout extends React.Component { static propTypes = { + children: React.PropTypes.node, actions: React.PropTypes.node, title: React.PropTypes.node, titleText: React.PropTypes.node, @@ -48,16 +50,15 @@ class Layout extends React.Component { return (
{ this.props.loading ? ( ) : null } +
{ user.team.name } @@ -76,17 +77,17 @@ class Layout extends React.Component { className={ styles.search } title="Search (/)" > - + Search
) } - - }> + /> } + > Logout diff --git a/package.json b/package.json index 1b98a1e0..f0346afd 100644 --- a/package.json +++ b/package.json @@ -102,6 +102,7 @@ "react-keydown": "^1.6.1", "react-router": "2.5.1", "rebass": "0.2.6", + "reflexbox": "^2.0.0", "safestart": "0.8.0", "sass-loader": "4.0.0", "sequelize": "3.23.4",