Skip to content

Commit

Permalink
feature: improve extension in-tab view (#988)
Browse files Browse the repository at this point in the history
* Improve extension in-tab view

* Update Overlay component and add delays in e2e tests

The Overlay component's position and size properties were adjusted to fit its new design requirements. The width is now fixed, and it is centered using transform. Meanwhile, explicit delays were added in the end-to-end tests for 'buy-cspr.spec.ts' to ensure proper closing of modal windows before continuing with the tests.
  • Loading branch information
ost-ptk authored Jun 3, 2024
1 parent b0fdd67 commit 9119ad7
Show file tree
Hide file tree
Showing 21 changed files with 644 additions and 496 deletions.
6 changes: 6 additions & 0 deletions e2e-tests/popup/buy-cspr/buy-cspr.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ popup.describe('Popup UI: buy cspr', () => {

await popupPage.getByText('Ukraine').click();

// wait until a modal window closed
await new Promise(r => setTimeout(r, 2000));

await popupPage.getByRole('button', { name: 'Next' }).click();

await popupExpect(
Expand All @@ -126,6 +129,9 @@ popup.describe('Popup UI: buy cspr', () => {

await popupPage.getByText('UAH').click();

// wait until a modal window closed
await new Promise(r => setTimeout(r, 2000));

await popupPage.getByRole('button', { name: 'Next' }).click();

await popupExpect(
Expand Down
19 changes: 4 additions & 15 deletions src/apps/import-account-with-file/app-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import { HashRouter, Route, Routes } from 'react-router-dom';
import { useUserActivityTracker } from '@hooks/use-user-activity-tracker';

import '@libs/i18n/i18n';
import { HeaderPopup, LayoutWindow } from '@libs/layout';

import { ImportAccountWithFilePage } from './pages/import-account-with-file';
import { ImportAccountWithFileFailureContentPage } from './pages/import-account-with-file-failure';
import { ImportAccountWithFileSuccessContentPage } from './pages/import-account-with-file-success';
import { ImportAccountWithFileFailurePage } from './pages/import-account-with-file-failure';
import { ImportAccountWithFileSuccessPage } from './pages/import-account-with-file-success';
import { ImportAccountWithFileUploadPage } from './pages/import-account-with-file-upload';
import { RouterPath } from './router';

Expand All @@ -28,21 +27,11 @@ export function AppRouter() {
/>
<Route
path={RouterPath.ImportAccountWithFileSuccess}
element={
<LayoutWindow
renderHeader={() => <HeaderPopup />}
renderContent={() => <ImportAccountWithFileSuccessContentPage />}
/>
}
element={<ImportAccountWithFileSuccessPage />}
/>
<Route
path={RouterPath.ImportAccountWithFileFailure}
element={
<LayoutWindow
renderHeader={() => <HeaderPopup />}
renderContent={() => <ImportAccountWithFileFailureContentPage />}
/>
}
element={<ImportAccountWithFileFailurePage />}
/>
</Routes>
</HashRouter>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import { Trans, useTranslation } from 'react-i18next';

import { useTypedLocation } from '@import-account-with-file/router';

import {
ContentContainer,
IllustrationContainer,
ParagraphContainer,
SpacingSize
} from '@libs/layout';
import { SvgIcon, Typography } from '@libs/ui/components';

export function ImportAccountWithFileFailureContentPage() {
const { t } = useTranslation();
const location = useTypedLocation();
const state = location.state;

return (
<ContentContainer>
<IllustrationContainer>
<SvgIcon
src="assets/illustrations/error.svg"
width={200}
height={120}
/>
</IllustrationContainer>
<ParagraphContainer top={SpacingSize.XL}>
<Typography type="header">
<Trans t={t}>Something went wrong</Trans>
</Typography>
</ParagraphContainer>
<ParagraphContainer top={SpacingSize.Medium}>
<Typography type="body" color="contentSecondary">
{state?.importAccountStatusMessage
? state.importAccountStatusMessage
: t(
': We couldn’t import your account. Please confirm that you’re importing a file containing your secret key (not to be confused with your public key).'
)}
</Typography>
</ParagraphContainer>
</ContentContainer>
);
}
Original file line number Diff line number Diff line change
@@ -1,60 +1,37 @@
import React from 'react';
import { Trans, useTranslation } from 'react-i18next';

import {
RouterPath,
useTypedLocation,
useTypedNavigate
} from '@import-account-with-file/router';
import { RouterPath, useTypedNavigate } from '@import-account-with-file/router';

import { closeCurrentWindow } from '@background/close-current-window';

import {
ContentContainer,
FooterButtonsAbsoluteContainer,
IllustrationContainer,
ParagraphContainer,
SpacingSize
FooterButtonsContainer,
HeaderPopup,
LayoutWindow
} from '@libs/layout';
import { Button, SvgIcon, Typography } from '@libs/ui/components';
import { Button } from '@libs/ui/components';

import { ImportAccountWithFileFailureContentPage } from './content';

export function ImportAccountWithFileFailureContentPage() {
export const ImportAccountWithFileFailurePage = () => {
const { t } = useTranslation();
const navigate = useTypedNavigate();
const location = useTypedLocation();
const state = location.state;

return (
<ContentContainer>
<IllustrationContainer>
<SvgIcon
src="assets/illustrations/error.svg"
width={200}
height={120}
/>
</IllustrationContainer>
<ParagraphContainer top={SpacingSize.XL}>
<Typography type="header">
<Trans t={t}>Something went wrong</Trans>
</Typography>
</ParagraphContainer>
<ParagraphContainer top={SpacingSize.Medium}>
<Typography type="body" color="contentSecondary">
{state?.importAccountStatusMessage
? state.importAccountStatusMessage
: t(
': We couldn’t import your account. Please confirm that you’re importing a file containing your secret key (not to be confused with your public key).'
)}
</Typography>
</ParagraphContainer>
<FooterButtonsAbsoluteContainer>
<Button onClick={() => navigate(RouterPath.ImportAccountWithFile)}>
<Trans t={t}>Try to import again</Trans>
</Button>
<Button color="secondaryBlue" onClick={() => closeCurrentWindow()}>
<Trans t={t}>Maybe later</Trans>
</Button>
</FooterButtonsAbsoluteContainer>
</ContentContainer>
<LayoutWindow
renderHeader={() => <HeaderPopup />}
renderContent={() => <ImportAccountWithFileFailureContentPage />}
renderFooter={() => (
<FooterButtonsContainer>
<Button onClick={() => navigate(RouterPath.ImportAccountWithFile)}>
<Trans t={t}>Try to import again</Trans>
</Button>
<Button color="secondaryBlue" onClick={() => closeCurrentWindow()}>
<Trans t={t}>Maybe later</Trans>
</Button>
</FooterButtonsContainer>
)}
/>
);
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import { Trans, useTranslation } from 'react-i18next';

import {
ContentContainer,
IllustrationContainer,
ParagraphContainer,
SpacingSize
} from '@libs/layout';
import { SvgIcon, Typography } from '@libs/ui/components';

export function ImportAccountWithFileSuccessContentPage() {
const { t } = useTranslation();

return (
<ContentContainer>
<IllustrationContainer>
<SvgIcon
src="assets/illustrations/account-imported.svg"
width={200}
height={120}
/>
</IllustrationContainer>
<ParagraphContainer top={SpacingSize.XL}>
<Typography type="header">
<Trans t={t}>Your account was successfully imported</Trans>
</Typography>
</ParagraphContainer>
<ParagraphContainer top={SpacingSize.Medium}>
<Typography type="body" color="contentSecondary">
<Trans t={t}>
Imported accounts are distinguished by an ‘IMPORTED’ icon in the
account lists.
</Trans>
</Typography>
</ParagraphContainer>
</ContentContainer>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,28 @@ import { Trans, useTranslation } from 'react-i18next';
import { closeCurrentWindow } from '@background/close-current-window';

import {
ContentContainer,
FooterButtonsAbsoluteContainer,
IllustrationContainer,
ParagraphContainer,
SpacingSize
FooterButtonsContainer,
HeaderPopup,
LayoutWindow
} from '@libs/layout';
import { Button, SvgIcon, Typography } from '@libs/ui/components';
import { Button } from '@libs/ui/components';

export function ImportAccountWithFileSuccessContentPage() {
import { ImportAccountWithFileSuccessContentPage } from './content';

export const ImportAccountWithFileSuccessPage = () => {
const { t } = useTranslation();

return (
<ContentContainer>
<IllustrationContainer>
<SvgIcon
src="assets/illustrations/account-imported.svg"
width={200}
height={120}
/>
</IllustrationContainer>
<ParagraphContainer top={SpacingSize.XL}>
<Typography type="header">
<Trans t={t}>Your account was successfully imported</Trans>
</Typography>
</ParagraphContainer>
<ParagraphContainer top={SpacingSize.Medium}>
<Typography type="body" color="contentSecondary">
<Trans t={t}>
Imported accounts are distinguished by an ‘IMPORTED’ icon in the
account lists.
</Trans>
</Typography>
</ParagraphContainer>
<FooterButtonsAbsoluteContainer>
<Button onClick={() => closeCurrentWindow()}>
<Trans t={t}>Done</Trans>
</Button>
</FooterButtonsAbsoluteContainer>
</ContentContainer>
<LayoutWindow
renderHeader={() => <HeaderPopup />}
renderContent={() => <ImportAccountWithFileSuccessContentPage />}
renderFooter={() => (
<FooterButtonsContainer>
<Button onClick={closeCurrentWindow}>
<Trans t={t}>Done</Trans>
</Button>
</FooterButtonsContainer>
)}
/>
);
}
};
53 changes: 6 additions & 47 deletions src/apps/popup/app-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import { ImportAccountFromLedgerPage } from '@popup/pages/import-account-from-le
import { ImportAccountFromTorusPage } from '@popup/pages/import-account-from-torus';
import { NavigationMenuPageContent } from '@popup/pages/navigation-menu';
import { NftDetailsPage } from '@popup/pages/nft-details';
import { NoConnectedAccountPageContent } from '@popup/pages/no-connected-account';
import { NoConnectedAccountPage } from '@popup/pages/no-connected-account';
import { RateAppPage } from '@popup/pages/rate-app';
import { ReceivePage } from '@popup/pages/receive';
import { RemoveAccountPageContent } from '@popup/pages/remove-account';
import { RenameAccountPageContent } from '@popup/pages/rename-account';
import { RemoveAccountPage } from '@popup/pages/remove-account';
import { RenameAccountPage } from '@popup/pages/rename-account';
import { SignWithLedgerInNewWindowPage } from '@popup/pages/sign-with-ledger-in-new-window';
import { StakesPage } from '@popup/pages/stakes';
import { TimeoutPageContent } from '@popup/pages/timeout';
Expand Down Expand Up @@ -134,52 +134,11 @@ function AppRoutes() {
/>
}
/>
<Route
path={RouterPath.RemoveAccount}
element={
<PopupLayout
renderHeader={() => (
<HeaderPopup
withNetworkSwitcher
withMenu
withConnectionStatus
renderSubmenuBarItems={() => (
<HeaderSubmenuBarNavLink linkType="back" />
)}
/>
)}
renderContent={() => <RemoveAccountPageContent />}
/>
}
/>
<Route
path={RouterPath.RenameAccount}
element={
<PopupLayout
renderHeader={() => (
<HeaderPopup
withNetworkSwitcher
withMenu
withConnectionStatus
renderSubmenuBarItems={() => (
<HeaderSubmenuBarNavLink linkType="back" />
)}
/>
)}
renderContent={() => <RenameAccountPageContent />}
/>
}
/>
<Route path={RouterPath.RemoveAccount} element={<RemoveAccountPage />} />
<Route path={RouterPath.RenameAccount} element={<RenameAccountPage />} />
<Route
path={RouterPath.NoConnectedAccount}
element={
<PopupLayout
renderHeader={() => (
<HeaderPopup withNetworkSwitcher withMenu withConnectionStatus />
)}
renderContent={() => <NoConnectedAccountPageContent />}
/>
}
element={<NoConnectedAccountPage />}
/>
<Route
path={RouterPath.ConnectedSites}
Expand Down
Loading

0 comments on commit 9119ad7

Please sign in to comment.