From ea63864b33c9253b266453f8f73898d1e7ce4c17 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Tue, 12 Dec 2017 17:05:08 +0100 Subject: [PATCH] Add icons for different notification types in recent notification dropdown [SCI-1865] --- .../components/NotificationImage.jsx | 51 +++++++++++++++--- .../components/NotificationItem.jsx | 54 ++++++++++++++++++- app/javascript/src/config/constants/colors.js | 1 + .../notifications/index.json.jbuilder | 3 ++ 4 files changed, 101 insertions(+), 8 deletions(-) diff --git a/app/javascript/src/components/Navigation/components/NotificationImage.jsx b/app/javascript/src/components/Navigation/components/NotificationImage.jsx index 1d9227cb8..051ec20a9 100644 --- a/app/javascript/src/components/Navigation/components/NotificationImage.jsx +++ b/app/javascript/src/components/Navigation/components/NotificationImage.jsx @@ -1,8 +1,47 @@ import React from "react"; +import { Image } from "react-bootstrap"; +import PropTypes from "prop-types"; -export default () => -
- - - -
; +const NotificationImage = ({className, type, avatar}) => { + const delegator = { + recent_changes: ( + + ), + system_message: ( + + + + ), + deliver: ( + + + + ), + assignment: ( + + + + ) + } + return ( +
+ {delegator[type]} +
+ ); +}; + +NotificationImage.defaultProps = { + avatar: '' +}; + +NotificationImage.propTypes = { + className: PropTypes.string.isRequired, + type: PropTypes.string.isRequired, + avatar: PropTypes.string +}; + +export default NotificationImage; diff --git a/app/javascript/src/components/Navigation/components/NotificationItem.jsx b/app/javascript/src/components/Navigation/components/NotificationItem.jsx index c77c65a17..ead90128a 100644 --- a/app/javascript/src/components/Navigation/components/NotificationItem.jsx +++ b/app/javascript/src/components/Navigation/components/NotificationItem.jsx @@ -6,6 +6,12 @@ import styled from "styled-components"; import CustomNavItem from "./CustomNavItem"; import NotificationImage from "./NotificationImage"; +import { + MAIN_COLOR_BLUE, + COLOR_ORANGE, + ICON_GREEN_COLOR, + WILD_SAND_COLOR +} from "../../../config/constants/colors"; const StyledListItem = styled(CustomNavItem)` border-bottom: 1px solid #d2d2d2; @@ -13,14 +19,58 @@ const StyledListItem = styled(CustomNavItem)` padding-top: 10px; `; +const StyledNotificationImage = styled(NotificationImage)` + margin-left: 12px; + + .avatar { + top: 0px; + margin-top: 5px; + height: 45px; + width: 45px; + } + + .assignment { + background-color: ${MAIN_COLOR_BLUE}; + border-radius: 50%; + color: ${WILD_SAND_COLOR}; + display: block; + font-size: 23px; + height: 45px; + padding-top: 5px; + width: 45px; + } + + .deliver { + background-color: ${COLOR_ORANGE}; + border-radius: 50%; + color: ${WILD_SAND_COLOR}; + display: block; + font-size: 23px; + height: 45px; + padding-top: 5px; + width: 45px; + } + + .system-message { + background-color: ${ICON_GREEN_COLOR}; + border-radius: 50%; + color: ${WILD_SAND_COLOR}; + display: block; + font-size: 23px; + height: 45px; + padding-top: 8px; + width: 45px; + } +`; + const NotificationItem = ({ notification }) => { - const { title, message, created_at, type_of } = notification; + const { title, message, created_at, type_of, avatarThumb } = notification; return ( - + diff --git a/app/javascript/src/config/constants/colors.js b/app/javascript/src/config/constants/colors.js index 15e7f0471..63ea391e7 100644 --- a/app/javascript/src/config/constants/colors.js +++ b/app/javascript/src/config/constants/colors.js @@ -19,3 +19,4 @@ export const COLOR_ALTO = "#dddddd"; export const COLOR_GRAY = "#909088"; export const COLOR_ALABASTER = "#fcfcfc"; export const COLOR_APPLE_BLOSSOM = "#a94442"; +export const COLOR_ORANGE = "#ff900b"; diff --git a/app/views/client_api/notifications/index.json.jbuilder b/app/views/client_api/notifications/index.json.jbuilder index 59551b386..2a8777d23 100644 --- a/app/views/client_api/notifications/index.json.jbuilder +++ b/app/views/client_api/notifications/index.json.jbuilder @@ -4,4 +4,7 @@ json.array! notifications do |notification| json.message notification.message json.type_of notification.type_of json.created_at notification.created_at + if notification.type_of == 'recent_changes' + json.avatarThumb avatar_path(notification.generator_user, :icon_small) + end end