forked from polkadot-js/extension
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Issue 3050] [feat] Extension - Add popup remind backup account
- Loading branch information
1 parent
c17a72a
commit 5e319d4
Showing
8 changed files
with
180 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
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
123 changes: 123 additions & 0 deletions
123
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,123 @@ | ||
// 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, 'done'); | ||
const learnMore = useCallback(() => { | ||
window.open(`${USER_GUIDE_URL}/${SUB_DOMAIN_USER_GUIDE}`); | ||
setTimeout(() => { | ||
window.close(); | ||
}, 300); | ||
}, []); | ||
|
||
const dismiss = useCallback(() => { | ||
window.close(); | ||
}, []); | ||
|
||
useEffect(() => { | ||
setStorage('done'); | ||
}, [setStorage]); | ||
|
||
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