-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathCallWithChatPane.tsx
More file actions
152 lines (138 loc) · 5.12 KB
/
CallWithChatPane.tsx
File metadata and controls
152 lines (138 loc) · 5.12 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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { IStackStyles, IStackTokens, Stack } from '@fluentui/react';
import { ParticipantMenuItemsCallback, useTheme, _DrawerMenu, _DrawerMenuItemProps } from '@internal/react-components';
import React, { useMemo, useState } from 'react';
import { CallAdapter } from '../CallComposite';
import { CallAdapterProvider } from '../CallComposite/adapter/CallAdapterProvider';
import { ChatAdapter, ChatComposite, ChatCompositeProps } from '../ChatComposite';
import { AvatarPersonaDataCallback } from '../common/AvatarPersona';
import {
getPipStyles,
paneBodyContainer,
scrollableContainer,
scrollableContainerContents
} from '../common/styles/ParticipantContainer.styles';
import { SidePaneHeader } from './SidePaneHeader';
import { useCallWithChatCompositeStrings } from './hooks/useCallWithChatCompositeStrings';
import { ModalLocalAndRemotePIP } from './ModalLocalAndRemotePIP';
import { PeoplePaneContent } from './PeoplePaneContent';
import { drawerContainerStyles } from './styles/CallWithChatCompositeStyles';
import { TabHeader } from './TabHeader';
/* @conditional-compile-remove(file-sharing) */
import { FileSharingOptions } from '../ChatComposite';
/**
* Pane that is used to store chat and people for CallWithChat composite
* @private
*/
export const CallWithChatPane = (props: {
chatCompositeProps: Partial<ChatCompositeProps>;
callAdapter: CallAdapter;
chatAdapter: ChatAdapter;
onClose: () => void;
onFetchAvatarPersonaData?: AvatarPersonaDataCallback;
onFetchParticipantMenuItems?: ParticipantMenuItemsCallback;
onChatButtonClicked: () => void;
onPeopleButtonClicked: () => void;
modalLayerHostId: string;
activePane: CallWithChatPaneOption;
mobileView?: boolean;
inviteLink?: string;
/* @conditional-compile-remove(file-sharing) */
fileSharing?: FileSharingOptions;
}): JSX.Element => {
const [drawerMenuItems, setDrawerMenuItems] = useState<_DrawerMenuItemProps[]>([]);
const hidden = props.activePane === 'none';
const paneStyles = hidden ? hiddenStyles : props.mobileView ? availableSpaceStyles : sidePaneStyles;
const callWithChatStrings = useCallWithChatCompositeStrings();
const theme = useTheme();
const header =
props.activePane === 'none' ? null : props.mobileView ? (
<TabHeader {...props} activeTab={props.activePane} />
) : (
<SidePaneHeader
{...props}
headingText={
props.activePane === 'chat'
? callWithChatStrings.chatPaneTitle
: props.activePane === 'people'
? callWithChatStrings.peoplePaneTitle
: ''
}
/>
);
const chatContent = (
<ChatComposite
{...props.chatCompositeProps}
adapter={props.chatAdapter}
fluentTheme={theme}
options={{
topic: false,
/* @conditional-compile-remove(chat-composite-participant-pane) */
participantPane: false,
/* @conditional-compile-remove(file-sharing) */
fileSharing: props.fileSharing
}}
onFetchAvatarPersonaData={props.onFetchAvatarPersonaData}
/>
);
const peopleContent = (
<CallAdapterProvider adapter={props.callAdapter}>
<PeoplePaneContent {...props} setDrawerMenuItems={setDrawerMenuItems} strings={callWithChatStrings} />
</CallAdapterProvider>
);
const pipStyles = useMemo(() => getPipStyles(theme), [theme]);
const dataUiId =
props.activePane === 'chat'
? 'call-with-chat-composite-chat-pane'
: props.activePane === 'people'
? 'call-with-chat-composite-people-pane'
: '';
return (
<Stack verticalFill grow styles={paneStyles} data-ui-id={dataUiId} tokens={props.mobileView ? {} : sidePaneTokens}>
{header}
<Stack.Item verticalFill grow styles={paneBodyContainer}>
<Stack horizontal styles={scrollableContainer}>
<Stack.Item verticalFill styles={scrollableContainerContents}>
<Stack styles={props.activePane === 'chat' ? availableSpaceStyles : hiddenStyles}>{chatContent}</Stack>
<Stack styles={props.activePane === 'people' ? availableSpaceStyles : hiddenStyles}>{peopleContent}</Stack>
</Stack.Item>
</Stack>
</Stack.Item>
{props.mobileView && (
<ModalLocalAndRemotePIP
callAdapter={props.callAdapter}
modalLayerHostId={props.modalLayerHostId}
hidden={hidden}
styles={pipStyles}
/>
)}
{drawerMenuItems.length > 0 && (
<Stack styles={drawerContainerStyles}>
<_DrawerMenu onLightDismiss={() => setDrawerMenuItems([])} items={drawerMenuItems} />
</Stack>
)}
</Stack>
);
};
/**
* Active tab option type for {@link CallWithChatPane} component
* @private
*/
export type CallWithChatPaneOption = 'none' | 'chat' | 'people';
const hiddenStyles: IStackStyles = {
root: {
display: 'none'
}
};
const sidePaneStyles: IStackStyles = {
root: {
height: '100%',
padding: '0.5rem 0.25rem',
maxWidth: '21.5rem'
}
};
const availableSpaceStyles: IStackStyles = { root: { width: '100%', height: '100%' } };
const sidePaneTokens: IStackTokens = {
childrenGap: '0.5rem'
};