Skip to content

Commit ae5d78e

Browse files
docs: Add Storybook story for Matrix Federation POC demonstration
1 parent b178dbf commit ae5d78e

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import React from 'react';
2+
import Message from '../views/Message/Message';
3+
import { RCInstanceProvider } from '../context/RCInstance';
4+
import {
5+
ThemeProvider,
6+
ToastBarProvider,
7+
Box
8+
} from '@embeddedchat/ui-elements';
9+
import GlobalStyles from '../views/GlobalStyles';
10+
import DefaultTheme from '../theme/DefaultTheme';
11+
12+
export default {
13+
title: 'EmbeddedChat/POC: Matrix Federation',
14+
component: Message,
15+
};
16+
17+
const mockMatrixMessage = {
18+
_id: 'matrix-msg-id',
19+
rid: 'GENERAL',
20+
msg: 'Hello from the Matrix! This message is coming from a federated homeserver.',
21+
ts: new Date().toISOString(),
22+
u: {
23+
_id: 'federated-user-id',
24+
username: '@vivek:matrix.org',
25+
name: 'Vivek (Matrix)',
26+
},
27+
};
28+
29+
const mockNormalMessage = {
30+
_id: 'normal-msg-id',
31+
rid: 'GENERAL',
32+
msg: 'Hi! I am a normal Rocket.Chat user.',
33+
ts: new Date().toISOString(),
34+
u: {
35+
_id: 'normal-user-id',
36+
username: 'vivekyadav',
37+
name: 'Vivek Yadav',
38+
},
39+
};
40+
41+
export const FederatedUser = () => (
42+
<ThemeProvider theme={DefaultTheme}>
43+
<GlobalStyles />
44+
<RCInstanceProvider value={{
45+
RCInstance: {
46+
auth: { onAuthChange: () => {} },
47+
getHost: () => 'http://localhost:3000',
48+
starMessage: () => {},
49+
pinMessage: () => {},
50+
},
51+
ECOptions: { showAvatar: true, showRoles: true, showUsername: true, showName: true }
52+
}}>
53+
<ToastBarProvider>
54+
<div style={{ padding: '2rem', background: 'white', minHeight: '100vh' }}>
55+
<h3>Federated vs Normal Message Comparison</h3>
56+
<p style={{ color: '#666' }}>Notice the purple Matrix badge on the federated user identifier.</p>
57+
<div style={{ border: '1px solid #eee', padding: '1rem', borderRadius: '8px', maxWidth: '600px' }}>
58+
<Message message={mockMatrixMessage} showAvatar={true} showRoles={true} />
59+
<hr style={{ margin: '1.5rem 0', border: '0', borderTop: '1px solid #eee' }} />
60+
<Message message={mockNormalMessage} showAvatar={true} showRoles={true} />
61+
</div>
62+
</div>
63+
</ToastBarProvider>
64+
</RCInstanceProvider>
65+
</ThemeProvider>
66+
);

0 commit comments

Comments
 (0)