forked from Hubs-Foundation/hubs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatSidebar.stories.js
More file actions
161 lines (157 loc) · 5.52 KB
/
ChatSidebar.stories.js
File metadata and controls
161 lines (157 loc) · 5.52 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import React from "react";
import { RoomLayout } from "../layout/RoomLayout";
import {
ChatMessageGroup,
ChatSidebar,
SystemMessage,
ChatMessageList,
ChatInput,
SpawnMessageButton,
MessageAttachmentButton,
EmojiPickerPopoverButton,
PermissionMessageGroup,
SendMessageButton
} from "./ChatSidebar";
import imgSrc from "../../assets/background.jpg";
import videoSrc from "../../assets/video/home.mp4";
import { PermissionNotification } from "./PermissionNotifications";
export default {
title: "Room/ChatSidebar",
parameters: {
layout: "fullscreen"
},
argTypes: {
textChatEnabled: {
control: "boolean",
defaultValue: true
}
}
};
const nextTimestamp = (function () {
const now = Date.now();
let time = now - 8 * 60 * 60 * 1000;
return function nextTimeStamp() {
time = time + (now - time) / 2.0;
return time;
};
})();
export const Base = args => (
<RoomLayout
viewport={<div style={{ height: "100vh" }} />}
sidebar={
<ChatSidebar>
<ChatMessageList>
<SystemMessage type="join" presence="room" name="Robert" timestamp={nextTimestamp()} />
<SystemMessage type="join" presence="room" name="Dom" timestamp={nextTimestamp()} />
<ChatMessageGroup
sender="Dom"
timestamp={nextTimestamp()}
messages={[
{ id: "1", key: "1", type: "chat", body: "Hello!" },
// prettier-ignore
{ id: "2", key: "2", type: "chat", body: "This is a really long message that should cause a new line, so it needs to contain a lot of verbiage." },
{ id: "3", key: "3", type: "image", body: { src: imgSrc } }
]}
/>
<ChatMessageGroup
sent
sender="Robert"
timestamp={nextTimestamp()}
messages={[
{ id: "4", key: "4", type: "chat", body: "Hello!" },
// prettier-ignore
{ id: "5", key: "5", type: "chat", body: "This is a really long message that should cause a new line, so it needs to contain a lot of verbiage." },
{ id: "6", key: "6", type: "video", body: { src: videoSrc } },
{ id: "7", key: "7", type: "chat", body: "Another message" },
{ id: "8", key: "8", type: "chat", body: "One last message" }
]}
/>
<SystemMessage type="join" presence="room" name="John" timestamp={nextTimestamp()} />
<ChatMessageGroup
sender="John"
timestamp={nextTimestamp()}
messages={[
{
id: "9",
key: "9",
type: "chat",
body: "https://hubsfoundation.org"
},
{
id: "10",
key: "10",
type: "chat",
body: "Test message with url. https://demo.hubsfoundation.org Best site :point_up:"
},
{
id: "11",
key: "11",
type: "chat",
body: ":thumbsup:"
},
{
id: "10",
key: "10",
type: "chat",
body: "Really long test message with url, to test line breaking. https://demo.hubsfoundation.org Woo!"
}
]}
/>
<SystemMessage type="join" presence="room" name="Liv" timestamp={nextTimestamp()} />
<SystemMessage type="join" presence="room" name="Robin" timestamp={nextTimestamp()} />
<ChatMessageGroup
sender="Liv"
timestamp={nextTimestamp()}
messages={[{ id: "12", key: "12", type: "chat", body: ":clap:" }]}
/>
<ChatMessageGroup
sender="Robin"
timestamp={nextTimestamp()}
messages={[{ id: "13", key: "13", type: "chat", body: '`console.log("Hello World")`' }]}
/>
<ChatMessageGroup
sent
sender="Robert"
timestamp={nextTimestamp()}
messages={[
{ id: "14", key: "14", type: "chat", body: "https://hubsfoundation.org" },
// prettier-ignore
{ id: "21", key: "21", type: "chat", body: "Another really long test message with url. https://hubsfoundation.org So where does the line break?" }
]}
/>
<PermissionMessageGroup
sent
timestamp={nextTimestamp()}
messages={[
{ key: "16", id: "16", type: "permission", body: { permission: "voice_chat", status: false } },
{ key: "17", id: "17", type: "permission", body: { permission: "text_chat", status: true } }
]}
permissionMessage
/>
</ChatMessageList>
{!!args.textChatEnabled && <PermissionNotification permission={"text_chat"} isMod={false} />}
<ChatInput
id="chat-input"
afterInput={
<>
<EmojiPickerPopoverButton onSelectEmoji={emoji => console.log(emoji)} />
<MessageAttachmentButton />
<SendMessageButton
disabled={!args.textChatEnabled}
title={!args.textChatEnabled ? "Text Chat Off" : undefined}
/>
<SpawnMessageButton
disabled={!args.textChatEnabled}
title={!args.textChatEnabled ? "Text Chat Off" : undefined}
/>
</>
}
disabled={!args.textChatEnabled}
/>
</ChatSidebar>
}
/>
);
Base.args = {
textChatEnabled: false
};