-
Notifications
You must be signed in to change notification settings - Fork 562
/
Copy pathHeader_old.js
164 lines (151 loc) · 4.58 KB
/
Header_old.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import Avatar from 'components/Avatar';
import { UserCard } from 'components/Card';
import Notifications from 'components/Notifications';
import SearchInput from 'components/SearchInput';
import { notificationsData } from 'demos/header';
import withBadge from 'hocs/withBadge';
import React from 'react';
import {
MdClearAll,
MdExitToApp,
MdHelp,
MdInsertChart,
MdMessage,
MdNotificationsActive,
MdNotificationsNone,
MdPersonPin,
MdSettingsApplications,
} from 'react-icons/md';
import {
Button,
ListGroup,
ListGroupItem,
// NavbarToggler,
Nav,
Navbar,
NavItem,
NavLink,
Popover,
PopoverBody,
} from 'reactstrap';
import bn from 'utils/bemnames';
const bem = bn.create('header');
const MdNotificationsActiveWithBadge = withBadge({
size: 'md',
color: 'primary',
style: {
top: -10,
right: -10,
display: 'inline-flex',
justifyContent: 'center',
alignItems: 'center',
},
children: <small>5</small>,
})(MdNotificationsActive);
class Header extends React.Component {
state = {
isOpenNotificationPopover: false,
isNotificationConfirmed: false,
isOpenUserCardPopover: false,
};
toggleNotificationPopover = () => {
this.setState({
isOpenNotificationPopover: !this.state.isOpenNotificationPopover,
});
if (!this.state.isNotificationConfirmed) {
this.setState({ isNotificationConfirmed: true });
}
};
toggleUserCardPopover = () => {
this.setState({
isOpenUserCardPopover: !this.state.isOpenUserCardPopover,
});
};
handleSidebarControlButton = event => {
event.preventDefault();
event.stopPropagation();
document.querySelector('.cr-sidebar').classList.toggle('cr-sidebar--open');
};
render() {
const { isNotificationConfirmed } = this.state;
return (
<Navbar light expand className={bem.b('bg-white')}>
<Nav navbar className="mr-2">
<Button outline onClick={this.handleSidebarControlButton}>
<MdClearAll size={25} />
</Button>
</Nav>
<Nav navbar>
<SearchInput />
</Nav>
<Nav navbar className={bem.e('nav-right')}>
<NavItem className="d-inline-flex">
<NavLink id="Popover1" className="position-relative">
{isNotificationConfirmed ? (
<MdNotificationsNone
size={25}
className="text-secondary can-click"
onClick={this.toggleNotificationPopover}
/>
) : (
<MdNotificationsActiveWithBadge
size={25}
className="text-secondary can-click animated swing infinite"
onClick={this.toggleNotificationPopover}
/>
)}
</NavLink>
<Popover
placement="bottom"
isOpen={this.state.isOpenNotificationPopover}
toggle={this.toggleNotificationPopover}
target="Popover1"
>
<PopoverBody>
<Notifications notificationsData={notificationsData} />
</PopoverBody>
</Popover>
</NavItem>
<NavItem>
<NavLink id="Popover2">
<Avatar
onClick={this.toggleUserCardPopover}
className="can-click"
/>
</NavLink>
<Popover
placement="bottom-end"
isOpen={this.state.isOpenUserCardPopover}
toggle={this.toggleUserCardPopover}
target="Popover2"
className="p-0 border-0"
style={{ minWidth: 250 }}
>
<PopoverBody className="p-0 border-light">
<UserCard
title="Jane"
subtitle="[email protected]"
text="Last updated 3 mins ago"
className="border-light"
>
<ListGroup flush>
<ListGroupItem tag="button" action className="border-light">
<MdSettingsApplications /> Settings
</ListGroupItem>
<ListGroupItem tag="button" action className="border-light">
<MdHelp /> Help
</ListGroupItem>
<ListGroupItem tag="button" action className="border-light">
<MdExitToApp /> Signout
</ListGroupItem>
</ListGroup>
</UserCard>
</PopoverBody>
</Popover>
</NavItem>
</Nav>
</Navbar>
);
}
}
export default Header;