diff --git a/.eslintignore b/.eslintignore index 45ed3e09d..c95d5ffb8 100644 --- a/.eslintignore +++ b/.eslintignore @@ -9,3 +9,4 @@ package.json !.storybook packages/browser-wallet-api-helpers/lib +packages/browser-wallet/src/popup/popupX/styles/_bundle.scss diff --git a/packages/browser-wallet/src/popup/constants/routes.ts b/packages/browser-wallet/src/popup/constants/routes.ts index 3d2976baf..2a52f5335 100644 --- a/packages/browser-wallet/src/popup/constants/routes.ts +++ b/packages/browser-wallet/src/popup/constants/routes.ts @@ -7,9 +7,6 @@ type RouteChildren = { }; export const relativeRoutes = { - onboarding: { - path: '/onboarding', - }, home: { path: '/', account: { diff --git a/packages/browser-wallet/src/popup/pages/Settings/Settings.tsx b/packages/browser-wallet/src/popup/pages/Settings/Settings.tsx index 0c8c00bb8..3c3dcd3bb 100644 --- a/packages/browser-wallet/src/popup/pages/Settings/Settings.tsx +++ b/packages/browser-wallet/src/popup/pages/Settings/Settings.tsx @@ -13,7 +13,7 @@ import { popupMessageHandler } from '@popup/shared/message-handler'; import { InternalMessageType } from '@messaging'; import Button from '@popup/shared/Button'; import { isFullscreenWindow } from '@popup/shared/window-helpers'; -import { noOp } from 'wallet-common-helpers'; +import { routePrefix } from '@popup/popupX/constants/routes'; function LightDarkModeToggle() { const { t } = useTranslation('settings'); @@ -63,24 +63,7 @@ export default function Settings() { {t('fullscreenWallet')} )} - { - const body = document.getElementsByTagName('body').item(0); - const html = document.getElementsByTagName('html').item(0); - const bg = document.getElementsByClassName('bg').item(0); - body?.classList.add('popup-x'); - bg?.classList.add('welcome-page'); - body?.setAttribute('style', 'width:375px; height:600px; margin: auto;'); - - popupMessageHandler - .sendInternalMessage(InternalMessageType.SetViewSize, { width: 375, height: 600 }) - .catch(noOp); - html?.classList.remove('ui-scale-medium'); - html?.classList.add('ui-scale-large'); - }} - > + Wallet X diff --git a/packages/browser-wallet/src/popup/popupX/page-layouts/MainLayout/Header/components/MenuTiles.tsx b/packages/browser-wallet/src/popup/popupX/page-layouts/MainLayout/Header/components/MenuTiles.tsx index a8e9cf87f..14aee3bad 100644 --- a/packages/browser-wallet/src/popup/popupX/page-layouts/MainLayout/Header/components/MenuTiles.tsx +++ b/packages/browser-wallet/src/popup/popupX/page-layouts/MainLayout/Header/components/MenuTiles.tsx @@ -8,6 +8,7 @@ import Plant from '@assets/svgX/plant.svg'; import LinkSimple from '@assets/svgX/link-simple-horizontal.svg'; import Info from '@assets/svgX/info2.svg'; import Restore from '@assets/svgX/arrow-counter-clock.svg'; +import Eye from '@assets/svgX/eye.svg'; import IconButton from '@popup/shared/IconButton'; import Text from '@popup/popupX/shared/Text'; import { Link } from 'react-router-dom'; @@ -49,7 +50,7 @@ export default function MenuTiles({ menuOpen, setMenuOpen }: MenuTilesProps) { {t('seedPhrase')} - + {t('passcode')} @@ -85,6 +86,12 @@ export default function MenuTiles({ menuOpen, setMenuOpen }: MenuTilesProps) { {t('restore')} + + + + {t('oldUI')} + + ); diff --git a/packages/browser-wallet/src/popup/popupX/page-layouts/MainLayout/Header/i18n/en.ts b/packages/browser-wallet/src/popup/popupX/page-layouts/MainLayout/Header/i18n/en.ts index 765c77fb8..12462ee60 100644 --- a/packages/browser-wallet/src/popup/popupX/page-layouts/MainLayout/Header/i18n/en.ts +++ b/packages/browser-wallet/src/popup/popupX/page-layouts/MainLayout/Header/i18n/en.ts @@ -9,6 +9,7 @@ const t = { network: 'Network', about: 'About', restore: 'Restore', + oldUI: 'Old UI', }, }; diff --git a/packages/browser-wallet/src/popup/popupX/pages/MainPage/MainPage.tsx b/packages/browser-wallet/src/popup/popupX/pages/MainPage/MainPage.tsx index 04f9eee15..47f10acfd 100644 --- a/packages/browser-wallet/src/popup/popupX/pages/MainPage/MainPage.tsx +++ b/packages/browser-wallet/src/popup/popupX/pages/MainPage/MainPage.tsx @@ -3,7 +3,7 @@ import { useNavigate } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { useAtomValue } from 'jotai'; import { displayAsCcd } from 'wallet-common-helpers'; -import { Ratio } from '@concordium/web-sdk'; +import { AccountInfoType, Ratio } from '@concordium/web-sdk'; import { relativeRoutes } from '@popup/popupX/constants/routes'; import Img from '@popup/shared/Img'; import { WalletCredential } from '@shared/storage/types'; @@ -142,6 +142,8 @@ function MainPage({ credential }: MainPageProps) { return <>Loading; } + const isStaked = [AccountInfoType.Delegator, AccountInfoType.Baker].includes(accountInfo.type); + return ( @@ -161,7 +163,7 @@ function MainPage({ credential }: MainPageProps) { onClick={() => nav(`${relativeRoutes.home.token.path}/ccd`)} thumbnail={} symbol="CCD" - staked + staked={isStaked} balance={displayAsCcd(accountInfo.accountAmount.microCcdAmount, false)} balanceBase={accountInfo.accountAmount.microCcdAmount} microCcdPerEur={microCcdPerEur} diff --git a/packages/browser-wallet/src/popup/popupX/pages/ReceiveFunds/QRcode.svg b/packages/browser-wallet/src/popup/popupX/pages/ReceiveFunds/QRcode.svg deleted file mode 100644 index 458dc91dd..000000000 --- a/packages/browser-wallet/src/popup/popupX/pages/ReceiveFunds/QRcode.svg +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/browser-wallet/src/popup/popupX/pages/ReceiveFunds/ReceiveFunds.tsx b/packages/browser-wallet/src/popup/popupX/pages/ReceiveFunds/ReceiveFunds.tsx index bc49a0331..6ac40a3b5 100644 --- a/packages/browser-wallet/src/popup/popupX/pages/ReceiveFunds/ReceiveFunds.tsx +++ b/packages/browser-wallet/src/popup/popupX/pages/ReceiveFunds/ReceiveFunds.tsx @@ -5,28 +5,29 @@ import Page from '@popup/popupX/shared/Page'; import Text from '@popup/popupX/shared/Text'; import Card from '@popup/popupX/shared/Card'; import { useAtomValue } from 'jotai'; -import { selectedAccountAtom } from '@popup/store/account'; +import { selectedCredentialAtom } from '@popup/store/account'; import { DisplayAsQR } from 'wallet-common-helpers'; import { copyToClipboard } from '@popup/popupX/shared/utils/helpers'; +import { displayNameAndSplitAddress } from '@popup/shared/utils/account-helpers'; export default function ReceiveFunds() { const { t } = useTranslation('x', { keyPrefix: 'receiveFunds' }); - const address = useAtomValue(selectedAccountAtom) || ''; + const credential = useAtomValue(selectedCredentialAtom); - if (address === undefined) { + if (credential === undefined) { return null; } return ( - {t('to', { value: 'Account 1 / 6gk...Fk7o' })} + {t('to', { value: displayNameAndSplitAddress(credential) })} - - {address} - copyToClipboard(address)} /> + + {credential.address} + copyToClipboard(credential.address)} /> diff --git a/packages/browser-wallet/src/popup/popupX/pages/TransactionDetails/TransactionDetails.scss b/packages/browser-wallet/src/popup/popupX/pages/TransactionDetails/TransactionDetails.scss index 9197a2aae..fb9eafe07 100644 --- a/packages/browser-wallet/src/popup/popupX/pages/TransactionDetails/TransactionDetails.scss +++ b/packages/browser-wallet/src/popup/popupX/pages/TransactionDetails/TransactionDetails.scss @@ -11,6 +11,10 @@ color: $color-mineral-3; } + .label__main { + color: $color-white; + } + .top-info { display: flex; justify-content: space-between; diff --git a/packages/browser-wallet/src/popup/popupX/pages/TransactionLog/TransactionLog.scss b/packages/browser-wallet/src/popup/popupX/pages/TransactionLog/TransactionLog.scss index 8bef77e11..7800c8e2f 100644 --- a/packages/browser-wallet/src/popup/popupX/pages/TransactionLog/TransactionLog.scss +++ b/packages/browser-wallet/src/popup/popupX/pages/TransactionLog/TransactionLog.scss @@ -17,6 +17,10 @@ margin-bottom: rem(4px); .transaction { + .label__main { + color: $color-white; + } + &.value, &.info { display: flex; diff --git a/packages/browser-wallet/src/popup/popupX/pages/TransactionLog/TransactionLog.tsx b/packages/browser-wallet/src/popup/popupX/pages/TransactionLog/TransactionLog.tsx index 1bbd3f84a..84518b967 100644 --- a/packages/browser-wallet/src/popup/popupX/pages/TransactionLog/TransactionLog.tsx +++ b/packages/browser-wallet/src/popup/popupX/pages/TransactionLog/TransactionLog.tsx @@ -307,7 +307,7 @@ function TransactionLog({ account }: TransactionLogProps) { {day.transactions.map((transaction) => ( // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
navToTransactionDetails(transaction)} > diff --git a/packages/browser-wallet/src/popup/popupX/shell/Providers.tsx b/packages/browser-wallet/src/popup/popupX/shell/Providers.tsx index 3ff8b9fdc..a18d074c3 100644 --- a/packages/browser-wallet/src/popup/popupX/shell/Providers.tsx +++ b/packages/browser-wallet/src/popup/popupX/shell/Providers.tsx @@ -3,12 +3,7 @@ import { useAtomValue } from 'jotai'; import { networkConfigurationAtom, themeAtom } from '@popup/store/settings'; import { mainnet } from '@shared/constants/networkConfiguration'; import { Dimensions, large, medium, small } from '@popup/constants/dimensions'; -import { - isFullscreenWindow, - isFullscreenWindowDemo, - isSpawnedWeb3IdProofWindow, - isSpawnedWindow, -} from '@popup/shared/window-helpers'; +import { isFullscreenWindow, isSpawnedWeb3IdProofWindow, isSpawnedWindow } from '@popup/shared/window-helpers'; import { popupMessageHandler } from '@popup/shared/message-handler'; import { InternalMessageType } from '@messaging'; import { noOp } from 'wallet-common-helpers'; @@ -53,13 +48,6 @@ export function Scaling({ children }: { children: ReactElement }) { // Send a message to the BG script to resize the window. popupMessageHandler.sendInternalMessage(InternalMessageType.SetViewSize, dimensions).catch(noOp); } - - if (isFullscreenWindowDemo && body) { - body.style.margin = 'unset'; - body.style.width = '100%'; - body.style.height = '100%'; - html?.classList.add('tablet'); - } }, []); return children; diff --git a/packages/browser-wallet/src/popup/popupX/styles/_base.scss b/packages/browser-wallet/src/popup/popupX/styles/_base.scss index c7ad0fb51..67bce27ef 100644 --- a/packages/browser-wallet/src/popup/popupX/styles/_base.scss +++ b/packages/browser-wallet/src/popup/popupX/styles/_base.scss @@ -1,3 +1,7 @@ +&:not(html) { + background-color: rgba($color-black, 0.9); +} + .bg { opacity: unset; filter: unset; diff --git a/packages/browser-wallet/src/popup/popupX/styles/_bundle.scss b/packages/browser-wallet/src/popup/popupX/styles/_bundle.scss index af33859b4..4006dce9d 100644 --- a/packages/browser-wallet/src/popup/popupX/styles/_bundle.scss +++ b/packages/browser-wallet/src/popup/popupX/styles/_bundle.scss @@ -6,7 +6,7 @@ // Temporary workaround to wrap all new classes // Should be removed on new design release html.popup-x, -body.popup-x, +body.light.popup-x, body.dark.popup-x { @import 'base'; @import 'elements'; diff --git a/packages/browser-wallet/src/popup/popupX/styles/_typography.scss b/packages/browser-wallet/src/popup/popupX/styles/_typography.scss index 1e3e5bfc2..d619bb39c 100644 --- a/packages/browser-wallet/src/popup/popupX/styles/_typography.scss +++ b/packages/browser-wallet/src/popup/popupX/styles/_typography.scss @@ -7,6 +7,18 @@ $t-font-weight-medium: 500; $t-font-weight-semi-bold: 600; $t-font-weight-bold: 700; +html.popup-x { + font-size: 14px; + + &.ui-scale-medium { + font-size: 14px; + } + + &.ui-scale-large { + font-size: 14px; + } +} + .heading { &_large { font-family: $t-font-family-satoshi; diff --git a/packages/browser-wallet/src/popup/shared/utils/account-helpers.ts b/packages/browser-wallet/src/popup/shared/utils/account-helpers.ts index 6d0564e0b..18d4e2816 100644 --- a/packages/browser-wallet/src/popup/shared/utils/account-helpers.ts +++ b/packages/browser-wallet/src/popup/shared/utils/account-helpers.ts @@ -15,6 +15,12 @@ export const displayNameOrSplitAddress = (account: WalletCredential | undefined) return credName || `${address.slice(0, 4)}...${address.slice(address.length - 4)}`; }; +export const displayNameAndSplitAddress = (account: WalletCredential | undefined) => { + const { credName, address } = account || { address: '' }; + const splitAddress = `${address.slice(0, 4)}...${address.slice(address.length - 4)}`; + return `${credName ? `${credName} / ` : ''}${splitAddress}`; +}; + export function useIdentityOf(cred?: WalletCredential) { const identities = useAtomValue(identitiesAtom); diff --git a/packages/browser-wallet/src/popup/shared/window-helpers.ts b/packages/browser-wallet/src/popup/shared/window-helpers.ts index ad19e0f37..db54cd90b 100644 --- a/packages/browser-wallet/src/popup/shared/window-helpers.ts +++ b/packages/browser-wallet/src/popup/shared/window-helpers.ts @@ -3,4 +3,3 @@ import { spawnedPopupUrl, web3IdProofPopupUrl } from '@shared/constants/url'; export const isSpawnedWindow = window.location.href.includes(spawnedPopupUrl); export const isSpawnedWeb3IdProofWindow = window.location.href.includes(web3IdProofPopupUrl); export const isFullscreenWindow = window.location.hash === '#fullscreen'; -export const isFullscreenWindowDemo = window.location.hash === '#fullscreen-demo'; diff --git a/packages/browser-wallet/src/popup/shell/Root.tsx b/packages/browser-wallet/src/popup/shell/Root.tsx index b2fe7aba7..5297ac295 100644 --- a/packages/browser-wallet/src/popup/shell/Root.tsx +++ b/packages/browser-wallet/src/popup/shell/Root.tsx @@ -1,17 +1,12 @@ import { Provider, useAtomValue } from 'jotai'; -import React, { ReactElement, useEffect } from 'react'; -import { MemoryRouter } from 'react-router-dom'; +import React, { ReactElement, useEffect, useMemo } from 'react'; +import { MemoryRouter, useLocation } from 'react-router-dom'; import { InternalMessageType } from '@messaging'; import { noOp } from 'wallet-common-helpers'; import { Dimensions, large, medium, small } from '@popup/constants/dimensions'; import { popupMessageHandler } from '@popup/shared/message-handler'; -import { - isFullscreenWindow, - isFullscreenWindowDemo, - isSpawnedWeb3IdProofWindow, - isSpawnedWindow, -} from '@popup/shared/window-helpers'; +import { isFullscreenWindow, isSpawnedWeb3IdProofWindow, isSpawnedWindow } from '@popup/shared/window-helpers'; import { networkConfigurationAtom, themeAtom } from '@popup/store/settings'; import { Theme as ThemeType } from '@shared/storage/types'; import BlockChainParametersContext from '@popup/shared/BlockChainParametersProvider'; @@ -20,17 +15,41 @@ import AccountInfoListenerContext from '@popup/shared/AccountInfoListenerContext import './i18n'; import { mainnet } from '@shared/constants/networkConfiguration'; +import { routePrefix } from '@popup/popupX/constants/routes'; import Routes from './Routes'; import RoutesX from '../popupX/shell/Routes'; const body = document.getElementsByTagName('body').item(0); const html = document.getElementsByTagName('html').item(0); -body?.classList.add('popup-x'); -function useScaling() { +function resetHtmlHeight() { + if (html) { + html.style.height = 'auto'; + setTimeout(() => { + html.style.removeProperty('height'); + }); + } +} + +function Scaling({ children }: { children: ReactElement }) { + const { pathname } = useLocation(); + const h = Math.min(window.screen.width, window.screen.height); // Seems to get dimensions for primary display only for the non-spawned popup. + + const isPopupX = useMemo(() => pathname.includes(routePrefix), [pathname]); + useEffect(() => { - const h = 1500; // Seems to get dimensions for primary display only for the non-spawned popup. + if (isPopupX) { + body?.classList.add('popup-x'); + html?.classList.add('popup-x'); + } else { + body?.classList.remove('popup-x'); + html?.classList.remove('popup-x'); + resetHtmlHeight(); + } + // html?.classList.add('tablet'); + }, [isPopupX]); + useEffect(() => { let dimensions: Dimensions | undefined; if (h >= 1080 && h < 1440) { @@ -41,8 +60,12 @@ function useScaling() { html?.classList.add('ui-scale-large'); } + if (isPopupX) { + dimensions = { ...large }; + } + // When opened by clicking on the extension icon - if (!isSpawnedWindow && body) { + if (!isSpawnedWindow && body && html) { const { width, height } = dimensions ?? small; // Mimic what's done on a spawned popup window in the bg script. @@ -62,15 +85,9 @@ function useScaling() { // Send a message to the BG script to resize the window. popupMessageHandler.sendInternalMessage(InternalMessageType.SetViewSize, dimensions).catch(noOp); } + }, [body?.classList.length, isPopupX]); - if (isFullscreenWindowDemo && body) { - body.style.margin = 'unset'; - body.style.width = 'unset'; - body.style.height = '100%'; - html?.classList.add('tablet'); - body.classList.add('popup-x'); - } - }, [body?.classList.length]); + return children; } function Network({ children }: { children: ReactElement }) { @@ -92,9 +109,11 @@ function Theme({ children }: { children: ReactElement }) { useEffect(() => { if (theme === ThemeType.Light) { + body?.classList.add('light'); body?.classList.remove('dark'); } else { body?.classList.add('dark'); + body?.classList.remove('light'); } }, [theme]); @@ -102,21 +121,21 @@ function Theme({ children }: { children: ReactElement }) { } export default function Root() { - useScaling(); - return ( - - - - - - - - - - - + + + + + + + + + + + + + );