Skip to content

Commit 648392a

Browse files
Notifications Popup Fixes
Challenge: 30115261 Submission: 351307
1 parent 54c0d14 commit 648392a

File tree

11 files changed

+297
-189
lines changed

11 files changed

+297
-189
lines changed

dist/dev/index.js

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/prod/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/AccountMenu/index.js

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import _ from 'lodash'
2-
import React from 'react'
2+
import React, { Fragment } from 'react'
33
import PropTypes from 'prop-types'
44
import cn from 'classnames'
55
import { Link } from 'topcoder-react-utils'
66
import IconAvatar from '../../assets/images/img-vic-tor-avatar.svg'
77
import IconCloseDark from '../../assets/images/icon-close-dark.svg'
88
import IconSwitchBusiness from '../../assets/images/icon-switch-business.svg'
9+
import IconNotificationsRed from '../../assets/images/icon-bell-red.svg'
10+
import IconRightArrow from '../../assets/images/right-arrow.svg'
911
import styles from './styles.module.scss'
1012
import moment from 'moment'
1113

@@ -41,7 +43,7 @@ class AccountMenu extends React.Component {
4143

4244
render () {
4345
const {
44-
onClose, open, menu, switchText, onSwitch, profile
46+
onClose, open, menu, switchText, onSwitch, profile, numNotifications, onClickNotifications
4547
} = this.props
4648

4749
return (
@@ -88,6 +90,29 @@ class AccountMenu extends React.Component {
8890
</div>
8991
)
9092
}
93+
{
94+
!_.isEmpty(profile) && (
95+
<Fragment>
96+
<div
97+
role='button'
98+
className={styles['notifications-mobile']}
99+
onClick={onClickNotifications}
100+
>
101+
<div className={styles['noti-left']}>
102+
<IconNotificationsRed className={styles['bell-icon']} />
103+
<div>
104+
<span className={styles['notifications-title']}>Notifications</span>
105+
<span className={styles['red-number']}>{'(' + numNotifications + ')'}</span>
106+
</div>
107+
</div>
108+
<span role='button' className={styles['icon-open-noti']}>
109+
<IconRightArrow />
110+
</span>
111+
</div>
112+
<span className={styles['noti-separator']} />
113+
</Fragment>
114+
)
115+
}
91116

92117
<div className={styles.menu}>
93118

@@ -98,13 +123,13 @@ class AccountMenu extends React.Component {
98123
))}
99124

100125
</div>
101-
</div>
126+
</div >
102127
)
103128
}
104129
}
105130

106131
AccountMenu.defaultProps = {
107-
numNotifications: 35
132+
numNotifications: 0
108133
}
109134

110135
AccountMenu.propTypes = {
@@ -113,7 +138,9 @@ AccountMenu.propTypes = {
113138
menu: PropTypes.array,
114139
switchText: PropTypes.shape(),
115140
onSwitch: PropTypes.func,
116-
profile: PropTypes.shape()
141+
profile: PropTypes.shape(),
142+
numNotifications: PropTypes.number,
143+
onClickNotifications: PropTypes.func.isRequired
117144
}
118145

119146
export default AccountMenu

src/components/AccountMenu/styles.module.scss

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,15 @@
7979
}
8080
}
8181

82+
.notifications-mobile {
83+
@include mobile-only;
84+
}
85+
8286
.menu {
8387
@include not-mobile {
8488
padding: 15px 0 25px 0;
8589
}
8690

87-
.notification-mobile {
88-
@include mobile-only;
89-
}
9091

9192
a {
9293
height: 50px;
@@ -186,6 +187,50 @@
186187
}
187188
}
188189

190+
.notifications-mobile {
191+
height: 75px;
192+
display: flex;
193+
align-items: center;
194+
justify-content: space-between;
195+
196+
.noti-left {
197+
198+
display: flex;
199+
align-items: center;
200+
margin-bottom: 2px;
201+
202+
.bell-icon {
203+
margin: 0 10px 0 22px;
204+
}
205+
206+
.red-number {
207+
color: $red;
208+
margin: 0 10px;
209+
}
210+
}
211+
212+
.icon-open-noti {
213+
width: 50px;
214+
height: 50px;
215+
display: flex;
216+
justify-content: center;
217+
align-items: center;
218+
}
219+
220+
a {
221+
color: $white;
222+
font-size: 14px;
223+
line-height: 30px;
224+
}
225+
}
226+
.noti-separator {
227+
background: $gray-05;
228+
width: calc(100% - 46px);
229+
height: 1px;
230+
align-self: center;
231+
padding: 0 $base-unit * 4;
232+
}
233+
189234
.menu {
190235
display: flex;
191236
flex-direction: column;
@@ -200,8 +245,7 @@
200245
padding: 0 $base-unit * 4;
201246
}
202247

203-
a,
204-
.notification-mobile {
248+
a {
205249
color: $gray-90;
206250
height: 40px;
207251
display: flex;
@@ -237,7 +281,6 @@
237281
}
238282
}
239283
}
240-
241284
}
242285
}
243286
}

src/components/LoginNav/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import NotificationButton from '../NotificationButton'
66
import NotificationsPopup from '../NotificationsPopup'
77
import UserInfo from '../UserInfo'
88
import AccountMenu from '../AccountMenu'
9+
import _ from 'lodash'
910

1011
const LoginNav = ({
1112
loggedIn,
@@ -20,7 +21,8 @@ const LoginNav = ({
2021
authURLs,
2122
markNotificationAsRead,
2223
markAllNotificationAsRead,
23-
markAllNotificationAsSeen
24+
markAllNotificationAsSeen,
25+
dismissChallengeNotifications
2426
}) => {
2527
const [openNotifications, setOpenNotifications] = useState()
2628
const [openAccountMenu, setOpenAccountMenu] = useState()
@@ -49,7 +51,7 @@ const LoginNav = ({
4951
/>,
5052
<UserInfo
5153
profile={profile}
52-
newNotifications={notificationButtonState === 'new'}
54+
newNotifications={(notifications && _.countBy(notifications || [], n => !n.isSeen).true > 0) && 'new'}
5355
onClick={handleClickUserInfo}
5456
open={openAccountMenu}
5557
key='user-info'
@@ -60,7 +62,7 @@ const LoginNav = ({
6062
return (
6163
<UserInfo
6264
profile={profile}
63-
newNotifications={notificationButtonState === 'new'}
65+
newNotifications={(notifications && _.countBy(notifications || [], n => !n.isSeen).true > 0) && 'new'}
6466
onClick={handleClickUserInfo}
6567
open={openAccountMenu}
6668
key='user-info'
@@ -91,6 +93,7 @@ const LoginNav = ({
9193
}}
9294
markNotificationAsRead={markNotificationAsRead}
9395
markAllNotificationAsRead={markAllNotificationAsRead}
96+
dismissChallengeNotifications={dismissChallengeNotifications}
9497
/>
9598
<AccountMenu
9699
profile={profile}
@@ -122,7 +125,8 @@ LoginNav.propTypes = {
122125
authURLs: PropTypes.shape(),
123126
markNotificationAsRead: PropTypes.func.isRequired,
124127
markAllNotificationAsRead: PropTypes.func.isRequired,
125-
markAllNotificationAsSeen: PropTypes.func.isRequired
128+
markAllNotificationAsSeen: PropTypes.func.isRequired,
129+
dismissChallengeNotifications: PropTypes.func.isRequired
126130
}
127131

128132
export default LoginNav

src/components/NotificationButton/index.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,12 @@ import styles from './styles.module.scss'
77
import _ from 'lodash'
88

99
const getNotificationButtonState = (notifications) => {
10-
console.log('got')
11-
console.log(_.countBy(notifications || [], n => !n.seen))
1210
if (notifications && _.countBy(notifications || [], n => !n.isSeen).true > 0) {
13-
console.log('returing : new')
14-
1511
return 'new'
1612
}
1713
if (notifications.length === 0) {
18-
console.log('returing : none')
19-
2014
return 'none'
2115
} else {
22-
console.log('returing : seen')
23-
2416
return 'seen'
2517
}
2618
}

src/components/NotificationButton/styles.module.scss

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
@import "../../assets/sass/_global/variables";
2+
@import "../../assets/sass/_global/utils";
23

34
.notificationButton {
5+
@include hide-mobile;
46
position: relative;
5-
width: 30px;
6-
height: 30px;
7-
padding-top: 3px;
8-
padding-left: 7px;
7+
width: 36px;
8+
height: 36px;
9+
padding: 5px;
910

1011
img {
1112
display: block;
@@ -37,5 +38,5 @@
3738
{
3839
background-color: $gray-hover-profile-icon;
3940
border-radius: 50%;
40-
}
41+
}
4142
}

src/components/NotificationsPopup/EmptyNotifications.js

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,34 @@ import React from 'react'
22
import PropTypes from 'prop-types'
33
import cn from 'classnames'
44
import styles from './styles.module.scss'
5+
import NotificationIcon from '../../assets/images/icon-bell.svg'
6+
import BackArrow from '../../assets/images/left-arrow.svg'
7+
import NotificationIconBig from '../../assets/images/bell-big.svg'
58

69
const EmptyNotifications = ({ onClose, emptyTitle, emptyText }) => (
710
<>
811
<div className={styles['noti-header']}>
9-
<span
10-
className={styles['notification-back-btn']}
11-
role='button'
12-
onClick={onClose}
13-
/>
14-
<span className={styles['left-noti']}>Notifications</span>
15-
<div className={styles.rights}>
16-
<span className={styles['white-link']} role='button'>Settings</span>
12+
<div className={styles['lefts']}>
13+
<div
14+
className={styles['notification-icon']}
15+
>
16+
<NotificationIcon />
17+
</div>
18+
<div
19+
className={styles['notification-left-btn-mobile']}
20+
role='button'
21+
onClick={onClose}
22+
>
23+
<BackArrow />
24+
</div>
25+
<span className={styles['noti-title']}>Notifications</span>
1726
</div>
18-
<span className={styles['btn-setting']} role='button' />
27+
<span className={cn(styles['noti-empty-title-mobileonly'])}>Notifications</span>
1928
</div>
20-
<div className={cn(styles['noti-body'], styles.center)}>
21-
<i className={cn(styles.icons, styles['icon-bell'])} />
22-
<h4 className={styles.titles}>{emptyTitle}</h4>
29+
<div className={cn(styles['noti-body'], styles['noti-body-empty'], styles.center)}>
30+
<NotificationIconBig className={styles['big-icon-bell']} />
31+
<div className={styles['empty-title']}>{emptyTitle}</div>
2332
<div className={cn(styles.txt, styles['center-txt'])}>{emptyText}</div>
24-
</div>
25-
<div className={styles['noti-footer']}>
2633
<span className={cn(styles['btn-empty-noti'])} role='button'>
2734
Notification Settings
2835
</span>
@@ -34,9 +41,8 @@ EmptyNotifications.defaultProps = {
3441
emptyTitle: 'Good job! You’re all caught up',
3542
emptyText: (
3643
<div>
37-
Join challenges and check your notification settings if
38-
you don’t receive notifications. We’re actively adding
39-
new notifications. Read our <a href='/' className={styles.blueLink}>blog post</a> for more info
44+
Join challenges and check your notification settings if you don’t
45+
receive notifications. We’re actively adding new notifications.
4046
</div>
4147
)
4248
}

0 commit comments

Comments
 (0)