-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
113 additions
and
75 deletions.
There are no files selected for viewing
50 changes: 0 additions & 50 deletions
50
client/packages/components/src/components/notification-service/NotificationService.tsx
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
client/packages/components/src/components/notifications/NotificationService.tsx
This file contains 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,42 @@ | ||
import { FC, PropsWithChildren, useState } from 'react'; | ||
|
||
import { css } from '@emotion/css'; | ||
import { useNotificationCenter } from './hooks/useNotificationCenter'; | ||
|
||
import { NotificationWrapper } from './components/NotificationWrapper'; | ||
import { Notification } from './types/Notification'; | ||
|
||
const messageListWrapper = css` | ||
position: fixed; | ||
top: 4rem; | ||
right: 2rem; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1rem; | ||
width: 500px; | ||
z-index: 1; | ||
`; | ||
|
||
const TimeoutInMilliseconds = 9000; | ||
|
||
export const NotificationService: FC<PropsWithChildren> = ({ children }) => { | ||
const [notifications, setNotifications] = useState<Notification[]>([]); | ||
useNotificationCenter((notification) => setNotifications((s) => [...s, notification])); | ||
|
||
return ( | ||
<> | ||
{children} | ||
<div className={messageListWrapper}> | ||
{notifications.length > 0 | ||
? notifications.map((notification, index) => ( | ||
<NotificationWrapper | ||
notification={notification} | ||
timeout={TimeoutInMilliseconds} | ||
index={index} | ||
/> | ||
)) | ||
: null} | ||
</div> | ||
</> | ||
); | ||
}; |
This file contains 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
38 changes: 38 additions & 0 deletions
38
client/packages/components/src/components/service-message-service/ServiceMessageService.tsx
This file contains 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,38 @@ | ||
import { FC, PropsWithChildren } from 'react'; | ||
import { useParams } from 'react-router-dom'; | ||
|
||
import { css } from '@emotion/css'; | ||
import { useServiceMessage, MessageWrapper } from '@equinor/service-message'; | ||
|
||
const messageListWrapper = css` | ||
position: fixed; | ||
bottom: 2rem; | ||
right: 2rem; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1rem; | ||
width: 500px; | ||
z-index: 1; | ||
`; | ||
|
||
export const ServiceMessageService: FC<PropsWithChildren> = ({ children }) => { | ||
const { appKey } = useParams(); | ||
|
||
const { currentMessages } = useServiceMessage(appKey); | ||
return ( | ||
<> | ||
{children} | ||
<div className={messageListWrapper}> | ||
{currentMessages.length > 0 | ||
? currentMessages.map((message) => ( | ||
<MessageWrapper | ||
key={message.id} | ||
message={message} | ||
timeout={message.type === 'Maintenance' ? 8000 : 5000} | ||
/> | ||
)) | ||
: null} | ||
</div> | ||
</> | ||
); | ||
}; |
This file contains 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 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