-
Notifications
You must be signed in to change notification settings - Fork 12
/
SidebarContainer.js
222 lines (212 loc) · 7.42 KB
/
SidebarContainer.js
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
import { Constants, useMeeting } from "@videosdk.live/react-sdk";
import React, { Fragment } from "react";
import useIsMobile from "../../hooks/useIsMobile";
import useIsTab from "../../hooks/useIsTab";
import ECommercePanel from "../../interactive-live-streaming/components/ECommercePanel";
import CreatePoll from "../../interactive-live-streaming/components/pollContainer/CreatePoll";
import PollList from "../../interactive-live-streaming/components/pollContainer/PollList";
import SubmitPollList from "../../interactive-live-streaming/components/pollContainer/SubmitPollList";
import { sideBarModes } from "../../utils/common";
import { XIcon } from "@heroicons/react/outline";
import { ChatPanel } from "./ChatPanel";
import { ParticipantPanel } from "./ParticipantPanel";
import { Dialog, Transition } from "@headlessui/react";
import { useMediaQuery } from "react-responsive";
import { useMeetingAppContext } from "../../MeetingAppContextDef";
const SideBarTabView = ({
height,
sideBarContainerWidth,
panelHeight,
panelHeaderHeight,
panelHeaderPadding,
panelPadding,
handleClose,
meetingMode,
}) => {
const { participants } = useMeeting();
const { sideBarMode, draftPolls, polls } = useMeetingAppContext();
return (
<div
className="bg-gray-800"
style={{
height,
width: sideBarContainerWidth,
paddingTop: panelPadding,
paddingLeft: panelPadding,
paddingRight: panelPadding,
paddingBottom: panelPadding,
}}
>
<div>
<div
className="bg-gray-750"
style={{
height: height,
borderRadius: 10,
overflow: "hidden",
}}
>
<>
{sideBarMode && (
<div
className={`flex items-center justify-between`}
style={{
padding: panelHeaderPadding,
height: panelHeaderHeight - 1,
borderBottom: "1px solid #70707033",
}}
>
<p className="text-base text-white font-bold">
{sideBarMode === "PARTICIPANTS"
? `${
sideBarMode.charAt(0).toUpperCase() +
sideBarMode.slice(1).toLowerCase() || ""
} (${new Map(participants)?.size})`
: sideBarMode === sideBarModes.CREATE_POLL
? "Create a poll"
: sideBarMode === sideBarModes.POLLS
? polls?.length >= 1 || draftPolls?.length >= 1
? `Polls ${
polls?.length || draftPolls?.length
? `(${polls?.length || draftPolls?.length})`
: ""
}`
: meetingMode === Constants.modes.VIEWER
? `Polls ${polls?.length ? `(${polls?.length})` : ""}`
: "Create a poll"
: sideBarMode === sideBarModes.ECOMMERCE
? "Products"
: sideBarMode.charAt(0).toUpperCase() +
sideBarMode.slice(1).toLowerCase() || ""}
</p>
<button
className="text-white"
onClick={handleClose}
style={{ margin: 0, padding: 0 }}
>
<XIcon className="h-5 w-5" />
</button>
</div>
)}
{sideBarMode === "PARTICIPANTS" ? (
<ParticipantPanel panelHeight={panelHeight} />
) : sideBarMode === "CHAT" ? (
<ChatPanel panelHeight={panelHeight} />
) : sideBarMode === "POLLS" && meetingMode !== "VIEWER" ? (
polls.length === 0 && draftPolls.length === 0 ? (
<CreatePoll {...{ panelHeight }} />
) : (
<PollList {...{ panelHeight }} />
)
) : sideBarMode === "POLLS" && meetingMode === "VIEWER" ? (
<SubmitPollList {...{ panelHeight }} />
) : sideBarMode === "CREATE_POLL" ? (
<CreatePoll {...{ panelHeight }} />
) : sideBarMode === "ECOMMERCE" ? (
<ECommercePanel {...{ panelHeight }} />
) : null}
</>
</div>
</div>
</div>
);
};
export function SidebarConatiner({
height,
sideBarContainerWidth,
meetingMode,
}) {
const { raisedHandsParticipants, sideBarMode, setSideBarMode } =
useMeetingAppContext();
const isMobile = useIsMobile();
const isTab = useIsTab();
const isLGDesktop = useMediaQuery({ minWidth: 1024, maxWidth: 1439 });
const isXLDesktop = useMediaQuery({ minWidth: 1440 });
const panelPadding = 8;
const paddedHeight = height - panelPadding * 3.5;
const panelHeaderHeight = isMobile
? 40
: isTab
? 44
: isLGDesktop
? 48
: isXLDesktop
? 52
: 0;
const panelHeaderPadding = isMobile
? 6
: isTab
? 8
: isLGDesktop
? 10
: isXLDesktop
? 12
: 0;
const handleClose = () => {
setSideBarMode(null);
};
return sideBarMode ? (
isTab || isMobile ? (
<Transition appear show={sideBarMode ? true : false} as={Fragment}>
<Dialog
as="div"
className="relative"
style={{ zIndex: 9999 }}
onClose={handleClose}
>
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="ease-in duration-200"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<div className="fixed inset-0 bg-black bg-opacity-25" />
</Transition.Child>
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="translate-y-full opacity-0 scale-95"
enterTo="translate-y-0 opacity-100 scale-100"
leave="ease-in duration-200"
leaveFrom="translate-y-0 opacity-100 scale-100"
leaveTo="translate-y-full opacity-0 scale-95"
>
<div className="fixed inset-0 overflow-y-hidden">
<div className="flex h-screen items-center justify-center text-center">
<Dialog.Panel className="w-screen transform overflow-hidden bg-gray-800 shadow-xl transition-all">
<SideBarTabView
height={"100%"}
sideBarContainerWidth={"100%"}
panelHeight={height}
raisedHandsParticipants={raisedHandsParticipants}
panelHeaderHeight={panelHeaderHeight}
panelHeaderPadding={panelHeaderPadding}
panelPadding={panelPadding}
handleClose={handleClose}
/>
</Dialog.Panel>
</div>
</div>
</Transition.Child>
</Dialog>
</Transition>
) : (
<SideBarTabView
height={paddedHeight}
sideBarContainerWidth={sideBarContainerWidth}
panelHeight={paddedHeight - panelHeaderHeight - panelHeaderPadding}
raisedHandsParticipants={raisedHandsParticipants}
panelHeaderHeight={panelHeaderHeight}
panelHeaderPadding={panelHeaderPadding}
panelPadding={panelPadding}
handleClose={handleClose}
meetingMode={meetingMode}
/>
)
) : (
<></>
);
}