-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathParticipantContainer.tsx
More file actions
100 lines (96 loc) · 3.25 KB
/
ParticipantContainer.tsx
File metadata and controls
100 lines (96 loc) · 3.25 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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import React, { useMemo } from 'react';
import {
participantListContainerStyle,
participantListMobileStyle,
participantListStack,
participantListStyle,
participantListWrapper,
displayNameStyles
} from './styles/ParticipantContainer.styles';
import {
OnRenderAvatarCallback,
ParticipantList,
ParticipantListProps,
ParticipantMenuItemsCallback
} from '@internal/react-components';
import { FocusZone, Stack, Text, useTheme } from '@fluentui/react';
import { AvatarPersona, AvatarPersonaDataCallback } from './AvatarPersona';
import { useId } from '@fluentui/react-hooks';
type ParticipantContainerProps = {
onRenderAvatar?: OnRenderAvatarCallback;
onFetchParticipantMenuItems?: ParticipantMenuItemsCallback;
onFetchAvatarPersonaData?: AvatarPersonaDataCallback;
participantListProps: ParticipantListProps;
title?: string;
isMobile?: boolean;
};
/**
* @private
*/
export const ParticipantContainer = (props: ParticipantContainerProps): JSX.Element => {
const theme = useTheme();
const participantListWrapperClassName = useMemo(() => participantListWrapper(theme), [theme]);
return (
<Stack className={participantListWrapperClassName}>
<ParticipantListWithHeading {...props} />
</Stack>
);
};
/**
* @private
*/
export const ParticipantListWithHeading = (props: {
participantListProps: ParticipantListProps;
title?: string;
isMobile?: boolean;
onFetchAvatarPersonaData?: AvatarPersonaDataCallback;
onFetchParticipantMenuItems?: ParticipantMenuItemsCallback;
}): JSX.Element => {
const { onFetchAvatarPersonaData, onFetchParticipantMenuItems, title, participantListProps } = props;
const subheadingUniqueId = useId();
const theme = useTheme();
const subheadingStyleThemed = useMemo(
() => ({
root: {
color: theme.palette.neutralSecondary,
margin: props.isMobile ? '0.5rem 1rem' : '0.5rem',
fontSize: theme.fonts.smallPlus.fontSize
}
}),
[theme.palette.neutralSecondary, theme.fonts.smallPlus.fontSize, props.isMobile]
);
return (
<Stack className={participantListStack}>
<Stack.Item styles={subheadingStyleThemed} aria-label={title} id={subheadingUniqueId}>
{title}
</Stack.Item>
<FocusZone className={participantListContainerStyle} shouldFocusOnMount={true}>
<ParticipantList
{...participantListProps}
styles={props.isMobile ? participantListMobileStyle : participantListStyle}
onRenderAvatar={(userId, options) => (
<>
<AvatarPersona
data-ui-id="chat-composite-participant-custom-avatar"
userId={userId}
{...options}
{...{ hidePersonaDetails: !!options?.text }}
dataProvider={onFetchAvatarPersonaData}
/>
{options?.text && (
<Text nowrap={true} styles={displayNameStyles}>
{options?.text}
</Text>
)}
</>
)}
onFetchParticipantMenuItems={onFetchParticipantMenuItems}
showParticipantOverflowTooltip={!props.isMobile}
participantAriaLabelledBy={subheadingUniqueId}
/>
</FocusZone>
</Stack>
);
};