-
Notifications
You must be signed in to change notification settings - Fork 102
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
7 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
packages/yoroi-extension/app/UI/common/hooks/useStrings.ts
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,19 @@ | ||
import React from 'react'; | ||
import { defineMessages } from 'react-intl'; | ||
import { useIntl } from '../../context/IntlProvider'; | ||
|
||
export const messages = Object.freeze( | ||
defineMessages({ | ||
clickToView: { | ||
id: 'notifications.description.clickToView', | ||
defaultMessage: 'Click to view', | ||
}, | ||
}) | ||
); | ||
|
||
export const useStrings = () => { | ||
const { intl } = useIntl(); | ||
return React.useRef({ | ||
clickToView: intl.formatMessage(messages.clickToView), | ||
}).current; | ||
}; |
74 changes: 74 additions & 0 deletions
74
packages/yoroi-extension/app/UI/components/notifications/NotificationToast.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,74 @@ | ||
import { IconButton, styled, Box, Typography } from '@mui/material'; | ||
import React from 'react'; | ||
import { useStrings } from '../../common/hooks/useStrings'; | ||
import { Icon } from '../icons/index'; | ||
|
||
enum NotificationTypes { | ||
Income = "Income", | ||
Cancelled = "Cancelled", | ||
Outcome = "Outcome", | ||
Rewards = "Rewards" | ||
} | ||
|
||
interface Props { | ||
text: string; | ||
type: NotificationTypes; | ||
onClick(): void; | ||
onClose(): void; | ||
} | ||
|
||
const IconWrapper = styled(IconButton)(({ theme }: any) => ({ | ||
'& svg': { | ||
'& path': { | ||
fill: theme.palette.ds.el_gray_medium, | ||
}, | ||
}, | ||
})); | ||
|
||
const SNotificationContainer = styled(Box)(({ theme }) => ({ | ||
display: 'flex', | ||
borderRadius: '8px', | ||
width: '446px', | ||
paddingTop: '16px', | ||
paddingBottom: '16px', | ||
backgroundColor: theme.palette["ds"].bg_color_contrast_high, | ||
boxShadow: theme.palette["ds"].light_shadow_notification, | ||
})); | ||
|
||
export default function NotificationToast({ onClick, onClose, text, type }: Props) { | ||
const strings = useStrings(); | ||
|
||
const handleClick = (e) => { | ||
e.preventDefault(); | ||
console.log("clicked"); | ||
onClick(); | ||
} | ||
|
||
const handleClose = (e) => { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
onClose(); | ||
console.log("closed"); | ||
} | ||
|
||
return ( | ||
<Box id="notif-toast" sx={{ position: 'fixed', top: 10, right: 10, zIndex: 9999 }}> | ||
<SNotificationContainer onClick={handleClick}> | ||
<Box px="16px" flexShrink={0} sx={{ cursor: 'pointer', alignSelf: 'center' }}> | ||
<Box borderRadius="50%" bgcolor="ds.secondary_100" width="40px" height="40px" display="flex" alignItems="center" justifyContent="center"> | ||
{type === NotificationTypes.Rewards ? <Icon.Staking fill='#08C29D' /> : <Icon.ChipArrowDown fill='#08C29D' />} | ||
</Box> | ||
</Box> | ||
<Box sx={{ flexGrow: 1, cursor: "pointer" }}> | ||
<Typography mb="2px" component="div" variant="body1" fontWeight={500} color="ds.text_gray_medium">{text}</Typography> | ||
<Typography component="div" variant='body2' color="ds.text_gray_low">{strings.clickToView}</Typography> | ||
</Box> | ||
<Box px="12px" flexShrink={0}> | ||
<IconWrapper onClick={handleClose} sx={{ padding: 0 }}> | ||
<Icon.CloseIcon fill='#6B7384' /> | ||
</IconWrapper> | ||
</Box> | ||
</SNotificationContainer> | ||
</Box> | ||
); | ||
}; |
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
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
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