forked from polkadot-js/extension
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3098 from Koniverse/koni/dev/issue-3050
[Issue 3050] Extension - Add popup remind backup account
- Loading branch information
Showing
8 changed files
with
186 additions
and
3 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
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
130 changes: 130 additions & 0 deletions
130
packages/extension-koni-ui/src/Popup/RemindExportAccount.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,130 @@ | ||
// Copyright 2019-2022 @subwallet/extension-koni-ui authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { Layout } from '@subwallet/extension-koni-ui/components'; | ||
import { USER_GUIDE_URL } from '@subwallet/extension-koni-ui/constants'; | ||
import { Theme, ThemeProps } from '@subwallet/extension-koni-ui/types'; | ||
import { Icon, PageIcon } from '@subwallet/react-ui'; | ||
import CN from 'classnames'; | ||
import { ArrowCircleRight, Export, X, XCircle } from 'phosphor-react'; | ||
import React, { useCallback, useEffect } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import styled, { useTheme } from 'styled-components'; | ||
import { useLocalStorage } from 'usehooks-ts'; | ||
|
||
type Props = ThemeProps; | ||
|
||
const SUB_DOMAIN_USER_GUIDE = 'account-management/export-and-backup-accounts#export-all-accounts'; | ||
const keyStorage = 'remind_export_account'; | ||
|
||
const Component: React.FC<Props> = (props: Props) => { | ||
const { className } = props; | ||
const { token } = useTheme() as Theme; | ||
const [, setStorage] = useLocalStorage(keyStorage, 'init'); | ||
const learnMore = useCallback(() => { | ||
window.open(`${USER_GUIDE_URL}/${SUB_DOMAIN_USER_GUIDE}`); | ||
setStorage('done'); | ||
setTimeout(() => { | ||
window.close(); | ||
}, 300); | ||
}, [setStorage]); | ||
|
||
const dismiss = useCallback(() => { | ||
setStorage('done'); | ||
window.close(); | ||
}, [setStorage]); | ||
|
||
useEffect(() => { | ||
const handleCloseTabs = () => { | ||
window.localStorage.setItem(keyStorage, 'done'); | ||
window.removeEventListener('beforeunload', handleCloseTabs); | ||
}; | ||
|
||
window.addEventListener('beforeunload', handleCloseTabs); | ||
}, []); | ||
|
||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<Layout.WithSubHeaderOnly | ||
leftFooterButton={{ | ||
children: t('Dismiss'), | ||
onClick: dismiss, | ||
schema: 'secondary', | ||
icon: <Icon | ||
phosphorIcon={XCircle} | ||
weight={'fill'} | ||
/> | ||
}} | ||
rightFooterButton={{ | ||
children: t('Learn more'), | ||
onClick: learnMore, | ||
icon: <Icon | ||
phosphorIcon={ArrowCircleRight} | ||
weight={'fill'} | ||
/> | ||
}} | ||
showBackButton={false} | ||
subHeaderLeft={( | ||
<Icon | ||
phosphorIcon={X} | ||
size='md' | ||
/> | ||
)} | ||
title={t('Pay attention')} | ||
> | ||
<div className={CN(className)}> | ||
<div className='page-icon'> | ||
<PageIcon | ||
color={token.colorWarning} | ||
iconProps={{ | ||
weight: 'fill', | ||
phosphorIcon: Export | ||
}} | ||
/> | ||
</div> | ||
<div className='title'> | ||
{t('Back up your accounts!')} | ||
</div> | ||
<div className='description'> | ||
{t('If you lose your seed phrases/private keys/JSON backup files/QR backup codes, your accounts can\'t be recovered and your assets are lost. Learn how to back up your accounts to secure your assets now.')} | ||
</div> | ||
</div> | ||
</Layout.WithSubHeaderOnly> | ||
); | ||
}; | ||
|
||
const RemindExportAccount = styled(Component)<Props>(({ theme: { token } }: Props) => { | ||
return { | ||
textAlign: 'center', | ||
|
||
'.page-icon': { | ||
display: 'flex', | ||
justifyContent: 'center', | ||
marginTop: token.controlHeightLG, | ||
marginBottom: token.margin, | ||
'--page-icon-color': token.colorSecondary | ||
}, | ||
|
||
'.title': { | ||
marginTop: token.margin, | ||
marginBottom: token.margin, | ||
fontWeight: token.fontWeightStrong, | ||
fontSize: token.fontSizeHeading3, | ||
lineHeight: token.lineHeightHeading3, | ||
color: token.colorTextBase | ||
}, | ||
|
||
'.description': { | ||
padding: `0 ${token.controlHeightLG - token.padding}px`, | ||
marginTop: token.margin, | ||
marginBottom: token.margin * 2, | ||
fontSize: token.fontSizeHeading5, | ||
lineHeight: token.lineHeightHeading5, | ||
color: token.colorTextDescription, | ||
textAlign: 'center' | ||
} | ||
}; | ||
}); | ||
|
||
export default RemindExportAccount; |
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
fbd6afb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Deployed on https://subwallet-dev--sw-web-runner.netlify.app