Skip to content

Commit 0903080

Browse files
authored
feat: add notification center bell icon and badge (#1994)
1 parent fbf58d8 commit 0903080

File tree

8 files changed

+85
-2
lines changed

8 files changed

+85
-2
lines changed
Lines changed: 9 additions & 0 deletions
Loading

apps/browser-extension-wallet/src/components/MainMenu/MainHeader.module.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
.controls {
2828
display: flex;
2929
align-items: center;
30-
gap: size_unit(1);
30+
gap: size_unit(0.75);
3131

3232
.avatar {
3333
font-size: 20px;
@@ -47,7 +47,7 @@
4747
}
4848

4949
.betaPill {
50-
background: linear-gradient(94.22deg, #FF92E1 -18.3%, #FDC300 118.89%);
50+
background: linear-gradient(94.22deg, #ff92e1 -18.3%, #fdc300 118.89%);
5151
border-radius: 100px;
5252

5353
.betaPillCopy {

apps/browser-extension-wallet/src/components/MainMenu/MainHeader.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { BrowserViewSections } from '@lib/scripts/types';
1313
import { NetworkPill } from '@components/NetworkPill';
1414
import { useAnalyticsContext } from '@providers';
1515
import { PostHogAction } from '@providers/AnalyticsProvider/analyticsTracker';
16+
import { NotificationsBellContainer } from '@components/NotificationsCenter';
1617

1718
export const MainHeader = (): React.ReactElement => {
1819
const { t } = useTranslation();
@@ -60,6 +61,7 @@ export const MainHeader = (): React.ReactElement => {
6061
.then(() => window.close())
6162
}
6263
/>
64+
<NotificationsBellContainer popupView />
6365
<DropdownMenu isPopup />
6466
</div>
6567
</div>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import { Button } from '@lace/common';
3+
import styles from './NotificationsCenter.module.scss';
4+
import NotificationBellIcon from '../../assets/icons/notifications-bell.component.svg';
5+
6+
// eslint-disable-next-line no-magic-numbers
7+
const formatNotificationCount = (count: number) => (count < 10 ? count.toString() : '9+');
8+
9+
export interface NotificationsBellProps {
10+
notificationsCount: number;
11+
onClick: () => void;
12+
popupView?: boolean;
13+
}
14+
15+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
16+
export const NotificationsBell = ({ notificationsCount, onClick }: NotificationsBellProps): React.ReactElement => (
17+
<Button className={styles.btn} block onClick={onClick} color="gradient" data-testid="notifications-bell">
18+
<NotificationBellIcon />
19+
{notificationsCount > 0 && <span className={styles.badge}>{formatNotificationCount(notificationsCount)}</span>}
20+
</Button>
21+
);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React, { useState } from 'react';
2+
import { NotificationsBell } from './NotificationsBell';
3+
4+
export interface NotificationsCenterContainerProps {
5+
popupView?: boolean;
6+
}
7+
8+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
9+
export const NotificationsBellContainer = ({ popupView }: NotificationsCenterContainerProps): React.ReactElement => {
10+
// TODO Connect with notifications center
11+
const [notificationsCount, setNotificationsCount] = useState(0);
12+
13+
// TODO Connect with notifications center
14+
const handleClick = () => {
15+
// eslint-disable-next-line no-magic-numbers
16+
setNotificationsCount(notificationsCount === 11 ? 0 : notificationsCount + 1);
17+
};
18+
19+
return <NotificationsBell notificationsCount={notificationsCount} onClick={handleClick} popupView={popupView} />;
20+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
@import '../../../../../packages/core/src/ui/styles/theme.scss';
2+
@import '../../../../../packages/common/src/ui/styles/theme.scss';
3+
4+
.badge {
5+
position: absolute;
6+
top: size_unit(-2);
7+
right: size_unit(-2);
8+
background: purple;
9+
color: white;
10+
border-radius: 50%;
11+
padding: 2px 2px;
12+
font-size: size_unit(1.5);
13+
font-weight: bold;
14+
min-width: size_unit(2.5);
15+
height: size_unit(2.5);
16+
display: flex;
17+
align-items: center;
18+
justify-content: center;
19+
font-family: 'Proxima Nova', Arial, Helvetica, sans-serif;
20+
}
21+
22+
.btn {
23+
max-width: size_unit(6);
24+
min-width: size_unit(6) !important;
25+
padding: size_unit(1) size_unit(2.75) !important;
26+
position: relative;
27+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './NotificationsBell';
2+
export * from './NotificationsBellContainer';

apps/browser-extension-wallet/src/views/browser-view/components/Layout/SidePanel.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import styles from './SectionLayout.modules.scss';
99
import { SidePanelButton } from '../SidePanelButton/SidePanelButton';
1010
import { CollapsiblePanelContainer } from '../CollapsiblePanelContainer/CollapsiblePanelContainer';
1111
import { BREAKPOINT_SMALL } from '@src/styles/constants';
12+
import { NotificationsBellContainer } from '@components/NotificationsCenter';
1213

1314
export const CONTENT_ID = 'content';
1415

@@ -65,6 +66,7 @@ export const SidePanel = ({ sidePanelContent, isSidePanelFixed = true }: Section
6566
})}
6667
>
6768
<TransactionCTAsBox />
69+
<NotificationsBellContainer />
6870
<DropdownMenu />
6971
{!!sidePanelContent && isScreenTooSmallForSidePanel && (
7072
<SidePanelButton active={isPanelVisible} onClick={toggleSidePanelVisibility} />

0 commit comments

Comments
 (0)