Skip to content

Commit

Permalink
feat(notifications): display notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
wri7tno committed Sep 20, 2023
1 parent 63b1569 commit 70a0816
Show file tree
Hide file tree
Showing 11 changed files with 490 additions and 225 deletions.
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ npm install -g yalc

2. Work on the component updates inside this library.

**Important**: you have to change the version inside the `package.json` every time you compile to avoid issues with the `node_modules` aggresively caching the library, preventing from seeing your latest changes.
Once your changes are good and tested, be careful not to commit the changes in `package.json`.

3. compile locally
```bash
yarn compile
Expand All @@ -154,14 +157,6 @@ yarn install # or just yarn

6. now you can run your app using the local component.

7. you can keep updating the component's code and just use:
```bash
yarn compile
yalc push
```

and only re run your app to see the updates in the component.

## Deployment

To deploy a new version of the library follow these steps:
Expand Down
10 changes: 10 additions & 0 deletions src/assets/icons/arrow-left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/assets/icons/notification-green-icon-dot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 15 additions & 11 deletions src/components/header/components/nav-alt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ import SearchGreenIcon from 'assets/icons/search-green-icon.svg';
import UserIcon from 'assets/icons/mygfw-green-icon.svg';
// eslint-disable-next-line no-unused-vars
import NotificationGreenIcon from 'assets/icons/notification-green-icon.svg';
import NotificationGreenRedDotIcon from 'assets/icons/notification-green-icon-dot.svg';

import { NavAltWrapper } from './styles';

import AuthenticationInfo from '../authentication-info';
import { notificationsExists } from '../../../../utils/storage';

class NavAlt extends PureComponent {
static propTypes = {
Expand All @@ -33,10 +35,12 @@ class NavAlt extends PureComponent {
appUrl: PropTypes.string,
showSubmenu: PropTypes.bool,
handleShowSubmenu: PropTypes.func,
handleShowNotificationsPanel: PropTypes.func,
handleLangSelect: PropTypes.func,
proAuthenticated: PropTypes.bool,
onProLogout: PropTypes.func,
NavLinkComponent: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
notifications: PropTypes.array,
};

render() {
Expand All @@ -48,13 +52,20 @@ class NavAlt extends PureComponent {
pathname,
appUrl,
handleShowSubmenu,
handleShowNotificationsPanel,
onProLogout,
showSubmenu,
handleLangSelect,
languages,
activeLang,
proAuthenticated,
notifications,
} = this.props;

const ids = notifications?.map((item) => item.id) || [];
const hasNotifications =
(notifications?.length || 0) !== 0 && !notificationsExists(ids);

return (
<NavAltWrapper theme={theme}>
<div className="nav-item lang-selector">
Expand Down Expand Up @@ -86,23 +97,16 @@ class NavAlt extends PureComponent {
</Tooltip>
</NavLink>
</div>
{/* // TODO: display this link when the new page is ready
<div className="nav-item">
<NavLink
href="/notifications/"
className="nav-link"
pathname={pathname}
appUrl={appUrl}
NavLinkComponent={NavLinkComponent}
>
<button onClick={handleShowNotificationsPanel}>
<Tooltip content="Notifications">
<div>
<NotificationGreenIcon />
{!hasNotifications && <NotificationGreenIcon />}
{hasNotifications && <NotificationGreenRedDotIcon />}
</div>
</Tooltip>
</NavLink>
</button>
</div>
*/}
<div className="nav-item">
<NavLink
href="/my-gfw/"
Expand Down
47 changes: 47 additions & 0 deletions src/components/header/components/notifications-panel/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';
import PropTypes from 'prop-types';
import OutsideClickHandler from 'react-outside-click-handler';

import NotificationItem from 'components/notifications/notification-item';

import CloseIcon from 'assets/icons/close.svg';
import { NotificationsPanelWrapper } from './styles';

const NotificationsPanel = ({ notifications, handleClose }) => {
const renderNotifications = () => {
if (notifications.length === 0) {
return <div className="empty-list">No notifications here.</div>;
}

return notifications.map(({ id, title, content, icon, date }) => (
<NotificationItem
key={id}
title={title}
description={content}
date={date}
icon={icon}
/>
));
};

return (
<NotificationsPanelWrapper>
<div>
<OutsideClickHandler onOutsideClick={handleClose}>
<div className="top">
<span className="title">NOTIFICATIONS</span>
<CloseIcon className="close-icon" onClick={handleClose} />
</div>
{renderNotifications()}
</OutsideClickHandler>
</div>
</NotificationsPanelWrapper>
);
};

NotificationsPanel.propTypes = {
notifications: PropTypes.array,
handleClose: PropTypes.func,
};

export default NotificationsPanel;
45 changes: 45 additions & 0 deletions src/components/header/components/notifications-panel/styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import styled from '@emotion/styled';
import theme from 'styles/theme';

export const NotificationsPanelWrapper = styled.div`
border: solid 1px ${theme.colors.lightGrey};
background-color: #ffffff;
left: 30%;
position: relative;
max-width: 438px;
max-height: 400px;
margin: 0 auto;
overflow-y: scroll;
z-index: 1;
.empty-list {
font-size: 14px;
padding: 20px;
text-align: center;
}
.top {
border-bottom: solid 1px ${theme.colors.lightGrey};
color: #333333;
display: flex;
flex-direction: row;
justify-content: space-between;
padding-bottom: 10px;
padding-left: 20px;
padding-right: 20px;
padding-top: 10px;
width: 100%;
.title {
font-weight: 700;
font-size: 16px;
}
.close-icon {
cursor: pointer;
height: 16px;
margin-top: 4px;
width: 16px;
}
}
`;
Loading

0 comments on commit 70a0816

Please sign in to comment.