Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Add modal layout for passkey popup actions (#520)

Leendert de Borst74f4bc0ee98d
diff --git a/apps/browser-extension/src/entrypoints/background/PasskeyHandler.ts b/apps/browser-extension/src/entrypoints/background/PasskeyHandler.ts
index 4d255c350..bb59f23d4 100644
--- a/apps/browser-extension/src/entrypoints/background/PasskeyHandler.ts
+++ b/apps/browser-extension/src/entrypoints/background/PasskeyHandler.ts
@@ -52,7 +52,7 @@ export async function handleWebAuthnCreate(data: any): Promise<any> {
pendingRequestData.set(requestId, requestData);
// Create popup using main popup with hash navigation - only pass requestId
- const popupUrl = browser.runtime.getURL('/popup.html') + '#/credentials/passkeys/create?' + new URLSearchParams({
+ const popupUrl = browser.runtime.getURL('/popup.html') + '#/passkeys/create?' + new URLSearchParams({
requestId
}).toString();
@@ -111,7 +111,7 @@ export async function handleWebAuthnGet(data: any): Promise<any> {
pendingRequestData.set(requestId, requestData);
// Create popup using main popup with hash navigation - only pass requestId
- const popupUrl = browser.runtime.getURL('/popup.html') + '#/credentials/passkeys/authenticate?' + new URLSearchParams({
+ const popupUrl = browser.runtime.getURL('/popup.html') + '#/passkeys/authenticate?' + new URLSearchParams({
requestId
}).toString();
diff --git a/apps/browser-extension/src/entrypoints/popup/App.tsx b/apps/browser-extension/src/entrypoints/popup/App.tsx
index 7dc49171d..4990df59e 100644
--- a/apps/browser-extension/src/entrypoints/popup/App.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/App.tsx
@@ -1,11 +1,10 @@
import React, { useState, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
-import { HashRouter as Router, Routes, Route } from 'react-router-dom';
+import { HashRouter as Router, Routes, Route, useLocation } from 'react-router-dom';
import { sendMessage } from 'webext-bridge/popup';
-import { ClipboardCountdownBar } from '@/entrypoints/popup/components/ClipboardCountdownBar';
-import BottomNav from '@/entrypoints/popup/components/Layout/BottomNav';
-import Header from '@/entrypoints/popup/components/Layout/Header';
+import DefaultLayout from '@/entrypoints/popup/components/Layout/DefaultLayout';
+import PasskeyLayout from '@/entrypoints/popup/components/Layout/PasskeyLayout';
import LoadingSpinner from '@/entrypoints/popup/components/LoadingSpinner';
import { useApp } from '@/entrypoints/popup/context/AppContext';
import { useHeaderButtons } from '@/entrypoints/popup/context/HeaderButtonsContext';
@@ -38,6 +37,16 @@ import { useMinDurationLoading } from '@/hooks/useMinDurationLoading';
import '@/entrypoints/popup/style.css';
+/**
+ * Available layout types for different page contexts.
+ */
+enum LayoutType {
+ /** Default layout with header, footer navigation, and full UI */
+ DEFAULT = 'default',
+ /** Minimal layout for passkey operations - logo only, no footer */
+ PASSKEY = 'passkey',
+}
+
/**
* Route configuration.
*/
@@ -46,6 +55,81 @@ type RouteConfig = {
element: React.ReactNode;
showBackButton?: boolean;
title?: string;
+ /** Layout type to use for this route. Defaults to LayoutType.DEFAULT if not specified. */
+ layout?: LayoutType;
+};
+
+/**
+ * AppContent - Wrapper component that switches between different layout types
+ */
+const AppContent: React.FC<{
+ routes: RouteConfig[];
+ isLoading: boolean;
+ message: string | null;
+ headerButtons: React.ReactNode;
+}> = ({ routes, isLoading, message, headerButtons }) => {
+ const location = useLocation();
+
+ // Find the current route configuration
+ const currentRoute = routes.find(route => {
+ const pattern = route.path.replace(/:\w+/g, '[^/]+');
+ const regex = new RegExp(`^${pattern}$`);
+ return regex.test(location.pathname);
+ });
+
+ // Get layout type, defaulting to DEFAULT if not specified
+ const layoutType = currentRoute?.layout ?? LayoutType.DEFAULT;
+
+ // Common loading overlay
+ const loadingOverlay = isLoading && (
+ <div className="fixed inset-0 bg-white dark:bg-gray-900 z-50 flex items-center justify-center">
+ <LoadingSpinner />
+ </div>
+ );
+
+ // Common routes component
+ const routesComponent = (
+ <Routes>
+ {routes.map((route) => (
+ <Route
+ key={route.path}
+ path={route.path}
+ element={route.element}
+ />
+ ))}
+ </Routes>
+ );
+
+ // Render based on layout type
+ switch (layoutType) {
+ case LayoutType.PASSKEY:
+ // Passkey layout - minimal UI with just logo header
+ return (
+ <PasskeyLayout>
+ {loadingOverlay}
+ {message && (
+ <p className="text-red-500 mb-4">{message}</p>
+ )}
+ {routesComponent}
+ </PasskeyLayout>
+ );
+
+ case LayoutType.DEFAULT:
+ default:
+ // Default layout with full header, footer, navigation
+ return (
+ <>
+ {loadingOverlay}
+ <DefaultLayout
+ routes={routes}
+ headerButtons={headerButtons}
+ message={message}
+ >
+ {routesComponent}
+ </DefaultLayout>
+ </>
+ );
+ }
};
/**
@@ -73,8 +157,8 @@ const App: React.FC = () => {
{ path: '/credentials/:id', element: <CredentialDetails />, showBackButton: true, title: t('credentials.credentialDetails') },
{ path: '/credentials/:id/edit', element: <CredentialAddEdit />, showBackButton: true, title: t('credentials.editCredential') },
{ path: '/credentials/passkeys', element: <PasskeysList />, showBackButton: false },
- { path: '/credentials/passkeys/create', element: <PasskeyCreate />, showBackButton: true, title: 'Create Passkey' },
- { path: '/credentials/passkeys/authenticate', element: <PasskeyAuthenticate />, showBackButton: true, title: 'Sign in with Passkey' },
+ { path: '/passkeys/create', element: <PasskeyCreate />, layout: LayoutType.PASSKEY },
+ { path: '/passkeys/authenticate', element: <PasskeyAuthenticate />, layout: LayoutType.PASSKEY },
{ path: '/emails', element: <EmailsList />, showBackButton: false },
{ path: '/emails/:id', element: <EmailDetails />, showBackButton: true, title: t('emails.title') },
{ path: '/settings', element: <Settings />, showBackButton: false },
@@ -129,43 +213,12 @@ const App: React.FC = () => {
return (
<Router>
<NavigationProvider>
- <div className="min-h-screen min-w-[350px] bg-white dark:bg-gray-900 flex flex-col max-h-[600px]">
- {isLoading && (
- <div className="fixed inset-0 bg-white dark:bg-gray-900 z-50 flex items-center justify-center">
- <LoadingSpinner />
- </div>
- )}
-
- <ClipboardCountdownBar />
- <Header
- routes={routes}
- rightButtons={headerButtons}
- />
-
- <main
- className="flex-1 overflow-y-auto bg-gray-100 dark:bg-gray-900"
- style={{
- paddingTop: '64px',
- height: 'calc(100% - 120px)',
- }}
- >
- <div className="p-4 mb-16">
- {message && (
- <p className="text-red-500 mb-4">{message}</p>
- )}
- <Routes>
- {routes.map((route) => (
- <Route
- key={route.path}
- path={route.path}
- element={route.element}
- />
- ))}
- </Routes>
- </div>
- </main>
- <BottomNav />
- </div>
+ <AppContent
+ routes={routes}
+ isLoading={isLoading}
+ message={message}
+ headerButtons={headerButtons}
+ />
</NavigationProvider>
</Router>
);
diff --git a/apps/browser-extension/src/entrypoints/popup/components/Layout/DefaultLayout.tsx b/apps/browser-extension/src/entrypoints/popup/components/Layout/DefaultLayout.tsx
new file mode 100644
index 000000000..c29878df8
--- /dev/null
+++ b/apps/browser-extension/src/entrypoints/popup/components/Layout/DefaultLayout.tsx
@@ -0,0 +1,72 @@
+import React from 'react';
+import { Routes, Route } from 'react-router-dom';
+
+import { ClipboardCountdownBar } from '@/entrypoints/popup/components/ClipboardCountdownBar';
+import BottomNav from '@/entrypoints/popup/components/Layout/BottomNav';
+import Header from '@/entrypoints/popup/components/Layout/Header';
+
+/**
+ * Route configuration type.
+ */
+type RouteConfig = {
+ path: string;
+ element: React.ReactNode;
+ showBackButton?: boolean;
+ title?: string;
+};
+
+/**
+ * DefaultLayout props.
+ */
+type DefaultLayoutProps = {
+ routes: RouteConfig[];
+ headerButtons: React.ReactNode;
+ message?: string | null;
+ children?: React.ReactNode;
+};
+
+/**
+ * DefaultLayout - Standard layout with full header, footer navigation, and complete UI.
+ * This is the main layout used for most pages in the extension.
+ */
+const DefaultLayout: React.FC<DefaultLayoutProps> = ({ routes, headerButtons, message, children }) => {
+ return (
+ <div className="min-h-screen min-w-[350px] bg-white dark:bg-gray-900 flex flex-col max-h-[600px]">
+ <ClipboardCountdownBar />
+
+ <Header
+ routes={routes}
+ rightButtons={headerButtons}
+ />
+
+ <main
+ className="flex-1 overflow-y-auto bg-gray-100 dark:bg-gray-900"
+ style={{
+ paddingTop: '64px',
+ height: 'calc(100% - 120px)',
+ }}
+ >
+ <div className="p-4 mb-16">
+ {message && (
+ <p className="text-red-500 mb-4">{message}</p>
+ )}
+ {children || (
+ <Routes>
+ {routes.map((route) => (
+ <Route
+ key={route.path}
+ path={route.path}
+ element={route.element}
+ />
+ ))}
+ </Routes>
+ )}
+ </div>
+ </main>
+
+ <BottomNav />
+ </div>
+ );
+};
+
+export default DefaultLayout;
diff --git a/apps/browser-extension/src/entrypoints/popup/components/Layout/PasskeyLayout.tsx b/apps/browser-extension/src/entrypoints/popup/components/Layout/PasskeyLayout.tsx
new file mode 100644
index 000000000..4b9648571
--- /dev/null
+++ b/apps/browser-extension/src/entrypoints/popup/components/Layout/PasskeyLayout.tsx
@@ -0,0 +1,43 @@
+import React from 'react';
+
+import Logo from '@/entrypoints/popup/components/Logo';
+
+/**
+ * PasskeyLayout - Minimal layout for passkey create/authenticate pages.
+ * Shows only the AliasVault logo header, no navigation, no footer.
+ */
+const PasskeyLayout: React.FC<{ children: React.ReactNode }> = ({ children }) => {
+ return (
+ <div className="min-h-screen min-w-[350px] bg-white dark:bg-gray-900 flex flex-col max-h-[600px]">
+ {/* Minimal header with just logo */}
+ <header className="fixed z-30 w-full bg-white border-b border-gray-200 dark:bg-gray-800 dark:border-gray-700">
+ <div className="flex items-center justify-center h-16 px-4">
+ <Logo
+ width={125}
+ height={40}
+ showText={true}
+ className="text-gray-900 dark:text-white"
+ />
+ {/* Hide beta badge on Safari as it's not allowed to show non-production badges */}
+ {!import.meta.env.SAFARI && (
+ <span className="text-primary-500 text-[10px] font-normal">BETA</span>
+ )}
+ </div>
+ </header>
+
+ {/* Main content without footer padding */}
+ <main
+ className="flex-1 overflow-y-auto bg-gray-100 dark:bg-gray-900"
+ style={{
+ paddingTop: '64px',
+ }}
+ >
+ <div className="p-4">
+ {children}
+ </div>
+ </main>
+ </div>
+ );
+};
+
+export default PasskeyLayout;
diff --git a/apps/browser-extension/src/entrypoints/popup/context/NavigationContext.tsx b/apps/browser-extension/src/entrypoints/popup/context/NavigationContext.tsx
index ddc91ad45..99bb53744 100644
--- a/apps/browser-extension/src/entrypoints/popup/context/NavigationContext.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/context/NavigationContext.tsx
@@ -43,8 +43,19 @@ export const NavigationProvider: React.FC<{ children: React.ReactNode }> = ({ ch
* Store the current page path, timestamp, and navigation history in storage.
*/
const storeCurrentPage = useCallback(async (): Promise<void> => {
- // Pages that are not allowed to be stored as these are auth conditional pages.
- const notAllowedPaths = ['/', '/reinitialize', '/login', '/unlock', '/unlock-success', '/auth-settings', '/upgrade', '/logout'];
+ // Pages that are not allowed to be stored as these are auth conditional pages or dedicated popup pages.
+ const notAllowedPaths = [
+ '/',
+ '/reinitialize',
+ '/login',
+ '/unlock',
+ '/unlock-success',
+ '/auth-settings',
+ '/upgrade',
+ '/logout',
+ '/passkeys/create',
+ '/passkeys/authenticate'
+ ];
// Only store the page if we're fully initialized and don't need auth
if (isFullyInitialized && !requiresAuth && !notAllowedPaths.includes(location.pathname)) {