veza/apps/web/src/components/settings/security/PasskeyModal.tsx

124 lines
4.2 KiB
TypeScript
Raw Normal View History

import React, { useState } from 'react';
import { Button } from '../../ui/button';
import { Input } from '../../ui/input';
import { Fingerprint, X, Loader2, CheckCircle } from 'lucide-react';
import { useToast } from '../../../components/feedback/ToastProvider';
interface PasskeyModalProps {
onClose: () => void;
onSuccess: () => void;
}
export const PasskeyModal: React.FC<PasskeyModalProps> = ({
onClose,
onSuccess,
}) => {
const { addToast } = useToast();
const [passkeyName, setPasskeyName] = useState('');
const [_loading, _setLoading] = useState(false);
const [step, _setStep] = useState<'name' | 'registering' | 'success'>('name');
const handleCreate = () => {
if (!passkeyName) {
addToast('Please name your passkey', 'error');
return;
}
2026-01-07 18:39:21 +00:00
_setStep('registering');
_setLoading(true);
// Simulate WebAuthn API call
setTimeout(() => {
2026-01-07 18:39:21 +00:00
_setLoading(false);
_setStep('success');
addToast('Passkey created successfully', 'success');
}, 2000);
};
return (
<div className="fixed inset-0 z-[100] flex items-center justify-center p-4">
<div
className="absolute inset-0 bg-kodo-void/90 backdrop-blur-sm"
onClick={onClose}
></div>
<div className="relative w-full max-w-md bg-kodo-graphite border border-kodo-steel rounded-xl shadow-2xl overflow-hidden animate-scaleIn">
<div className="p-4 border-b border-kodo-steel bg-kodo-ink flex justify-between items-center">
<h3 className="font-bold text-white flex items-center gap-2">
aesthetic-improvements: reduce decorative cyan across multiple component categories (80/20 rule, batch 11) - Social: FeedView, ConnectionsView, GroupsView, ExploreView, GroupDetailView loading spinners and decorative text, CreatePostModal decorative select text and hashtag links, PostCard decorative tag links and waveform bars and view comments link, CreateGroupModal decorative icon (9 instances) - Settings: DataExportModal decorative icon, LoginHistory decorative IP text, AppearanceSettingsView decorative icon and selected theme checkmark, BackupsView decorative icon, CloudIntegrationView decorative icon, AccessibilitySettingsView decorative icon, SecuritySettings decorative icon, PasskeyModal decorative icon and loading spinner (8 instances) - Studio: ProjectsManager loading spinner and progress percentage text, CloudFileBrowser decorative music icons, AIToolsView decorative music icon, ConnectivityView decorative icon, CreateProjectModal decorative icon, CloudSettingsView decorative icon (6 instances) - Admin: AdminDashboardView loading spinner and decorative chart bars and icon, AdminSettingsView decorative icon, AdminModerationView loading spinner, AdminUsersView loading spinner (5 instances) - Inventory: InventoryView loading spinner, EquipmentCard decorative price icon, EquipmentDetailView loading spinner and decorative icons and price text, AddEquipmentView decorative icon (5 instances) - Seller: CreateProductView decorative icon, SellerDashboardView loading spinner and decorative icon and sales text (3 instances) - Live: LiveStreamDetailView decorative streamer name text (1 instance) - Developer: DeveloperDashboardView loading spinner, WebhooksView decorative icon (2 instances) - Upload: BulkUploadModal decorative icon, FilePreviewCard decorative audio file icon, MetadataForm decorative button text, CoverArtUploadModal decorative icon, LyricsEditorModal decorative icon (5 instances) - Notifications: NotificationItem decorative follow icon and mark as read button, NotificationBell decorative mark all read link (3 instances) - Total: ~46 files, ~46 instances replaced - Preserved: Active/selected states (CloudFileBrowser selected files checkmarks, CreatePostModal post type active state, GroupCard/GroupDetailView public/private badges - semantic indicators, DataExportModal checkbox accents - focus/interaction, AppearanceSettingsView selected theme - active state, PasskeyModal checkbox accent - focus/interaction, LyricsEditorModal checkbox accent - focus/interaction, FileUploadZone drag active state - active state, EquipmentDetailView support link - functional link, FlashSaleModal link - functional link, EquipmentDetailView image indicator dots - active state), primary actions, design system variants - Action 11.3.1.3 in progress (eleventh batch: social, settings, studio, admin, inventory, seller, live, developer, upload, notifications components)
2026-01-16 10:26:33 +00:00
<Fingerprint className="w-4 h-4 text-kodo-steel" /> Add Passkey
</h3>
<button onClick={onClose}>
<X className="w-5 h-5 text-kodo-content-dim hover:text-white" />
</button>
</div>
<div className="p-6">
{step === 'name' && (
<div className="space-y-4">
<div className="text-center mb-6">
<div className="w-16 h-16 bg-kodo-steel/10 rounded-full flex items-center justify-center mx-auto mb-4">
<Fingerprint className="w-8 h-8 text-kodo-steel" />
</div>
<p className="text-sm text-kodo-text-main">
Passkeys allow you to sign in safely using your fingerprint,
face, or device PIN.
</p>
</div>
2026-01-07 18:39:21 +00:00
<Input
label="Passkey Name"
placeholder="e.g. MacBook Pro, iPhone 13"
value={passkeyName}
onChange={(e) => setPasskeyName(e.target.value)}
autoFocus
/>
<div className="pt-2">
<Button
variant="primary"
className="w-full"
onClick={handleCreate}
>
Create Passkey
</Button>
</div>
</div>
)}
{step === 'registering' && (
<div className="text-center py-8">
aesthetic-improvements: reduce decorative cyan across multiple component categories (80/20 rule, batch 11) - Social: FeedView, ConnectionsView, GroupsView, ExploreView, GroupDetailView loading spinners and decorative text, CreatePostModal decorative select text and hashtag links, PostCard decorative tag links and waveform bars and view comments link, CreateGroupModal decorative icon (9 instances) - Settings: DataExportModal decorative icon, LoginHistory decorative IP text, AppearanceSettingsView decorative icon and selected theme checkmark, BackupsView decorative icon, CloudIntegrationView decorative icon, AccessibilitySettingsView decorative icon, SecuritySettings decorative icon, PasskeyModal decorative icon and loading spinner (8 instances) - Studio: ProjectsManager loading spinner and progress percentage text, CloudFileBrowser decorative music icons, AIToolsView decorative music icon, ConnectivityView decorative icon, CreateProjectModal decorative icon, CloudSettingsView decorative icon (6 instances) - Admin: AdminDashboardView loading spinner and decorative chart bars and icon, AdminSettingsView decorative icon, AdminModerationView loading spinner, AdminUsersView loading spinner (5 instances) - Inventory: InventoryView loading spinner, EquipmentCard decorative price icon, EquipmentDetailView loading spinner and decorative icons and price text, AddEquipmentView decorative icon (5 instances) - Seller: CreateProductView decorative icon, SellerDashboardView loading spinner and decorative icon and sales text (3 instances) - Live: LiveStreamDetailView decorative streamer name text (1 instance) - Developer: DeveloperDashboardView loading spinner, WebhooksView decorative icon (2 instances) - Upload: BulkUploadModal decorative icon, FilePreviewCard decorative audio file icon, MetadataForm decorative button text, CoverArtUploadModal decorative icon, LyricsEditorModal decorative icon (5 instances) - Notifications: NotificationItem decorative follow icon and mark as read button, NotificationBell decorative mark all read link (3 instances) - Total: ~46 files, ~46 instances replaced - Preserved: Active/selected states (CloudFileBrowser selected files checkmarks, CreatePostModal post type active state, GroupCard/GroupDetailView public/private badges - semantic indicators, DataExportModal checkbox accents - focus/interaction, AppearanceSettingsView selected theme - active state, PasskeyModal checkbox accent - focus/interaction, LyricsEditorModal checkbox accent - focus/interaction, FileUploadZone drag active state - active state, EquipmentDetailView support link - functional link, FlashSaleModal link - functional link, EquipmentDetailView image indicator dots - active state), primary actions, design system variants - Action 11.3.1.3 in progress (eleventh batch: social, settings, studio, admin, inventory, seller, live, developer, upload, notifications components)
2026-01-16 10:26:33 +00:00
<Loader2 className="w-12 h-12 text-kodo-steel animate-spin mx-auto mb-4" />
<h4 className="text-lg font-bold text-white mb-2">
Waiting for device...
</h4>
<p className="text-sm text-kodo-content-dim">
Follow the instructions on your device/browser.
</p>
</div>
)}
{step === 'success' && (
<div className="text-center py-4">
<div className="w-16 h-16 bg-kodo-lime/20 rounded-full flex items-center justify-center mx-auto mb-4 text-kodo-lime">
<CheckCircle className="w-8 h-8" />
</div>
<h4 className="text-xl font-bold text-white mb-2">
Passkey Added!
</h4>
<p className="text-sm text-kodo-content-dim mb-6">
You can now use this device to log in.
</p>
<Button
variant="primary"
className="w-full"
onClick={() => {
onSuccess();
onClose();
}}
>
Done
</Button>
</div>
)}
</div>
</div>
</div>
);
};