forked from awesomestvi/navet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenergy-insights-widget.tsx
More file actions
58 lines (54 loc) · 1.96 KB
/
energy-insights-widget.tsx
File metadata and controls
58 lines (54 loc) · 1.96 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
50
51
52
53
54
55
56
57
58
import { Gauge } from 'lucide-react';
import { memo } from 'react';
import { getThemeSurfaceTokens } from '@/app/components/shared/theme/theme-surface-tokens';
import { useI18n, useTheme } from '@/app/hooks';
import type { EnergyInsight } from '../../types/energy.types';
import { EnergyWidgetShell } from '../energy-widget-shell';
const SEVERITY_CLASS: Record<EnergyInsight['severity'], string> = {
critical: 'text-rose-300',
warning: 'text-amber-300',
info: 'text-sky-300',
};
interface EnergyInsightsWidgetProps {
insights: EnergyInsight[];
}
export const EnergyInsightsWidget = memo(function EnergyInsightsWidget({
insights,
}: EnergyInsightsWidgetProps) {
const { t } = useI18n();
const { theme } = useTheme();
const surface = getThemeSurfaceTokens(theme);
const severityLabels: Record<EnergyInsight['severity'], string> = {
critical: t('energy.widgets.insights.severity.critical'),
warning: t('energy.widgets.insights.severity.warning'),
info: t('energy.widgets.insights.severity.info'),
};
return (
<EnergyWidgetShell
title={t('energy.widgets.insights.title')}
eyebrow={t('energy.widgets.insights.eyebrow')}
action={<Gauge className={`h-5 w-5 ${surface.textMuted}`} />}
>
<div className="space-y-3">
{insights.map((insight) => (
<div
key={insight.id}
className={`rounded-3xl border p-4 ${surface.border} ${surface.panelMuted}`}
>
<div
className={`text-xs font-semibold uppercase tracking-[0.16em] ${SEVERITY_CLASS[insight.severity]}`}
>
{severityLabels[insight.severity]}
</div>
<div className={`mt-2 text-sm font-semibold ${surface.textPrimary}`}>
{insight.title}
</div>
<p className={`mt-2 text-sm leading-6 ${surface.textSecondary}`}>
{insight.description}
</p>
</div>
))}
</div>
</EnergyWidgetShell>
);
});