feat: add error boundary, glass shimmer skeleton, empty state
- Create ErrorBoundary class component with GlassCard fallback UI - Update LoadingSkeleton with glass shimmer animation overlay - Update EmptyState with GlassPanel and default Inbox icon - Add ErrorBoundary to shared components index export Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
2b06d82450
commit
1c6f98117a
@@ -0,0 +1,35 @@
|
||||
"use client";
|
||||
|
||||
import { Component, type ReactNode } from "react";
|
||||
import { GlassCard } from "@/components/glass/card";
|
||||
import { AlertCircle, RefreshCw } from "lucide-react";
|
||||
|
||||
interface Props { children: ReactNode; fallback?: ReactNode; }
|
||||
interface State { hasError: boolean; error?: Error; }
|
||||
|
||||
export class ErrorBoundary extends Component<Props, State> {
|
||||
state: State = { hasError: false };
|
||||
|
||||
static getDerivedStateFromError(error: Error): State {
|
||||
return { hasError: true, error };
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.hasError) {
|
||||
return this.props.fallback || (
|
||||
<GlassCard variant="danger" className="flex flex-col items-center gap-2 py-8">
|
||||
<AlertCircle className="size-6 text-destructive" />
|
||||
<p className="text-sm text-text-secondary">{this.state.error?.message || "Something went wrong"}</p>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => this.setState({ hasError: false })}
|
||||
className="flex items-center gap-1 text-xs text-primary hover:text-primary/80 transition-colors"
|
||||
>
|
||||
<RefreshCw className="size-3" /> Try again
|
||||
</button>
|
||||
</GlassCard>
|
||||
);
|
||||
}
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user