Skip to content

Commit 15a797a

Browse files
committed
Add mail menu
1 parent e450396 commit 15a797a

File tree

3 files changed

+229
-57
lines changed

3 files changed

+229
-57
lines changed

src/components/Header/HeaderView.js

Lines changed: 190 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
InputBase,
88
Menu,
99
MenuItem,
10-
Typography,
1110
Fab,
1211
withStyles
1312
} from "@material-ui/core";
@@ -17,36 +16,67 @@ import {
1716
NotificationsNone as NotificationsIcon,
1817
Person as AccountIcon,
1918
Search as SearchIcon,
20-
Navigation as NavigationIcon,
21-
ArrowBack as ArrowBackIcon,
19+
Send as SendIcon,
20+
ArrowBack as ArrowBackIcon
2221
} from "@material-ui/icons";
2322
import { fade } from "@material-ui/core/styles/colorManipulator";
2423
import classNames from "classnames";
2524

26-
import { Badge } from "../Wrappers";
27-
import Notification from '../Notification';
25+
import { Badge, Typography } from "../Wrappers";
26+
import Notification from "../Notification";
27+
import UserAvatar from "../UserAvatar";
2828

29-
const mailNotifications = [
30-
{ id: 0, avatar: "", name: "Jane Hew", message: "Hey! How is it going?" },
29+
const messages = [
30+
{
31+
id: 0,
32+
variant: "warning",
33+
name: "Jane Hew",
34+
message: "Hey! How is it going?",
35+
time: "9:32"
36+
},
3137
{
3238
id: 1,
33-
avatar: "",
34-
name: "Alies Rumiancaŭ",
35-
message: "I will definitely buy this template"
39+
variant: "success",
40+
name: "Lloyd Brown",
41+
message: "Check out my new Dashboard",
42+
time: "9:18"
3643
},
3744
{
3845
id: 2,
39-
avatar: "",
40-
name: "Michał Rumiancaŭ",
41-
message: "Is it really Lore ipsum? Lore ..."
46+
variant: "primary",
47+
name: "Mark Winstein",
48+
message: "I want rearrange the appointment",
49+
time: "9:15"
50+
},
51+
{
52+
id: 3,
53+
variant: "secondary",
54+
name: "Liana Dutti",
55+
message: "Good news from sale department",
56+
time: "9:09"
4257
}
4358
];
4459

4560
const notifications = [
46-
{ id: 0, color: 'warning', message: "Check out this awesome ticket" },
47-
{ id: 1, color: 'success', type: 'info', message: "What is the best way to get ..." },
48-
{ id: 2, color: 'secondary', type: 'notification', message: "This is just a simple notification" },
49-
{ id: 3, color: 'primary', type: 'e-commerce', message: "12 new orders has arrived today" },
61+
{ id: 0, color: "warning", message: "Check out this awesome ticket" },
62+
{
63+
id: 1,
64+
color: "success",
65+
type: "info",
66+
message: "What is the best way to get ..."
67+
},
68+
{
69+
id: 2,
70+
color: "secondary",
71+
type: "notification",
72+
message: "This is just a simple notification"
73+
},
74+
{
75+
id: 3,
76+
color: "primary",
77+
type: "e-commerce",
78+
message: "12 new orders has arrived today"
79+
}
5080
];
5181

5282
const Header = ({ classes, isSidebarOpened, toggleSidebar, ...props }) => (
@@ -55,24 +85,38 @@ const Header = ({ classes, isSidebarOpened, toggleSidebar, ...props }) => (
5585
<IconButton
5686
color="inherit"
5787
onClick={toggleSidebar}
58-
className={classNames(classes.headerMenuButton, classes.headerMenuButtonCollapse)}
88+
className={classNames(
89+
classes.headerMenuButton,
90+
classes.headerMenuButtonCollapse
91+
)}
5992
>
6093
{isSidebarOpened ? (
61-
<ArrowBackIcon classes={{ root: classNames(classes.headerIcon, classes.headerIconCollapse) }} />
94+
<ArrowBackIcon
95+
classes={{
96+
root: classNames(classes.headerIcon, classes.headerIconCollapse)
97+
}}
98+
/>
6299
) : (
63-
<MenuIcon classes={{ root: classNames(classes.headerIcon, classes.headerIconCollapse) }} />
100+
<MenuIcon
101+
classes={{
102+
root: classNames(classes.headerIcon, classes.headerIconCollapse)
103+
}}
104+
/>
64105
)}
65106
</IconButton>
66-
<Typography className={classes.logotype}>
67-
Material Dashboard
68-
</Typography>
107+
<Typography className={classes.logotype}>Material Dashboard</Typography>
69108
<div className={classes.grow} />
70109
<div
71110
className={classNames(classes.search, {
72111
[classes.searchFocused]: props.isSearchOpen
73112
})}
74113
>
75-
<div className={classNames(classes.searchIcon, { [classes.searchIconOpened]: props.isSearchOpen })} onClick={props.toggleSearch}>
114+
<div
115+
className={classNames(classes.searchIcon, {
116+
[classes.searchIconOpened]: props.isSearchOpen
117+
})}
118+
onClick={props.toggleSearch}
119+
>
76120
<SearchIcon classes={{ root: classes.headerIcon }} />
77121
</div>
78122
<InputBase
@@ -107,7 +151,7 @@ const Header = ({ classes, isSidebarOpened, toggleSidebar, ...props }) => (
107151
className={classes.headerMenuButton}
108152
>
109153
<Badge
110-
badgeContent={props.isMailsUnread ? mailNotifications.length : null}
154+
badgeContent={props.isMailsUnread ? messages.length : null}
111155
color="secondary"
112156
>
113157
<MailIcon classes={{ root: classes.headerIcon }} />
@@ -129,25 +173,51 @@ const Header = ({ classes, isSidebarOpened, toggleSidebar, ...props }) => (
129173
onClose={props.closeMailMenu}
130174
MenuListProps={{ className: classes.headerMenuList }}
131175
className={classes.headerMenu}
176+
classes={{ paper: classes.profileMenu }}
132177
disableAutoFocusItem
133178
>
134-
{mailNotifications.map(mail => (
135-
<MenuItem key={mail.id} onClick={props.closeMailMenu}>
136-
<div className={classes.messageContent}>
137-
<Typography variant="subtitle2">{mail.name}</Typography>
138-
<Typography>{mail.message}</Typography>
179+
<div className={classes.profileMenuUser}>
180+
<Typography variant="h4" weight="medium">
181+
New Messages
182+
</Typography>
183+
<Typography
184+
className={classes.profileMenuLink}
185+
component="a"
186+
color="secondary"
187+
>
188+
{messages.length} New Messages
189+
</Typography>
190+
</div>
191+
{messages.map(message => (
192+
<MenuItem key={message.id} className={classes.messageNotification}>
193+
<div className={classes.messageNotificationSide}>
194+
<UserAvatar color={message.variant} name={message.name} />
195+
<Typography size="sm" color="textSecondary">
196+
{message.time}
197+
</Typography>
198+
</div>
199+
<div
200+
className={classNames(
201+
classes.messageNotificationSide,
202+
classes.messageNotificationBodySide
203+
)}
204+
>
205+
<Typography weight="medium" gutterBottom>
206+
{message.name}
207+
</Typography>
208+
<Typography color="textSecondary">{message.message}</Typography>
139209
</div>
140210
</MenuItem>
141211
))}
142212
<Fab
143213
variant="extended"
144-
size="small"
214+
// size="large"
145215
color="primary"
146216
aria-label="Add"
147-
className={classes.headerMenuButton}
217+
className={classes.sendMessageButton}
148218
>
149-
<NavigationIcon />
150-
New Message
219+
Send New Message
220+
<SendIcon className={classes.sendButtonIcon} />
151221
</Fab>
152222
</Menu>
153223
<Menu
@@ -178,14 +248,50 @@ const Header = ({ classes, isSidebarOpened, toggleSidebar, ...props }) => (
178248
disableAutoFocusItem
179249
>
180250
<div className={classes.profileMenuUser}>
181-
<Typography variant="h6">John Smith</Typography>
182-
<Typography className={classes.profileMenuLink} component="a" color="primary" href="https://flatlogic.com">Flalogic.com</Typography>
251+
<Typography variant="h4" weight="medium">
252+
John Smith
253+
</Typography>
254+
<Typography
255+
className={classes.profileMenuLink}
256+
component="a"
257+
color="primary"
258+
href="https://flatlogic.com"
259+
>
260+
Flalogic.com
261+
</Typography>
183262
</div>
184-
<MenuItem className={classNames(classes.profileMenuItem, classes.headerMenuItem)}><AccountIcon className={classes.profileMenuIcon}/> Profile</MenuItem>
185-
<MenuItem className={classNames(classes.profileMenuItem, classes.headerMenuItem)}><AccountIcon className={classes.profileMenuIcon}/> Tasks</MenuItem>
186-
<MenuItem className={classNames(classes.profileMenuItem, classes.headerMenuItem)}><AccountIcon className={classes.profileMenuIcon}/> Messages</MenuItem>
263+
<MenuItem
264+
className={classNames(
265+
classes.profileMenuItem,
266+
classes.headerMenuItem
267+
)}
268+
>
269+
<AccountIcon className={classes.profileMenuIcon} /> Profile
270+
</MenuItem>
271+
<MenuItem
272+
className={classNames(
273+
classes.profileMenuItem,
274+
classes.headerMenuItem
275+
)}
276+
>
277+
<AccountIcon className={classes.profileMenuIcon} /> Tasks
278+
</MenuItem>
279+
<MenuItem
280+
className={classNames(
281+
classes.profileMenuItem,
282+
classes.headerMenuItem
283+
)}
284+
>
285+
<AccountIcon className={classes.profileMenuIcon} /> Messages
286+
</MenuItem>
187287
<div className={classes.profileMenuUser}>
188-
<Typography className={classes.profileMenuLink} color="primary" onClick={props.signOut}>Sign Out</Typography>
288+
<Typography
289+
className={classes.profileMenuLink}
290+
color="primary"
291+
onClick={props.signOut}
292+
>
293+
Sign Out
294+
</Typography>
189295
</div>
190296
</Menu>
191297
</Toolbar>
@@ -199,9 +305,9 @@ const styles = theme => ({
199305
marginRight: theme.spacing.unit * 2.5,
200306
fontWeight: 500,
201307
fontSize: 18,
202-
whiteSpace: 'nowrap',
308+
whiteSpace: "nowrap",
203309
[theme.breakpoints.down("xs")]: {
204-
display: 'none',
310+
display: "none"
205311
}
206312
},
207313
appBar: {
@@ -255,7 +361,7 @@ const styles = theme => ({
255361
}
256362
},
257363
searchIconOpened: {
258-
right: theme.spacing.unit * 1.25,
364+
right: theme.spacing.unit * 1.25
259365
},
260366
inputRoot: {
261367
color: "inherit",
@@ -279,46 +385,73 @@ const styles = theme => ({
279385
flexDirection: "column"
280386
},
281387
headerMenuItem: {
282-
'&:hover, &:focus': {
388+
"&:hover, &:focus": {
283389
backgroundColor: theme.palette.primary.main,
284-
color: 'white',
390+
color: "white"
285391
}
286392
},
287393
headerMenuButton: {
288394
marginLeft: theme.spacing.unit * 2,
289395
padding: theme.spacing.unit / 2
290396
},
291397
headerMenuButtonCollapse: {
292-
marginRight: theme.spacing.unit * 2,
398+
marginRight: theme.spacing.unit * 2
293399
},
294400
headerIcon: {
295401
fontSize: 28,
296402
color: "rgba(255, 255, 255, 0.35)"
297403
},
298404
headerIconCollapse: {
299-
color: "white",
405+
color: "white"
300406
},
301407
profileMenu: {
302-
minWidth: 265,
408+
minWidth: 265
303409
},
304410
profileMenuUser: {
305-
display: 'flex',
306-
flexDirection: 'column',
307-
padding: theme.spacing.unit * 2,
411+
display: "flex",
412+
flexDirection: "column",
413+
padding: theme.spacing.unit * 2
308414
},
309415
profileMenuItem: {
310-
color: theme.palette.text.hint,
416+
color: theme.palette.text.hint
311417
},
312418
profileMenuIcon: {
313419
marginRight: theme.spacing.unit * 2,
314-
color: theme.palette.text.hint,
420+
color: theme.palette.text.hint
315421
},
316422
profileMenuLink: {
317423
fontSize: 16,
318-
textDecoration: 'none',
319-
'&:hover': {
320-
cursor: 'pointer',
321-
},
424+
textDecoration: "none",
425+
"&:hover": {
426+
cursor: "pointer"
427+
}
428+
},
429+
messageNotification: {
430+
height: "auto",
431+
display: "flex",
432+
alignItems: "center",
433+
"&:hover, &:focus": {
434+
backgroundColor: theme.palette.background.light
435+
}
436+
},
437+
messageNotificationSide: {
438+
display: "flex",
439+
flexDirection: "column",
440+
alignItems: "center",
441+
marginRight: theme.spacing.unit * 2
442+
},
443+
messageNotificationBodySide: {
444+
alignItems: "flex-start",
445+
marginRight: 0
446+
},
447+
sendMessageButton: {
448+
margin: theme.spacing.unit * 4,
449+
marginTop: theme.spacing.unit * 2,
450+
marginBottom: theme.spacing.unit * 2,
451+
textTransform: "none"
452+
},
453+
sendButtonIcon: {
454+
marginLeft: theme.spacing.unit * 2
322455
}
323456
});
324457

0 commit comments

Comments
 (0)