Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update browser extension modal style (#2413)
Leendert de Borstfe9df7ef86c9
diff --git a/apps/browser-extension/src/entrypoints/popup/components/Dialogs/ModalWrapper.tsx b/apps/browser-extension/src/entrypoints/popup/components/Dialogs/ModalWrapper.tsxindex 8fc7cb331..42231ade5 100644--- a/apps/browser-extension/src/entrypoints/popup/components/Dialogs/ModalWrapper.tsx+++ b/apps/browser-extension/src/entrypoints/popup/components/Dialogs/ModalWrapper.tsx@@ -23,8 +23,6 @@ type ModalWrapperProps = {* A generic modal wrapper component that provides consistent behavior:* - Click outside to close (on backdrop)* - Escape key to close- * - Dark overlay background- * - Consistent styling and animations*/const ModalWrapper: React.FC<ModalWrapperProps> = ({isOpen,@@ -75,65 +73,59 @@ const ModalWrapper: React.FC<ModalWrapperProps> = ({};return (- <div className="fixed inset-0 z-50 overflow-y-auto">- {/* Backdrop */}- <div- className="fixed inset-0 bg-black bg-opacity-80 transition-opacity"- onMouseDown={onClose}- />+ <div className="fixed inset-0 z-50">+ <div className="fixed inset-0 bg-gray-600/50 backdrop-blur-sm dark:bg-black/80" />+ <div className="fixed inset-0 overflow-y-auto">+ {/* Pressing outside the panel closes the modal */}+ <div className="flex min-h-full items-center justify-center p-4" onMouseDown={handleContainerMouseDown}>+ <div className={`relative overflow-hidden rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-600 dark:bg-gray-800 dark:shadow-2xl w-full ${maxWidth}`}>+ {/* Header */}+ {title && (+ <div className={`px-6 py-4 flex items-center justify-between ${showHeaderBorder ? 'border-b border-gray-200 dark:border-gray-700' : ''}`}>+ <h2 className="text-xl font-semibold text-gray-900 dark:text-white">+ {title}+ </h2>+ {showCloseButton && (+ <button+ type="button"+ className="text-gray-400 hover:text-gray-500 focus:outline-none"+ onClick={onClose}+ >+ <span className="sr-only">{t('common.close')}</span>+ <svg className="h-6 w-6" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="currentColor">+ <path strokeLinecap="round" strokeLinejoin="round" d="M6 18L18 6M6 6l12 12" />+ </svg>+ </button>+ )}+ </div>+ )}- {/* Modal container - pressing here (outside modal content) also closes */}- <div- className="fixed inset-0 flex items-center justify-center p-4"- onMouseDown={handleContainerMouseDown}- >- <div className={`relative transform overflow-hidden rounded-lg bg-white dark:bg-gray-800 shadow-xl transition-all w-full ${maxWidth} mx-4`}>- {/* Header - only show as block if title exists */}- {title && (- <div className={`px-6 py-4 flex items-center justify-between ${showHeaderBorder ? 'border-b border-gray-200 dark:border-gray-700' : ''}`}>- <h2 className="text-xl font-semibold text-gray-900 dark:text-white">- {title}- </h2>- {showCloseButton && (- <button- type="button"- className="text-gray-400 hover:text-gray-500 focus:outline-none"- onClick={onClose}- >- <span className="sr-only">{t('common.close')}</span>- <svg className="h-6 w-6" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="currentColor">- <path strokeLinecap="round" strokeLinejoin="round" d="M6 18L18 6M6 6l12 12" />- </svg>- </button>- )}- </div>- )}+ {/* Floating close button when no title */}+ {!title && showCloseButton && (+ <button+ type="button"+ className="absolute top-3 right-3 text-gray-400 hover:text-gray-500 focus:outline-none z-10"+ onClick={onClose}+ >+ <span className="sr-only">{t('common.close')}</span>+ <svg className="h-6 w-6" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="currentColor">+ <path strokeLinecap="round" strokeLinejoin="round" d="M6 18L18 6M6 6l12 12" />+ </svg>+ </button>+ )}- {/* Floating close button when no title */}- {!title && showCloseButton && (- <button- type="button"- className="absolute top-3 right-3 text-gray-400 hover:text-gray-500 focus:outline-none z-10"- onClick={onClose}- >- <span className="sr-only">{t('common.close')}</span>- <svg className="h-6 w-6" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="currentColor">- <path strokeLinecap="round" strokeLinejoin="round" d="M6 18L18 6M6 6l12 12" />- </svg>- </button>- )}+ {/* Body */}+ <div className={bodyClassName}>+ {children}+ </div>- {/* Body */}- <div className={bodyClassName}>- {children}+ {/* Footer */}+ {footer && (+ <div className="px-6 py-4 border-t border-gray-200 dark:border-gray-700">+ {footer}+ </div>+ )}</div>-- {/* Footer */}- {footer && (- <div className="px-6 py-4 border-t border-gray-200 dark:border-gray-700">- {footer}- </div>- )}</div></div></div>diff --git a/apps/browser-extension/src/entrypoints/popup/components/Forms/AddFieldMenu.tsx b/apps/browser-extension/src/entrypoints/popup/components/Forms/AddFieldMenu.tsxindex 9e49b589b..645984b65 100644--- a/apps/browser-extension/src/entrypoints/popup/components/Forms/AddFieldMenu.tsx+++ b/apps/browser-extension/src/entrypoints/popup/components/Forms/AddFieldMenu.tsx@@ -215,7 +215,7 @@ const AddFieldMenu: React.FC<AddFieldMenuProps> = ({<>{/* Dark overlay backdrop for better visibility */}<div- className="fixed inset-0 z-10 bg-black bg-opacity-50"+ className="fixed inset-0 z-10 bg-gray-600/50 backdrop-blur-sm dark:bg-black/80"onClick={() => setIsOpen(false)}/><div className="absolute bottom-full left-0 right-0 mb-1 z-20 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-md shadow-lg overflow-hidden">diff --git a/apps/browser-extension/src/entrypoints/popup/components/Items/ItemNameInput.tsx b/apps/browser-extension/src/entrypoints/popup/components/Items/ItemNameInput.tsxindex 87787a66c..c1fc9c4f3 100644--- a/apps/browser-extension/src/entrypoints/popup/components/Items/ItemNameInput.tsx+++ b/apps/browser-extension/src/entrypoints/popup/components/Items/ItemNameInput.tsx@@ -3,6 +3,7 @@ import { buildFolderTree, getFolderIdPath, isSharedFolder, type FolderTreeNode }import React, { useState, useCallback, useMemo, useEffect } from 'react';import { useTranslation } from 'react-i18next';+import ModalWrapper from '@/entrypoints/popup/components/Dialogs/ModalWrapper';import FolderIcon from '@/entrypoints/popup/components/Folders/FolderIcon';import { useDb } from '@/entrypoints/popup/context/DbContext';@@ -242,66 +243,34 @@ const ItemNameInput: React.FC<ItemNameInputProps> = ({</div>{/* Folder Selection Modal */}- {showFolderModal && (- <div className="fixed inset-0 z-50 overflow-y-auto">- {/* Backdrop */}- <div- className="fixed inset-0 bg-black bg-opacity-80 transition-opacity"- onClick={handleCloseFolderModal}- />-- {/* Modal */}- <div className="fixed inset-0 flex items-center justify-center p-4">- <div className="relative transform overflow-hidden rounded-lg bg-white dark:bg-gray-800 px-4 pb-4 pt-5 text-left shadow-xl transition-all w-full max-w-sm">- {/* Close button */}- <button- type="button"- className="absolute right-4 top-4 text-gray-400 hover:text-gray-500 focus:outline-none"- onClick={handleCloseFolderModal}- >- <span className="sr-only">{t('common.close')}</span>- <svg className="h-6 w-6" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="currentColor">- <path strokeLinecap="round" strokeLinejoin="round" d="M6 18L18 6M6 6l12 12" />- </svg>- </button>-- {/* Content */}- <div className="mb-4">- <h3 className="text-lg font-semibold leading-6 text-gray-900 dark:text-white">- {t('items.folder')}- </h3>- </div>-- {/* Folder Options - Tree View */}- <div className="space-y-1 max-h-64 overflow-y-auto">- {/* No Folder Option */}- <button- type="button"- onClick={() => handleSelectFolder(null)}- className={`w-full px-3 py-2 text-left rounded-md flex items-center gap-3 transition-colors ${- !selectedFolderId- ? 'bg-primary-50 dark:bg-primary-900/20 text-primary-700 dark:text-primary-300'- : 'text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700'- }`}- >- <svg className={`w-5 h-5 ${!selectedFolderId ? 'text-primary-500' : 'text-gray-400'}`} fill="none" stroke="currentColor" viewBox="0 0 24 24">- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4" />- </svg>- <span className="font-medium">—</span>- {!selectedFolderId && (- <svg className="w-5 h-5 ml-auto text-primary-600 dark:text-primary-400" fill="currentColor" viewBox="0 0 20 20">- <path fillRule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clipRule="evenodd" />- </svg>- )}- </button>+ <ModalWrapper isOpen={showFolderModal} onClose={handleCloseFolderModal} title={t('items.folder')} maxWidth="max-w-sm">+ {/* Folder Options - Tree View */}+ <div className="space-y-1 max-h-64 overflow-y-auto">+ {/* No Folder Option */}+ <button+ type="button"+ onClick={() => handleSelectFolder(null)}+ className={`w-full px-3 py-2 text-left rounded-md flex items-center gap-3 transition-colors ${+ !selectedFolderId+ ? 'bg-primary-50 dark:bg-primary-900/20 text-primary-700 dark:text-primary-300'+ : 'text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700'+ }`}+ >+ <svg className={`w-5 h-5 ${!selectedFolderId ? 'text-primary-500' : 'text-gray-400'}`} fill="none" stroke="currentColor" viewBox="0 0 24 24">+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4" />+ </svg>+ <span className="font-medium">—</span>+ {!selectedFolderId && (+ <svg className="w-5 h-5 ml-auto text-primary-600 dark:text-primary-400" fill="currentColor" viewBox="0 0 20 20">+ <path fillRule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clipRule="evenodd" />+ </svg>+ )}+ </button>- {/* Folder Tree */}- {folderTree.map(node => renderFolderNode(node, 0))}- </div>- </div>- </div>+ {/* Folder Tree */}+ {folderTree.map(node => renderFolderNode(node, 0))}</div>- )}+ </ModalWrapper></>);};diff --git a/apps/browser-extension/src/entrypoints/popup/pages/settings/VaultUnlockSettings.tsx b/apps/browser-extension/src/entrypoints/popup/pages/settings/VaultUnlockSettings.tsxindex f43faeced..7099f9333 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/settings/VaultUnlockSettings.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/settings/VaultUnlockSettings.tsx@@ -5,6 +5,7 @@ import { useTranslation } from 'react-i18next';import AlertMessage from '@/entrypoints/popup/components/AlertMessage';import Button from '@/entrypoints/popup/components/Button';import HelpModal from '@/entrypoints/popup/components/Dialogs/HelpModal';+import ModalWrapper from '@/entrypoints/popup/components/Dialogs/ModalWrapper';import PageTitle from '@/entrypoints/popup/components/PageTitle';import { useDb } from '@/entrypoints/popup/context/DbContext';import { useLoading } from '@/entrypoints/popup/context/LoadingContext';@@ -80,6 +81,17 @@ const VaultUnlockSettings: React.FC = () => {setShowPinSetup(true);};+ /**+ * Close the PIN setup modal and reset its state.+ */+ const closePinSetup = (): void => {+ setShowPinSetup(false);+ setPinSetupStep(1);+ setNewPin('');+ setConfirmPin('');+ setError(null);+ };+/*** Handle PIN setup submission (step 1: enter PIN).*/@@ -256,89 +268,67 @@ const VaultUnlockSettings: React.FC = () => {</section>{/* PIN Setup Modal */}- {showPinSetup && (- <div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">- <div className="bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md w-full mx-4 relative">- {/* Cancel button in top right corner */}- <button- type="button"- onClick={() => {- setShowPinSetup(false);- setPinSetupStep(1);- setNewPin('');- setConfirmPin('');- setError(null);- }}- className="absolute top-4 right-4 text-gray-400 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300 transition-colors"- aria-label="Cancel"- >- <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />- </svg>- </button>-- {/* Step 1: Enter PIN */}- {pinSetupStep === 1 && (- <>- <h3 className="text-lg font-semibold text-gray-900 dark:text-white mb-4 pr-8">- {t('settings.unlockMethod.setupPin')}- </h3>- <p className="text-sm text-gray-600 dark:text-gray-400 mb-4">- {t('settings.unlockMethod.enterNewPinDescription')}- </p>- <form onSubmit={handlePinSetupNext}>- <div className="mb-4">- <input- type="password"- inputMode="numeric"- pattern="[0-9]*"- maxLength={8}- value={newPin}- onChange={(e) => setNewPin(e.target.value.replace(/\D/g, ''))}- className="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white text-center text-2xl tracking-widest"- autoFocus- />- </div>- {error && <AlertMessage type="error" message={error} className="mb-4" />}- <Button type="submit">- {t('common.next')}- </Button>- </form>- </>- )}-- {/* Step 2: Confirm PIN */}- {pinSetupStep === 2 && (- <>- <h3 className="text-lg font-semibold text-gray-900 dark:text-white mb-4 pr-8">- {t('settings.unlockMethod.confirmPin')}- </h3>- <p className="text-sm text-gray-600 dark:text-gray-400 mb-4">- {t('settings.unlockMethod.confirmPinDescription')}- </p>- <form onSubmit={handlePinSetupSubmit}>- <div className="mb-4">- <input- type="password"- inputMode="numeric"- pattern="[0-9]*"- maxLength={8}- value={confirmPin}- onChange={(e) => setConfirmPin(e.target.value.replace(/\D/g, ''))}- className="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white text-center text-2xl tracking-widest"- autoFocus- />- </div>- {error && <AlertMessage type="error" message={error} className="mb-4" />}- <Button type="submit">- {t('common.confirm')}- </Button>- </form>- </>- )}- </div>- </div>- )}+ <ModalWrapper isOpen={showPinSetup} onClose={closePinSetup} bodyClassName="p-6">+ {/* Step 1: Enter PIN */}+ {pinSetupStep === 1 && (+ <>+ <h3 className="text-lg font-semibold text-gray-900 dark:text-white mb-4 pr-8">+ {t('settings.unlockMethod.setupPin')}+ </h3>+ <p className="text-sm text-gray-600 dark:text-gray-400 mb-4">+ {t('settings.unlockMethod.enterNewPinDescription')}+ </p>+ <form onSubmit={handlePinSetupNext}>+ <div className="mb-4">+ <input+ type="password"+ inputMode="numeric"+ pattern="[0-9]*"+ maxLength={8}+ value={newPin}+ onChange={(e) => setNewPin(e.target.value.replace(/\D/g, ''))}+ className="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white text-center text-2xl tracking-widest"+ autoFocus+ />+ </div>+ {error && <AlertMessage type="error" message={error} className="mb-4" />}+ <Button type="submit">+ {t('common.next')}+ </Button>+ </form>+ </>+ )}++ {/* Step 2: Confirm PIN */}+ {pinSetupStep === 2 && (+ <>+ <h3 className="text-lg font-semibold text-gray-900 dark:text-white mb-4 pr-8">+ {t('settings.unlockMethod.confirmPin')}+ </h3>+ <p className="text-sm text-gray-600 dark:text-gray-400 mb-4">+ {t('settings.unlockMethod.confirmPinDescription')}+ </p>+ <form onSubmit={handlePinSetupSubmit}>+ <div className="mb-4">+ <input+ type="password"+ inputMode="numeric"+ pattern="[0-9]*"+ maxLength={8}+ value={confirmPin}+ onChange={(e) => setConfirmPin(e.target.value.replace(/\D/g, ''))}+ className="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white text-center text-2xl tracking-widest"+ autoFocus+ />+ </div>+ {error && <AlertMessage type="error" message={error} className="mb-4" />}+ <Button type="submit">+ {t('common.confirm')}+ </Button>+ </form>+ </>+ )}+ </ModalWrapper></div></>);