forked from Nova-reward/Nova-Rewards
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInlineError.tsx
More file actions
49 lines (44 loc) · 1.16 KB
/
Copy pathInlineError.tsx
File metadata and controls
49 lines (44 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import React from 'react';
import { motion } from 'framer-motion';
import { AlertCircle, RefreshCw } from 'lucide-react';
export interface InlineErrorProps {
message: string;
onRetry?: () => void;
size?: 'sm' | 'md' | 'lg';
}
const sizeClasses = {
sm: 'text-xs p-2 gap-1',
md: 'text-sm p-3 gap-2',
lg: 'text-base p-4 gap-3',
};
const iconSizes = {
sm: 'h-3 w-3',
md: 'h-4 w-4',
lg: 'h-5 w-5',
};
export const InlineError: React.FC<InlineErrorProps> = ({
message,
onRetry,
size = 'md',
}) => {
return (
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
className={`flex items-center rounded-lg bg-red-50 text-red-800 dark:bg-red-950/20 dark:text-red-200 ${sizeClasses[size]}`}
>
<AlertCircle className={`flex-shrink-0 ${iconSizes[size]}`} />
<span className="flex-1">{message}</span>
{onRetry && (
<button
onClick={onRetry}
className="ml-2 rounded hover:bg-red-100 dark:hover:bg-red-900/30 p-1"
aria-label="Retry"
>
<RefreshCw className={`${iconSizes[size]}`} />
</button>
)}
</motion.div>
);
};
export default InlineError;