refactor(ui): polish alert feed surface
This commit is contained in:
parent
4f152b4b45
commit
92e717509d
@ -1,17 +1,43 @@
|
|||||||
.alert-feed {
|
.alert-feed {
|
||||||
background: linear-gradient(135deg, var(--card) 0%, var(--card-elevated) 100%);
|
|
||||||
border-radius: 16px;
|
|
||||||
padding: 24px;
|
|
||||||
box-shadow: var(--card-shadow);
|
|
||||||
border: 1px solid var(--border);
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 18px;
|
||||||
|
background: var(--card);
|
||||||
|
padding: 22px;
|
||||||
|
box-shadow: var(--card-shadow);
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert-feed-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 12px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert-feed-title-icon {
|
||||||
|
display: grid;
|
||||||
|
width: 34px;
|
||||||
|
height: 34px;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
place-items: center;
|
||||||
|
border: 1px solid color-mix(in oklab, var(--accent) 24%, var(--border));
|
||||||
|
border-radius: 12px;
|
||||||
|
background: var(--accent-soft);
|
||||||
|
color: var(--accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert-feed h2 {
|
.alert-feed h2 {
|
||||||
|
margin: 0;
|
||||||
color: var(--foreground);
|
color: var(--foreground);
|
||||||
font-size: 20px;
|
font-size: 18px;
|
||||||
font-weight: 700;
|
font-weight: 820;
|
||||||
margin: 0 0 20px 0;
|
letter-spacing: 0;
|
||||||
letter-spacing: 0.5px;
|
}
|
||||||
|
|
||||||
|
.alert-feed-header p {
|
||||||
|
margin: 4px 0 0;
|
||||||
|
color: var(--muted-foreground);
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alerts-container {
|
.alerts-container {
|
||||||
@ -63,15 +89,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.alert-item {
|
.alert-item {
|
||||||
display: flex;
|
display: grid;
|
||||||
|
grid-template-columns: auto minmax(0, 1fr);
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
padding: 16px;
|
|
||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
|
padding: 16px;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
background: color-mix(in oklab, var(--foreground) 3%, transparent);
|
|
||||||
border: 1px solid var(--border);
|
border: 1px solid var(--border);
|
||||||
transition: all 0.2s;
|
background: color-mix(in oklab, var(--muted) 42%, var(--card));
|
||||||
animation: slideIn 0.3s ease;
|
animation: slideIn 0.3s ease;
|
||||||
|
transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes slideIn {
|
@keyframes slideIn {
|
||||||
@ -87,8 +114,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.alert-item:hover {
|
.alert-item:hover {
|
||||||
background: var(--muted);
|
border-color: var(--border-strong);
|
||||||
transform: translateX(4px);
|
background: color-mix(in oklab, var(--accent-soft) 34%, var(--card));
|
||||||
|
transform: translateY(-1px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert-signal {
|
.alert-signal {
|
||||||
@ -108,27 +136,40 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.alert-icon {
|
.alert-icon {
|
||||||
font-size: 24px;
|
display: grid;
|
||||||
flex-shrink: 0;
|
width: 34px;
|
||||||
|
height: 34px;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
place-items: center;
|
||||||
|
border-radius: 12px;
|
||||||
|
background: var(--muted);
|
||||||
|
color: var(--muted-foreground);
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert-content {
|
.alert-content {
|
||||||
flex: 1;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert-header {
|
.alert-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
margin-bottom: 6px;
|
margin-bottom: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert-symbol {
|
.alert-symbol {
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
color: var(--foreground);
|
color: var(--foreground);
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert-time {
|
.alert-time {
|
||||||
|
flex: 0 0 auto;
|
||||||
color: var(--muted-foreground);
|
color: var(--muted-foreground);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
@ -137,4 +178,20 @@
|
|||||||
color: var(--muted-foreground);
|
color: var(--muted-foreground);
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert-signal .alert-icon {
|
||||||
|
background: var(--bl-success-muted);
|
||||||
|
color: var(--bl-success);
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert-pulse .alert-icon {
|
||||||
|
background: var(--bl-info-muted);
|
||||||
|
color: var(--bl-info);
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert-error .alert-icon {
|
||||||
|
background: var(--bl-danger-muted);
|
||||||
|
color: var(--bl-danger);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ describe('AlertFeed DOM behavior', () => {
|
|||||||
expect(screen.getByText('Recent Activity')).toBeInTheDocument();
|
expect(screen.getByText('Recent Activity')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders different alert types with correct icons', () => {
|
it('renders different alert types with messages', () => {
|
||||||
const alerts: any[] = [
|
const alerts: any[] = [
|
||||||
{ timestamp: Date.now(), type: 'signal', symbol: 'BTC', message: 'Signal Alert' },
|
{ timestamp: Date.now(), type: 'signal', symbol: 'BTC', message: 'Signal Alert' },
|
||||||
{ timestamp: Date.now(), type: 'pulse', symbol: 'ETH', message: 'Pulse Alert' },
|
{ timestamp: Date.now(), type: 'pulse', symbol: 'ETH', message: 'Pulse Alert' },
|
||||||
@ -28,13 +28,8 @@ describe('AlertFeed DOM behavior', () => {
|
|||||||
|
|
||||||
render(<AlertFeed alerts={alerts} />);
|
render(<AlertFeed alerts={alerts} />);
|
||||||
|
|
||||||
expect(screen.getByText('🚀')).toBeInTheDocument();
|
expect(screen.getByText('Signal Alert')).toBeInTheDocument();
|
||||||
expect(screen.getByText('⏰')).toBeInTheDocument();
|
expect(screen.getByText('Pulse Alert')).toBeInTheDocument();
|
||||||
expect(screen.getByText('⚠️')).toBeInTheDocument();
|
|
||||||
expect(screen.getByText('ℹ️')).toBeInTheDocument();
|
|
||||||
|
|
||||||
expect(screen.getByText('Signal Alert')).toBeInTheDocument();
|
|
||||||
expect(screen.getByText('Pulse Alert')).toBeInTheDocument();
|
|
||||||
expect(screen.getByText('Error Alert')).toBeInTheDocument();
|
expect(screen.getByText('Error Alert')).toBeInTheDocument();
|
||||||
expect(screen.getByText('Info Alert')).toBeInTheDocument();
|
expect(screen.getByText('Info Alert')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import './AlertFeed.css';
|
import { AlertCircle, Bell, Info, Rocket, Timer } from 'lucide-react';
|
||||||
|
import './AlertFeed.css';
|
||||||
|
|
||||||
interface AlertFeedProps {
|
interface AlertFeedProps {
|
||||||
alerts: Array<{
|
alerts: Array<{
|
||||||
@ -9,12 +10,12 @@ interface AlertFeedProps {
|
|||||||
}>;
|
}>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const alertTypeIcons: { [key: string]: string } = {
|
const alertTypeIcons = {
|
||||||
signal: '🚀',
|
signal: Rocket,
|
||||||
pulse: '⏰',
|
pulse: Timer,
|
||||||
error: '⚠️',
|
error: AlertCircle,
|
||||||
info: 'ℹ️'
|
info: Info
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AlertFeed = ({ alerts }: AlertFeedProps) => {
|
export const AlertFeed = ({ alerts }: AlertFeedProps) => {
|
||||||
const sortedAlerts = [...alerts].reverse().slice(0, 50);
|
const sortedAlerts = [...alerts].reverse().slice(0, 50);
|
||||||
@ -31,7 +32,13 @@ export const AlertFeed = ({ alerts }: AlertFeedProps) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="alert-feed">
|
<div className="alert-feed">
|
||||||
<h2>Recent Activity</h2>
|
<div className="alert-feed-header">
|
||||||
|
<div className="alert-feed-title-icon"><Bell size={16} /></div>
|
||||||
|
<div>
|
||||||
|
<h2>Recent Activity</h2>
|
||||||
|
<p>{sortedAlerts.length} recent event{sortedAlerts.length === 1 ? '' : 's'} across signals, warnings, and execution.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div className="alerts-container">
|
<div className="alerts-container">
|
||||||
{sortedAlerts.length === 0 && (
|
{sortedAlerts.length === 0 && (
|
||||||
<div className="alert-empty-state">
|
<div className="alert-empty-state">
|
||||||
@ -39,19 +46,22 @@ export const AlertFeed = ({ alerts }: AlertFeedProps) => {
|
|||||||
<span>Signals, warnings, and execution events will appear here as they arrive.</span>
|
<span>Signals, warnings, and execution events will appear here as they arrive.</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{sortedAlerts.map((alert, index) => (
|
{sortedAlerts.map((alert, index) => {
|
||||||
|
const Icon = alertTypeIcons[alert.type] || Info;
|
||||||
|
return (
|
||||||
<div key={index} className={`alert-item alert-${alert.type}`}>
|
<div key={index} className={`alert-item alert-${alert.type}`}>
|
||||||
<div className="alert-icon">{alertTypeIcons[alert.type]}</div>
|
<div className="alert-icon"><Icon size={18} /></div>
|
||||||
<div className="alert-content">
|
<div className="alert-content">
|
||||||
<div className="alert-header">
|
<div className="alert-header">
|
||||||
<span className="alert-symbol">{alert.symbol}</span>
|
<span className="alert-symbol">{alert.symbol || 'System'}</span>
|
||||||
<span className="alert-time">{getTimeAgo(alert.timestamp)}</span>
|
<span className="alert-time">{getTimeAgo(alert.timestamp)}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="alert-message">{alert.message}</div>
|
<div className="alert-message">{alert.message}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
);
|
||||||
</div>
|
})}
|
||||||
</div>
|
</div>
|
||||||
);
|
</div>
|
||||||
};
|
);
|
||||||
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user