This repository was archived by the owner on Jul 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 374
feat: Add notification panel #4484
Merged
cwhitten
merged 11 commits into
microsoft:main
from
tdurnford:feature/notification-panel
Oct 24, 2020
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e9c2220
feat: Add notificiation panel
tdurnford d7b8ce0
Merge branch 'main' into feature/notification-panel
tdurnford 61ac0b8
fix test
tdurnford a00f208
Merge branch 'main' into feature/notification-panel
tdurnford c62a188
small changes
tdurnford 4a56356
Merge branch 'main' into feature/notification-panel
tdurnford a3f4dc0
moved new notifications to the top
tdurnford fe9b0d9
Merge branch 'main' into feature/notification-panel
tdurnford 619ff71
Merge branch 'main' into feature/notification-panel
tdurnford 91dc760
Merge branch 'main' into feature/notification-panel
tdurnford 73ab819
Merge branch 'main' into feature/notification-panel
cwhitten File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
Composer/packages/client/src/components/Notifications/NotificationButton.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| /** @jsx jsx */ | ||
| import { css, jsx } from '@emotion/core'; | ||
| import React, { useState } from 'react'; | ||
| import { FontWeights } from '@uifabric/styling'; | ||
| import { IButtonStyles, IconButton } from 'office-ui-fabric-react/lib/Button'; | ||
| import { NeutralColors, SharedColors } from '@uifabric/fluent-theme'; | ||
| import { useRecoilValue } from 'recoil'; | ||
| import formatMessage from 'format-message'; | ||
|
|
||
| import { notificationsSelector } from '../../recoilModel/selectors/notificationsSelector'; | ||
| import { dispatcherState } from '../../recoilModel'; | ||
|
|
||
| import { NotificationPanel } from './NotificationPanel'; | ||
|
|
||
| const styles = { | ||
| container: css` | ||
| position: relative; | ||
| `, | ||
| count: (visible?: boolean) => css` | ||
| background-color: ${NeutralColors.white}; | ||
| border: 2px solid ${SharedColors.cyanBlue10}; | ||
| border-radius: 100%; | ||
| color: ${SharedColors.cyanBlue10}; | ||
| font-size: 8px; | ||
| font-weight: ${FontWeights.bold}; | ||
| height: 12px; | ||
| right: -4px; | ||
| position: absolute; | ||
| text-align: center; | ||
| visibility: ${visible ? 'visible' : 'hidden'}; | ||
| width: 12px; | ||
| `, | ||
| }; | ||
|
|
||
| type NotificationButtonProps = { | ||
| buttonStyles?: IButtonStyles; | ||
| }; | ||
|
|
||
| const NotificationButton: React.FC<NotificationButtonProps> = ({ buttonStyles }) => { | ||
| const [isOpen, setIsOpen] = useState(false); | ||
| const { deleteNotification, markNotificationAsRead } = useRecoilValue(dispatcherState); | ||
| const notifications = useRecoilValue(notificationsSelector); | ||
| const unreadNotification = notifications.filter(({ read }) => !read); | ||
|
|
||
| const toggleIsOpen = () => { | ||
| if (!isOpen) { | ||
| notifications.map(({ id }) => markNotificationAsRead(id)); | ||
| } | ||
| setIsOpen(!isOpen); | ||
| }; | ||
|
|
||
| return ( | ||
| <div aria-label={formatMessage('Open notification panel')}> | ||
| <IconButton iconProps={{ iconName: 'Ringer' }} styles={buttonStyles} onClick={toggleIsOpen}> | ||
| <div css={styles.container}> | ||
| <div aria-hidden css={styles.count(!isOpen && !!unreadNotification.length)}> | ||
| {unreadNotification.length} | ||
tdurnford marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </div> | ||
| </div> | ||
| </IconButton> | ||
| <NotificationPanel | ||
| isOpen={isOpen} | ||
| notifications={notifications} | ||
| onDeleteNotification={deleteNotification} | ||
| onDismiss={toggleIsOpen} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export { NotificationButton }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.