eletrotupi / tcc/ frontend/components/insights/InsightCard.tsxcd24e52c4f9ec392235c1c0407fef8f18c191a40
1.8 KB | 84 lines Raw
1
import React from "react";
2
import { View, Text, StyleSheet } from "react-native";
3

4
import { Card } from "@/components/ui/Cards";
5
import { Colors, Spacing, Typography } from "@/constants/theme";
6

7
export type MetricAccent = "green" | "purple" | "neutral";
8

9
const metricColor: Record<MetricAccent, string> = {
10
  green: Colors.light.tint,
11
  purple: Colors.light.accentDarkPurple,
12
  neutral: Colors.light.text,
13
};
14

15
interface InsightCardProps {
16
  category: string;
17
  body: React.ReactNode;
18
  metric: string;
19
  accent?: MetricAccent;
20
}
21

22
export const InsightCard: React.FC<InsightCardProps> = ({
23
  category,
24
  body,
25
  metric,
26
  accent = "neutral",
27
}) => (
28
  <Card style={styles.cardContainer}>
29
    <View style={styles.inner}>
30
      <View style={styles.left}>
31
        <Text style={styles.category}>{category}</Text>
32
        {typeof body === "string" ? (
33
          <Text style={styles.body}>{body}</Text>
34
        ) : (
35
          body
36
        )}
37
      </View>
38
      <Text style={[styles.metric, { color: metricColor[accent] }]}>
39
        {metric}
40
      </Text>
41
    </View>
42
  </Card>
43
);
44

45
interface HighlightProps {
46
  children: React.ReactNode;
47
  color?: string;
48
}
49

50
export const Highlight: React.FC<HighlightProps> = ({
51
  children,
52
  color = Colors.light.tint,
53
}) => <Text style={{ color, fontWeight: "700" }}>{children}</Text>;
54

55
const styles = StyleSheet.create({
56
  cardContainer: {
57
    padding: Spacing.cardGap,
58
  },
59
  inner: {
60
    flexDirection: "row",
61
    alignItems: "center",
62
    justifyContent: "space-between",
63
    gap: 12,
64
  },
65
  left: {
66
    flex: 1,
67
    gap: 6,
68
  },
69
  category: {
70
    fontSize: 11,
71
    fontWeight: "600",
72
    letterSpacing: 0.8,
73
    textTransform: "uppercase",
74
    color: Colors.light.textSecondary,
75
  },
76
  body: {
77
    ...Typography.bodyMd,
78
    color: Colors.light.text,
79
  },
80
  metric: {
81
    ...Typography.headlineLg,
82
    fontSize: 22,
83
  },
84
});