forked from deriv-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: show snackbar if strategy changed while running bot
- Loading branch information
1 parent
a028efc
commit ff1ee1e
Showing
5 changed files
with
132 additions
and
2 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -15,4 +15,5 @@ | |
--zindex-drawer: 5; | ||
--zindex-modal: 6; | ||
--zindex-draggable-modal: 7; | ||
--zindex-snackbar: 8; | ||
} |
36 changes: 36 additions & 0 deletions
36
packages/bot-web-ui/src/components/bot-snackbar/bot-snackbar.scss
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,36 @@ | ||
.bot-snackbar { | ||
position: fixed; | ||
z-index: var(--zindex-snackbar); | ||
right: 38rem; | ||
top: 12rem; | ||
|
||
.dc-toast { | ||
width: 100%; | ||
&__message { | ||
background: var(--text-prominent); | ||
color: var(--general-main-1); | ||
padding: 1rem 1.6rem; | ||
} | ||
&__message-content { | ||
display: flex; | ||
|
||
@include mobile { | ||
align-items: center; | ||
} | ||
} | ||
} | ||
|
||
@include mobile { | ||
top: unset; | ||
left: 0; | ||
right: 0; | ||
bottom: 10.5rem; | ||
} | ||
|
||
.notification-close { | ||
cursor: pointer; | ||
filter: invert(1); | ||
margin-left: 1rem; | ||
margin-top: 0.1rem; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
packages/bot-web-ui/src/components/bot-snackbar/bot-snackbar.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,50 @@ | ||
import React, { useState } from 'react'; | ||
import { Icon, Toast } from '@deriv/components'; | ||
import { Localize } from '@deriv/translations'; | ||
|
||
type TBotSnackbar = { | ||
className?: string; | ||
is_open?: boolean; | ||
onClick?: React.MouseEventHandler<HTMLDivElement>; | ||
handleClose: () => void; | ||
type?: 'error' | 'info' | 'notification'; | ||
timeout?: number; | ||
msg_localize_components?: JSX.Element[]; | ||
message: string; | ||
}; | ||
|
||
const BotSnackbar = ({ | ||
message = '', | ||
msg_localize_components = [], | ||
timeout = 6000, | ||
is_open = false, | ||
onClick, | ||
handleClose, | ||
type, | ||
className, | ||
}: TBotSnackbar) => { | ||
const [notification_timer, setNotificationTimer] = useState(timeout); | ||
|
||
return ( | ||
<div | ||
onMouseOver={() => { | ||
setNotificationTimer(20000); | ||
}} | ||
onMouseLeave={() => { | ||
setNotificationTimer(timeout); | ||
}} | ||
className={className ?? 'bot-snackbar'} | ||
> | ||
<Toast is_open={is_open} type={type} timeout={notification_timer} onClick={onClick} onClose={handleClose}> | ||
<div>{message && <Localize i18n_default_text={message} components={msg_localize_components} />}</div> | ||
<Icon | ||
icon='IcCross' | ||
className={'bot-snackbar-notification-close'} | ||
data_testid={'bot-snackbar-notification-close'} | ||
onClick={handleClose} | ||
/> | ||
</Toast> | ||
</div> | ||
); | ||
}; | ||
export default BotSnackbar; |
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,4 @@ | ||
import BotSnackbar from './bot-snackbar'; | ||
import './bot-snackbar.scss'; | ||
|
||
export default BotSnackbar; |
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