Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add auth form components (#2413)
Leendert de Borst61b6a93d9214
diff --git a/apps/web/src/components/auth/InputTextField.tsx b/apps/web/src/components/auth/InputTextField.tsxnew file mode 100644index 000000000..be9b552ff--- /dev/null+++ b/apps/web/src/components/auth/InputTextField.tsx@@ -0,0 +1,25 @@+import React, { forwardRef } from 'react';++type InputTextFieldProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'value'> & {+ id: string;+ value: string;+ onValueChange: (value: string) => void;+};++/**+ * Text input with the auth form styling.+ */+const InputTextField = forwardRef<HTMLInputElement, InputTextFieldProps>(({ id, value, onValueChange, ...rest }, ref) => (+ <input+ ref={ref}+ id={id}+ value={value}+ onChange={(e) => onValueChange(e.target.value)}+ className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500"+ {...rest}+ />+));++InputTextField.displayName = 'InputTextField';++export default InputTextField;diff --git a/apps/web/src/components/auth/LanguageSwitcher.tsx b/apps/web/src/components/auth/LanguageSwitcher.tsxnew file mode 100644index 000000000..f0a679e47--- /dev/null+++ b/apps/web/src/components/auth/LanguageSwitcher.tsx@@ -0,0 +1,31 @@+import React from 'react';+import { useTranslation } from 'react-i18next';++import { AVAILABLE_LANGUAGES } from '@/i18n/config';+import { changeLanguage } from '@/i18n/i18n';++/**+ * Language selector shown on the auth pages.+ */+const LanguageSwitcher: React.FC = () => {+ const { t, i18n } = useTranslation();++ return (+ <div className="relative inline-block">+ <select+ value={i18n.language}+ onChange={(e) => void changeLanguage(e.target.value)}+ aria-label={t('pages.main.settings.general.AppLanguageLabel')}+ className="appearance-none cursor-pointer pl-3 pr-9 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 dark:focus:ring-offset-gray-800">+ {AVAILABLE_LANGUAGES.map((language) => (+ <option key={language.code} value={language.code}>{language.flag} {language.nativeName}</option>+ ))}+ </select>+ <svg className="w-4 h-4 absolute right-2.5 top-1/2 -translate-y-1/2 pointer-events-none text-gray-500 dark:text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="m19 9-7 7-7-7"></path>+ </svg>+ </div>+ );+};++export default LanguageSwitcher;diff --git a/apps/web/src/components/auth/Logo.tsx b/apps/web/src/components/auth/Logo.tsxnew file mode 100644index 000000000..c273642ed--- /dev/null+++ b/apps/web/src/components/auth/Logo.tsx@@ -0,0 +1,19 @@+import React from 'react';+import { Link } from 'react-router-dom';++/**+ * The AliasVault logo shown above the auth cards.+ */+const Logo: React.FC = () => (+ <Link to="/">+ <div className="text-5xl font-bold text-gray-900 dark:text-white mb-4 flex items-center mt-12 lg:mt-0">+ <img src="/img/logo.svg" alt="AliasVault" className="w-20 h-20 mr-2" />+ <span className="relative inline-flex flex-wrap items-center">+ AliasVault+ <span className="ml-2 bg-primary-500 text-white text-xs px-2 py-0.5 rounded-full font-normal sm:-top-2 sm:ml-1">BETA</span>+ </span>+ </div>+ </Link>+);++export default Logo;diff --git a/apps/web/src/components/auth/PasswordInputField.tsx b/apps/web/src/components/auth/PasswordInputField.tsxnew file mode 100644index 000000000..48525d489--- /dev/null+++ b/apps/web/src/components/auth/PasswordInputField.tsx@@ -0,0 +1,52 @@+import React, { forwardRef, useState } from 'react';++type PasswordInputFieldProps = {+ id: string;+ value: string;+ onValueChange: (value: string) => void;+ placeholder?: string;+ autoFocus?: boolean;+};++/**+ * Password input with a show/hide toggle.+ */+const PasswordInputField = forwardRef<HTMLInputElement, PasswordInputFieldProps>(({ id, value, onValueChange, placeholder = '', autoFocus = false }, ref) => {+ const [showPassword, setShowPassword] = useState(false);++ return (+ <div className="relative">+ <input+ ref={ref}+ id={id}+ value={value}+ onChange={(e) => onValueChange(e.target.value)}+ type={showPassword ? 'text' : 'password'}+ placeholder={placeholder}+ autoComplete="off"+ autoFocus={autoFocus}+ className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:outline-none focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 pr-10 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500"+ />+ <button+ type="button"+ onClick={() => setShowPassword(!showPassword)}+ className="absolute inset-y-0 right-0 flex items-center pr-3 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"+ aria-label={showPassword ? 'Hide password' : 'Show password'}>+ {showPassword ? (+ <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"></path>+ </svg>+ ) : (+ <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path>+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"></path>+ </svg>+ )}+ </button>+ </div>+ );+});++PasswordInputField.displayName = 'PasswordInputField';++export default PasswordInputField;