forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserMessage.tsx
More file actions
68 lines (64 loc) · 1.84 KB
/
Copy pathUserMessage.tsx
File metadata and controls
68 lines (64 loc) · 1.84 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
59
60
61
62
63
64
65
66
67
68
import React from "react";
import { View, Text, StyleSheet, type ViewStyle } from "react-native";
import { formatTimestamp } from "./utils";
// ─── Colors ──────────────────────────────────────────────────────────────────
const USER_BUBBLE_BG = "#0066CC";
const USER_TEXT_COLOR = "#FFFFFF";
const TIMESTAMP_COLOR = "#999999";
/**
* Props for the UserMessage component.
*/
export interface UserMessageProps {
/** Plain text content to display */
content: string;
/** Optional timestamp displayed below the bubble */
timestamp?: Date;
/** Optional style override for the outer container */
style?: ViewStyle;
}
/**
* Right-aligned chat bubble for user messages.
*
* Renders plain text (no markdown) with a primary-color background
* and white text. Optionally displays a subtle timestamp below.
*/
export function UserMessage({ content, timestamp, style }: UserMessageProps) {
return (
<View style={[styles.container, style]}>
<View style={styles.bubble}>
<Text style={styles.text}>{content}</Text>
</View>
{timestamp && (
<Text style={styles.timestamp}>{formatTimestamp(timestamp)}</Text>
)}
</View>
);
}
const styles = StyleSheet.create({
container: {
alignItems: "flex-end",
marginVertical: 4,
paddingHorizontal: 12,
},
bubble: {
backgroundColor: USER_BUBBLE_BG,
borderTopLeftRadius: 16,
borderTopRightRadius: 16,
borderBottomLeftRadius: 16,
borderBottomRightRadius: 4,
paddingHorizontal: 12,
paddingVertical: 8,
maxWidth: "80%",
},
text: {
color: USER_TEXT_COLOR,
fontSize: 16,
lineHeight: 22,
},
timestamp: {
color: TIMESTAMP_COLOR,
fontSize: 11,
marginTop: 2,
marginRight: 4,
},
});