Skip to content

Commit

Permalink
feat: move pin extension notification to main screen
Browse files Browse the repository at this point in the history
  • Loading branch information
greatertomi committed Feb 26, 2024
1 parent af41488 commit 1c94112
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 7 deletions.
1 change: 1 addition & 0 deletions apps/browser-extension-wallet/src/types/local-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ export interface ILocalStorage {
multidelegationFirstVisitSincePortfolioPersistence?: boolean;
unconfirmedTransactions: UnconfirmedTransaction[];
stakingBrowserPreferences: StakingBrowserPreferences;
showPinExtension?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,10 @@ $main-gap: 49px;
@include content_grid($col-width-large, $grid-gap-large);
}
}

.pinExtension {
position: absolute;
top: 10px;
right: 80px;
z-index: 100;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { DrawerContent, DrawerUIContainer } from '../Drawer';
import { useNetworkError } from '@hooks/useNetworkError';
import { LeftSidePanel } from '../LeftSidePanel';
import styles from './Layout.module.scss';
import { PinExtension } from '@views/browser/features/wallet-setup/components/PinExtension';
import { useLocalStorage } from '@hooks';

interface LayoutProps {
children: React.ReactNode;
Expand All @@ -21,13 +23,16 @@ interface LayoutProps {

const toastThrottle = 500;
const isFlexible = process.env.USE_DESKTOP_LAYOUT === 'true';
const PIN_EXTENSION_TIMEOUT = 5000;

export const Layout = ({ children, drawerUIDefaultContent, isFullWidth }: LayoutProps): React.ReactElement => {
const { t } = useTranslation();
const [, setDrawerConfig] = useDrawer();
const { theme, setTheme } = useTheme();
const backgroundServices = useBackgroundServiceAPIContext();

const [showPinExtension, { updateLocalStorage: setShowPinExtension }] = useLocalStorage('showPinExtension', true);

useEffect(() => {
const openDrawer = async () => {
const backgroundStorage = await backgroundServices.getBackgroundStorage();
Expand All @@ -50,6 +55,13 @@ export const Layout = ({ children, drawerUIDefaultContent, isFullWidth }: Layout
return () => subscription.unsubscribe();
}, [backgroundServices, setTheme]);

useEffect(() => {
const timer = setTimeout(() => {
setShowPinExtension(false);
}, PIN_EXTENSION_TIMEOUT);
return () => clearTimeout(timer);
}, [setShowPinExtension]);

const debouncedToast = useMemo(() => debounce(toast.notify, toastThrottle), []);
const showNetworkError = useCallback(
() => debouncedToast({ text: t('general.errors.networkError') }),
Expand All @@ -64,6 +76,11 @@ export const Layout = ({ children, drawerUIDefaultContent, isFullWidth }: Layout
className={classnames(styles.layoutGridContainer, isFullWidth && styles.fullWidth, isFlexible && styles.flexible)}
>
<LeftSidePanel theme={theme.name} />
{showPinExtension && (
<div className={styles.pinExtension}>
<PinExtension />
</div>
)}
{children}
<DrawerUIContainer defaultContent={drawerUIDefaultContent} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import React, { useState, useCallback, useEffect } from 'react';
import { Switch, Route, useHistory, useLocation } from 'react-router-dom';
import { Wallet } from '@lace/cardano';
import { WalletSetupLayout } from '@src/views/browser-view/components/Layout';
import { PinExtension } from './PinExtension';
import { ErrorDialog, HWErrorCode } from './ErrorDialog';
import { StartOverDialog } from '@views/browser/features/wallet-setup/components/StartOverDialog';
import { useTranslation } from 'react-i18next';
Expand Down Expand Up @@ -324,7 +323,7 @@ export const HardwareWalletFlow = ({
onStartOver={handleStartOver}
onClose={() => setIsStartOverDialogVisible(false)}
/>
<WalletSetupLayout prompt={location.pathname.endsWith('finish') ? <PinExtension /> : undefined}>
<WalletSetupLayout>
<Switch>
<Route path={route('analytics')}>{hardwareWalletStepRenderFunctions.analytics()}</Route>
<Route path={route('connect')}>{hardwareWalletStepRenderFunctions.connect()}</Route>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
gap: size_unit(2);
width: 300px;
padding: size_unit(2);
background: var(--color-white, var(--dark-mode-dark-grey-plus));
background: var(--primary-default, #7E5BF0);
box-shadow: var(--shadows-lighter-assets);
border-radius: 11px;

Expand All @@ -25,12 +25,12 @@

h5 {
@include text-bodySmall-bold;
color: var(--text-color-primary);
color: var(--text-color-white, #ffffff) !important;
}

p {
@include text-bodySmall-semi-bold;
color: var(--text-color-secondary);
color: var(--text-color-white, #ffffff);
display: flex;
align-items: center;
gap: 4px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
} from '@providers/AnalyticsProvider/analyticsTracker';
import { config } from '@src/config';

import { PinExtension } from './PinExtension';
import { Fallback } from './Fallback';

import { passwordTranslationMap } from '../constants';
Expand Down Expand Up @@ -449,7 +448,7 @@ export const WalletSetupWizard = ({
}, [shouldDisplayExperiment]);

return (
<WalletSetupLayout prompt={currentStep === WalletSetupSteps.Finish ? <PinExtension /> : undefined}>
<WalletSetupLayout>
{currentStep === WalletSetupSteps.Legal && (
<WalletSetupLegalStep
onBack={moveBack}
Expand Down

0 comments on commit 1c94112

Please sign in to comment.