Add foundational components and logic for migration, UI design, and input handling
- Introduced foundational UI components (`Badge`, `LockCard`, `SectionHeader`, `AvatarIcon`, etc.) for flexible layouts and consistent design. - Added migration support with the `MigrationModal` component and backend integration for exporting/importing data between Electron and Tauri. - Extended form components with `TextAreaInput`, `OrderInput`, `ToggleField`, and `ToolbarSelect` for improved input handling. - Updated `ScribeShell` with migration popup logic to prompt users for data migration. - Integrated `AlertStack` for better alert handling and notification management. - Enhanced Rust/Tauri services with migration command implementations. - Added translations and styles for new components.
This commit is contained in:
44
components/ui/AlertStack.tsx
Normal file
44
components/ui/AlertStack.tsx
Normal file
@@ -0,0 +1,44 @@
|
||||
'use client';
|
||||
|
||||
import React from 'react';
|
||||
import {createPortal} from 'react-dom';
|
||||
import StaticAlert from '@/components/ui/StaticAlert';
|
||||
import {Alert} from '@/context/AlertProvider';
|
||||
|
||||
interface AlertStackProps {
|
||||
alerts: Alert[];
|
||||
onClose: (id: string) => void;
|
||||
}
|
||||
|
||||
export default function AlertStack({alerts, onClose}: AlertStackProps) {
|
||||
const [mounted, setMounted] = React.useState(false);
|
||||
|
||||
React.useEffect(() => {
|
||||
setMounted(true);
|
||||
return () => setMounted(false);
|
||||
}, []);
|
||||
|
||||
if (!mounted) return null;
|
||||
|
||||
const alertContent = (
|
||||
<div className="fixed top-4 right-4 z-50 flex flex-col gap-3 pointer-events-none">
|
||||
{alerts.map((alert, index) => (
|
||||
<div
|
||||
key={alert.id}
|
||||
className="pointer-events-auto alert-slide-in"
|
||||
ref={(el: HTMLDivElement | null): void => {
|
||||
if (el) el.style.animationDelay = `${index * 50}ms`;
|
||||
}}
|
||||
>
|
||||
<StaticAlert
|
||||
type={alert.type}
|
||||
message={alert.message}
|
||||
onClose={() => onClose(alert.id)}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
|
||||
return createPortal(alertContent, document.body);
|
||||
}
|
||||
Reference in New Issue
Block a user