diff --git a/packages/page-accounts/src/Accounts/Banner.tsx b/packages/page-accounts/src/Accounts/Banner.tsx index 4c123c5227..70d45b5d1b 100644 --- a/packages/page-accounts/src/Accounts/Banner.tsx +++ b/packages/page-accounts/src/Accounts/Banner.tsx @@ -2,59 +2,21 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { detect } from 'detect-browser'; import React from 'react'; import styled from 'styled-components'; -import { availableExtensions } from '@polkadot/apps-config/extensions'; -import { isWeb3Injected } from '@polkadot/extension-dapp'; -import { stringUpperFirst } from '@polkadot/util'; - -import { useTranslation } from '../translate'; - -// it would have been really good to import this from detect, however... not exported -type Browser = 'chrome' | 'firefox'; interface Props { + children: React.ReactNode; className?: string; + type: 'warning' | 'error'; } -const browserInfo = detect(); -const browserName: Browser | null = (browserInfo && (browserInfo.name as Browser)) || null; -const isSupported = browserName && Object.keys(availableExtensions).includes(browserName); - -function Banner ({ className }: Props): React.ReactElement | null { - const { t } = useTranslation(); - - if (isWeb3Injected || !isSupported || !browserName) { - return null; - } - +function Banner ({ children, className = '', type }: Props): React.ReactElement | null { return ( -
+
-

{t('It is recommended that you create/store your accounts securely and externally from the app. On {{yourBrowser}} the following browser extensions are available for use -', { - replace: { - yourBrowser: stringUpperFirst(browserName) - } - })}

-
    {availableExtensions[browserName].map(({ desc, link, name }): React.ReactNode => ( -
  • - - {name} - ({t(desc)}) -
  • - )) - }
-

{t('Accounts injected from any of these extensions will appear in this application and be available for use. The above list is updated as more extensions with external signing capability become available.')} {t('Learn more...')}

+ {children}
@@ -64,9 +26,24 @@ function Banner ({ className }: Props): React.ReactElement | null { export default React.memo(styled(Banner)` padding: 0 0.5rem 0.5rem; + &.error { + .box { + background: #fdd; + border-left-color: #9f3a38; + color: #9f3a38; + } + } + + &.warning { + .box { + background: #fff6e5; + border-left-color: darkorange; + } + } + .box { - background: #fff6e5; - border-left: 0.25rem solid darkorange; + border-left-style: solid; + border-left-width: 0.25rem; border-radius: 0 0.25rem 0.25rem 0; box-sizing: border-box; padding: 1rem 1.5rem; diff --git a/packages/page-accounts/src/Accounts/BannerClaims.tsx b/packages/page-accounts/src/Accounts/BannerClaims.tsx new file mode 100644 index 0000000000..e35ac822e9 --- /dev/null +++ b/packages/page-accounts/src/Accounts/BannerClaims.tsx @@ -0,0 +1,26 @@ +// Copyright 2017-2020 @polkadot/app-accounts authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import React from 'react'; +import useClaimCounter from '@polkadot/app-claims/useCounter'; // exceptionally CRAP idea + +import { useTranslation } from '../translate'; +import Banner from './Banner'; + +function BannerExtension (): React.ReactElement | null { + const claimCount = useClaimCounter(); + const { t } = useTranslation(); + + if (!claimCount) { + return null; + } + + return ( + +

{t('You have {{claimCount}} accounts that need attestations. Use the Claim Tokens app on the left navigation bar to complete the process. Until you do, your balances for those accounts will not be reflected.', { replace: { claimCount } })}

+
+ ); +} + +export default React.memo(BannerExtension); diff --git a/packages/page-accounts/src/Accounts/BannerExtension.tsx b/packages/page-accounts/src/Accounts/BannerExtension.tsx new file mode 100644 index 0000000000..a3e62a9893 --- /dev/null +++ b/packages/page-accounts/src/Accounts/BannerExtension.tsx @@ -0,0 +1,56 @@ +// Copyright 2017-2020 @polkadot/app-accounts authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import { detect } from 'detect-browser'; +import React from 'react'; +import { availableExtensions } from '@polkadot/apps-config/extensions'; +import { isWeb3Injected } from '@polkadot/extension-dapp'; +import { stringUpperFirst } from '@polkadot/util'; + +import { useTranslation } from '../translate'; +import Banner from './Banner'; + +// it would have been really good to import this from detect, however... not exported +type Browser = 'chrome' | 'firefox'; + +const browserInfo = detect(); +const browserName: Browser | null = (browserInfo && (browserInfo.name as Browser)) || null; +const isSupported = browserName && Object.keys(availableExtensions).includes(browserName); + +function BannerExtension (): React.ReactElement | null { + const { t } = useTranslation(); + + if (isWeb3Injected || !isSupported || !browserName) { + return null; + } + + return ( + +

{t('It is recommended that you create/store your accounts securely and externally from the app. On {{yourBrowser}} the following browser extensions are available for use -', { + replace: { + yourBrowser: stringUpperFirst(browserName) + } + })}

+
    {availableExtensions[browserName].map(({ desc, link, name }): React.ReactNode => ( +
  • + + {name} + ({t(desc)}) +
  • + )) + }
+

{t('Accounts injected from any of these extensions will appear in this application and be available for use. The above list is updated as more extensions with external signing capability become available.')} {t('Learn more...')}

+
+ ); +} + +export default React.memo(BannerExtension); diff --git a/packages/page-accounts/src/Accounts/index.tsx b/packages/page-accounts/src/Accounts/index.tsx index 8befeed704..01d514645b 100644 --- a/packages/page-accounts/src/Accounts/index.tsx +++ b/packages/page-accounts/src/Accounts/index.tsx @@ -22,7 +22,8 @@ import ImportModal from './modals/Import'; import Multisig from './modals/MultisigCreate'; import QrModal from './modals/Qr'; import Account from './Account'; -import Banner from './Banner'; +import BannerClaims from './BannerClaims'; +import BannerExtension from './BannerExtension'; interface Balances { accounts: Record; @@ -159,7 +160,8 @@ function Overview ({ className = '', onStatusChange }: Props): React.ReactElemen return (
- + + {isCreateOpen && (