- Add CSS clamp() for fluid font-size scaling (16px to 20px based on viewport) - Apply responsive breakpoint classes to all components: * text-xs → lg:text-sm xl:text-base * text-sm → lg:text-base xl:text-lg * text-base → lg:text-lg xl:text-xl * text-lg → lg:text-xl xl:text-2xl * text-xl → lg:text-2xl xl:text-3xl * text-2xl → lg:text-3xl xl:text-4xl * text-3xl → lg:text-4xl xl:text-5xl - Apply responsive padding/spacing scaling proportionally - Updated 27 component and page files - Build verified: 6 routes, zero TypeScript errors - Fixes readability on MacBook Pro 14" and other desktop screens without browser zoom
146 lines
8.3 KiB
TypeScript
146 lines
8.3 KiB
TypeScript
import React from 'react';
|
|
import { User, UserPlus, Shield, Edit2, Trash2, X } from 'lucide-react';
|
|
import { cn } from '@/lib/utils';
|
|
|
|
interface IdentityManagerProps {
|
|
users: any[];
|
|
onAddUser: () => void;
|
|
onDeleteUser: (id: number, username: string) => void;
|
|
editingUser: any | null;
|
|
setEditingUser: (user: any | null) => void;
|
|
editUserForm: any;
|
|
setEditUserForm: (form: any) => void;
|
|
onUpdateUserSubmit: () => void;
|
|
}
|
|
|
|
export default function IdentityManager({
|
|
users,
|
|
onAddUser,
|
|
onDeleteUser,
|
|
editingUser,
|
|
setEditingUser,
|
|
editUserForm,
|
|
setEditUserForm,
|
|
onUpdateUserSubmit
|
|
}: IdentityManagerProps) {
|
|
return (
|
|
<div className="bg-surface/50 border border-slate-800/50 rounded-[2.5rem] p-5 md:p-8 flex flex-col shadow-2xl transition-all group/identity h-full">
|
|
<div className="flex items-center justify-between mb-6">
|
|
<div className="flex items-center gap-4">
|
|
<div className="w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center text-primary border border-primary/20">
|
|
<User size={20} />
|
|
</div>
|
|
<h2 className="text-xl lg:text-2xl xl:text-3xl lg:text-4xl xl:text-5xl font-black text-white tracking-tight">Identity Management</h2>
|
|
</div>
|
|
<button
|
|
onClick={onAddUser}
|
|
data-testid="add-user-button"
|
|
className="flex items-center gap-2 px-5 py-2 lg:py-3 xl:py-4.5 bg-primary hover:bg-blue-600 text-white rounded-xl text-sm lg:text-base xl:text-lg lg:text-xl xl:text-2xl lg:text-3xl xl:text-4xl font-black transition-all shadow-xl shadow-primary/10 active:scale-95 border border-primary/30 tracking-tight focus-visible:ring-2 focus-visible:ring-primary focus-visible:outline-none"
|
|
aria-label="Add new user"
|
|
>
|
|
<UserPlus size={16} /> Add User
|
|
</button>
|
|
</div>
|
|
|
|
<div className="flex-1 space-y-2.5 pr-2 -mr-2 overflow-y-auto max-h-[400px] scrollbar-thin scrollbar-thumb-slate-800 scrollbar-track-transparent">
|
|
{users.map((user) => (
|
|
<div key={user.id} className="flex items-center justify-between p-3 lg:p-4 xl:p-5 lg:p-6 xl:p-8.5 bg-background/40 border border-slate-800/40 rounded-2xl hover:border-primary/30 transition-all group">
|
|
<div className="flex items-center gap-3 min-w-0">
|
|
<div className={cn(
|
|
"w-9 h-9 rounded-xl flex items-center justify-center transition-colors shadow-inner shrink-0",
|
|
user.role === 'admin' ? "bg-primary/10 text-primary border border-primary/20" : "bg-slate-800 text-muted border border-slate-700"
|
|
)}>
|
|
{user.role === 'admin' ? <Shield size={16} /> : <User size={16} />}
|
|
</div>
|
|
<div className="min-w-0">
|
|
<p className="card-title truncate">{user.username}</p>
|
|
<p className="card-subtitle">{user.role}</p>
|
|
</div>
|
|
</div>
|
|
<div className="flex items-center gap-1.5 ml-2">
|
|
<button
|
|
onClick={() => {
|
|
setEditingUser(user);
|
|
setEditUserForm({ username: user.username, password: '', role: user.role });
|
|
}}
|
|
className="p-2 lg:p-3 xl:p-4 lg:p-5 xl:p-6 lg:p-8 xl:p-10 text-secondary hover:text-primary hover:bg-primary/5 rounded-xl transition-all focus-visible:ring-2 focus-visible:ring-primary focus-visible:outline-none"
|
|
aria-label={`Edit user ${user.username}`}
|
|
>
|
|
<Edit2 size={16} />
|
|
</button>
|
|
{user.username !== 'Admin' && (
|
|
<button
|
|
onClick={() => onDeleteUser(user.id, user.username)}
|
|
data-testid="delete-user-button"
|
|
className="p-2 lg:p-3 xl:p-4 lg:p-5 xl:p-6 lg:p-8 xl:p-10 text-secondary hover:text-rose-500 hover:bg-rose-500/5 rounded-xl transition-all focus-visible:ring-2 focus-visible:ring-rose-500 focus-visible:outline-none"
|
|
aria-label={`Delete user ${user.username}`}
|
|
>
|
|
<Trash2 size={16} />
|
|
</button>
|
|
)}
|
|
</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
|
|
{/* Edit User Modal */}
|
|
{editingUser && (
|
|
<div className="fixed inset-0 z-[100] flex items-center justify-center p-4 lg:p-5 xl:p-6 lg:p-8 xl:p-10 bg-background/80 animate-in fade-in duration-200">
|
|
<div className="bg-surface border border-slate-800 rounded-[2.5rem] p-8 w-full max-w-md shadow-2xl">
|
|
<div className="flex justify-between items-center mb-6">
|
|
<h3 className="text-xl lg:text-2xl xl:text-3xl lg:text-4xl xl:text-5xl font-black text-white tracking-tight">Edit Identity</h3>
|
|
<button
|
|
onClick={() => setEditingUser(null)}
|
|
className="p-2 lg:p-3 xl:p-4 lg:p-5 xl:p-6 lg:p-8 xl:p-10 text-muted hover:text-white transition-colors focus-visible:ring-2 focus-visible:ring-primary focus-visible:outline-none rounded"
|
|
aria-label="Close edit dialog"
|
|
>
|
|
<X size={20} />
|
|
</button>
|
|
</div>
|
|
|
|
<div className="space-y-4">
|
|
<div className="space-y-1.5">
|
|
<label className="text-sm lg:text-base xl:text-lg lg:text-xl xl:text-2xl lg:text-3xl xl:text-4xl font-bold text-secondary tracking-tight ml-1">Username</label>
|
|
<input
|
|
type="text"
|
|
value={editUserForm.username}
|
|
onChange={(e) => setEditUserForm({ ...editUserForm, username: e.target.value })}
|
|
className="w-full bg-background/80 border border-slate-800 rounded-2xl py-3 lg:py-4 xl:py-5 px-4 lg:px-5 xl:px-6 text-sm lg:text-base xl:text-lg lg:text-xl xl:text-2xl lg:text-3xl xl:text-4xl font-bold text-white outline-none focus:border-primary/50 focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-0 transition-all font-mono"
|
|
/>
|
|
</div>
|
|
<div className="space-y-1.5">
|
|
<label className="text-sm lg:text-base xl:text-lg lg:text-xl xl:text-2xl lg:text-3xl xl:text-4xl font-bold text-secondary tracking-tight ml-1">New Password (Leave Empty To Keep)</label>
|
|
<input
|
|
type="password"
|
|
value={editUserForm.password}
|
|
onChange={(e) => setEditUserForm({ ...editUserForm, password: e.target.value })}
|
|
placeholder="********"
|
|
className="w-full bg-background/80 border border-slate-800 rounded-2xl py-3 lg:py-4 xl:py-5 px-4 lg:px-5 xl:px-6 text-sm lg:text-base xl:text-lg lg:text-xl xl:text-2xl lg:text-3xl xl:text-4xl font-bold text-white outline-none focus:border-primary/50 focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-0 transition-all font-mono"
|
|
/>
|
|
</div>
|
|
<div className="space-y-1.5">
|
|
<label className="text-sm lg:text-base xl:text-lg lg:text-xl xl:text-2xl lg:text-3xl xl:text-4xl font-bold text-secondary tracking-tight ml-1">Role</label>
|
|
<select
|
|
value={editUserForm.role}
|
|
onChange={(e) => setEditUserForm({ ...editUserForm, role: e.target.value })}
|
|
className="w-full bg-background/80 border border-slate-800 rounded-2xl py-3 lg:py-4 xl:py-5 px-4 lg:px-5 xl:px-6 text-sm lg:text-base xl:text-lg lg:text-xl xl:text-2xl lg:text-3xl xl:text-4xl font-bold text-white outline-none focus:border-primary/50 transition-all appearance-none"
|
|
>
|
|
<option value="user">Standard User</option>
|
|
<option value="admin">Administrator</option>
|
|
</select>
|
|
</div>
|
|
|
|
<button
|
|
onClick={onUpdateUserSubmit}
|
|
className="w-full bg-primary hover:bg-primary/80 text-white rounded-2xl py-4 text-sm lg:text-base xl:text-lg lg:text-xl xl:text-2xl lg:text-3xl xl:text-4xl font-black transition-all active:scale-95 shadow-xl shadow-primary/20 tracking-tight mt-4 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-slate-900 focus-visible:ring-primary focus-visible:outline-none"
|
|
>
|
|
Apply Changes
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|