11import React from "react" ;
2- import { Typography , withStyles } from "@material-ui/core" ;
2+ import { Button , withStyles } from "@material-ui/core" ;
33import {
44 NotificationsNone as NotificationsIcon ,
55 ThumbUp as ThumbUpIcon ,
66 ShoppingCart as ShoppingCartIcon ,
7- LocalOffer as TicketIcon
7+ LocalOffer as TicketIcon ,
8+ BusinessCenter as DeliveredIcon ,
9+ SmsFailed as FeedbackIcon ,
10+ DiscFull as DiscIcon ,
11+ Email as MessageIcon ,
12+ Report as ReportIcon ,
13+ Error as DefenceIcon ,
14+ AccountBox as CustomerIcon ,
15+ Done as ShippedIcon ,
16+ Publish as UploadIcon ,
817} from "@material-ui/icons" ;
18+ import classnames from "classnames" ;
19+ import tinycolor from 'tinycolor2' ;
20+
21+ import { Typography } from "../Wrappers" ;
922
1023const typesIcons = {
1124 "e-commerce" : < ShoppingCartIcon /> ,
1225 notification : < NotificationsIcon /> ,
1326 offer : < TicketIcon /> ,
14- info : < ThumbUpIcon />
27+ info : < ThumbUpIcon /> ,
28+ message : < MessageIcon /> ,
29+ feedback : < FeedbackIcon /> ,
30+ customer : < CustomerIcon /> ,
31+ shipped : < ShippedIcon /> ,
32+ delivered : < DeliveredIcon /> ,
33+ defence : < DefenceIcon /> ,
34+ report : < ReportIcon /> ,
35+ upload : < UploadIcon /> ,
36+ disc : < DiscIcon /> ,
1537} ;
1638
1739const getIconByType = ( type = "offer" ) => typesIcons [ type ] ;
1840
19- const Notification = ( { classes, theme, ...props } ) => {
41+ const Notification = ( { classes, theme, variant , ...props } ) => {
2042 const icon = getIconByType ( props . type ) ;
2143 const iconWithStyles = React . cloneElement ( icon , {
2244 classes : {
2345 root : classes . notificationIcon
2446 } ,
2547 style : {
26- color : theme . palette [ props . color ] && theme . palette [ props . color ] . main ,
48+ color : variant !== "contained" && theme . palette [ props . color ] && theme . palette [ props . color ] . main
2749 }
2850 } ) ;
2951
3052 return (
31- < div className = { classes . notificationContainer } >
32- { iconWithStyles }
33- < Typography variant = "inherit" > { props . message } </ Typography >
53+ < div
54+ className = { classnames ( classes . notificationContainer , props . className , {
55+ [ classes . notificationContained ] : variant === "contained" ,
56+ [ classes . notificationContainedShadowless ] : props . shadowless ,
57+ } ) }
58+ style = { {
59+ backgroundColor :
60+ variant === "contained" &&
61+ theme . palette [ props . color ] &&
62+ theme . palette [ props . color ] . main
63+ } }
64+ >
65+ < div
66+ className = { classnames ( classes . notificationIconContainer , {
67+ [ classes . notificationIconContainerContained ] : variant === "contained" ,
68+ [ classes . notificationIconContainerRounded ] : variant === "rounded" ,
69+ }
70+ ) }
71+ style = { {
72+ backgroundColor : variant === "rounded" &&
73+ theme . palette [ props . color ] &&
74+ tinycolor ( theme . palette [ props . color ] . main ) . setAlpha ( 0.15 ) . toRgbString ( )
75+ } }
76+ > { iconWithStyles } </ div >
77+ < div className = { classes . messageContainer } >
78+ < Typography
79+ className = { classnames ( {
80+ [ classes . containedTypography ] : variant === "contained"
81+ } ) }
82+ variant = { props . typographyVariant }
83+ size = { variant !== "contained" && ! props . typographyVariant && "md" }
84+ >
85+ { props . message }
86+ </ Typography >
87+ { props . extraButton && props . extraButtonClick && ( < Button onClick = { props . extraButtonClick } disableRipple className = { classes . extraButton } > { props . extraButton } </ Button > ) }
88+ </ div >
3489 </ div >
3590 ) ;
3691} ;
@@ -40,10 +95,45 @@ const styles = theme => ({
4095 display : "flex" ,
4196 alignItems : "center"
4297 } ,
43- notificationIcon : {
98+ notificationContained : {
99+ borderRadius : 45 ,
100+ height : 45 ,
101+ boxShadow : theme . customShadows . widgetDark
102+ } ,
103+ notificationContainedShadowless : {
104+ boxShadow : 'none' ,
105+ } ,
106+ notificationIconContainer : {
107+ width : 45 ,
108+ height : 45 ,
109+ borderRadius : 45 ,
110+ display : 'flex' ,
111+ alignItems : 'center' ,
112+ justifyContent : 'center' ,
113+ fontSize : 24 ,
114+ } ,
115+ notificationIconContainerContained : {
44116 fontSize : 18 ,
45- marginRight : theme . spacing . unit * 2
46- }
117+ color : '#FFFFFF80' ,
118+ } ,
119+ notificationIconContainerRounded : {
120+ marginRight : theme . spacing . unit * 2 ,
121+ } ,
122+ containedTypography : {
123+ color : "white"
124+ } ,
125+ messageContainer : {
126+ display : 'flex' ,
127+ alignItems : 'center' ,
128+ justifyContent : 'space-between' ,
129+ flexGrow : 1 ,
130+ } ,
131+ extraButton : {
132+ color : 'white' ,
133+ '&:hover, &:focus' : {
134+ background : 'transparent' ,
135+ }
136+ } ,
47137} ) ;
48138
49139export default withStyles ( styles , { withTheme : true } ) ( Notification ) ;
0 commit comments