@100mslive/roomkit-react 0.1.19-alpha.1 → 0.1.19
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{HLSView-UBVLOPNY.js → HLSView-4L4OAX2K.js} +2 -2
- package/dist/Prebuilt/App.d.ts +1 -0
- package/dist/Prebuilt/common/constants.d.ts +1 -1
- package/dist/Prebuilt/components/Chat/EmptyChat.d.ts +2 -0
- package/dist/Prebuilt/components/Polls/Voting/{Leaderboard.d.ts → LeaderboardSummary.d.ts} +1 -1
- package/dist/Prebuilt/components/Polls/Voting/StatisticBox.d.ts +5 -0
- package/dist/Prebuilt/components/VirtualBackground/VBCollection.d.ts +3 -4
- package/dist/Prebuilt/components/VirtualBackground/VBHandler.d.ts +14 -0
- package/dist/Prebuilt/components/VirtualBackground/VBPicker.d.ts +1 -1
- package/dist/Prebuilt/components/VirtualBackground/constants.d.ts +0 -2
- package/dist/{chunk-VU2CQFCB.js → chunk-NHPPOGUF.js} +1403 -1293
- package/dist/chunk-NHPPOGUF.js.map +7 -0
- package/dist/index.cjs.js +1749 -1609
- package/dist/index.cjs.js.map +4 -4
- package/dist/index.js +1 -1
- package/dist/meta.cjs.json +236 -94
- package/dist/meta.esbuild.json +243 -101
- package/package.json +6 -6
- package/src/Prebuilt/App.tsx +2 -1
- package/src/Prebuilt/AppStateContext.tsx +2 -0
- package/src/Prebuilt/common/constants.ts +1 -1
- package/src/Prebuilt/components/Chat/Chat.tsx +2 -2
- package/src/Prebuilt/components/Chat/ChatActions.tsx +3 -3
- package/src/Prebuilt/components/Chat/ChatBody.tsx +28 -46
- package/src/Prebuilt/components/Chat/EmptyChat.tsx +51 -0
- package/src/Prebuilt/components/Footer/PaginatedParticipants.tsx +1 -1
- package/src/Prebuilt/components/Footer/PollsToggle.tsx +7 -1
- package/src/Prebuilt/components/Notifications/Notifications.tsx +0 -29
- package/src/Prebuilt/components/Polls/Polls.tsx +2 -2
- package/src/Prebuilt/components/Polls/Voting/LeaderboardEntry.tsx +2 -2
- package/src/Prebuilt/components/Polls/Voting/LeaderboardSummary.tsx +162 -0
- package/src/Prebuilt/components/Polls/Voting/PeerParticipationSummary.tsx +2 -9
- package/src/Prebuilt/components/Polls/Voting/StatisticBox.tsx +15 -0
- package/src/Prebuilt/components/Polls/Voting/Voting.jsx +1 -17
- package/src/Prebuilt/components/TileMenu/TileMenuContent.tsx +1 -1
- package/src/Prebuilt/components/VirtualBackground/VBCollection.tsx +5 -11
- package/src/Prebuilt/components/VirtualBackground/VBHandler.tsx +77 -0
- package/src/Prebuilt/components/VirtualBackground/VBPicker.tsx +45 -79
- package/src/Prebuilt/components/VirtualBackground/constants.ts +0 -4
- package/src/Prebuilt/layouts/SidePane.tsx +6 -1
- package/src/Theme/stitches.config.ts +2 -10
- package/dist/chunk-VU2CQFCB.js.map +0 -7
- package/src/Prebuilt/components/Polls/Voting/Leaderboard.tsx +0 -123
- package/src/Prebuilt/components/Polls/Voting/PollResultSummary.jsx +0 -125
- /package/dist/{HLSView-UBVLOPNY.js.map → HLSView-4L4OAX2K.js.map} +0 -0
@@ -1,123 +0,0 @@
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
2
|
-
import { HMSPollLeaderboardResponse, selectPollByID, useHMSActions, useHMSStore } from '@100mslive/react-sdk';
|
3
|
-
import { ChevronLeftIcon, CrossIcon } from '@100mslive/react-icons';
|
4
|
-
import { Box, Flex } from '../../../../Layout';
|
5
|
-
import { Loading } from '../../../../Loading';
|
6
|
-
import { Text } from '../../../../Text';
|
7
|
-
import { LeaderboardEntry } from './LeaderboardEntry';
|
8
|
-
// @ts-ignore
|
9
|
-
import { useSidepaneToggle } from '../../AppData/useSidepane';
|
10
|
-
// @ts-ignore
|
11
|
-
import { usePollViewState } from '../../AppData/useUISettings';
|
12
|
-
// @ts-ignore
|
13
|
-
import { StatusIndicator } from '../common/StatusIndicator';
|
14
|
-
import { POLL_VIEWS } from '../../../common/constants';
|
15
|
-
|
16
|
-
export const Leaderboard = ({ pollID }: { pollID: string }) => {
|
17
|
-
const hmsActions = useHMSActions();
|
18
|
-
const poll = useHMSStore(selectPollByID(pollID));
|
19
|
-
const [pollLeaderboard, setPollLeaderboard] = useState<HMSPollLeaderboardResponse | undefined>();
|
20
|
-
const { setPollView } = usePollViewState();
|
21
|
-
const toggleSidepane = useSidepaneToggle();
|
22
|
-
|
23
|
-
/*
|
24
|
-
const sharedLeaderboardRef = useRef(false);
|
25
|
-
const sharedLeaderboards = useHMSStore(selectSessionStore(SESSION_STORE_KEY.SHARED_LEADERBOARDS));
|
26
|
-
const { sendEvent } = useCustomEvent({
|
27
|
-
type: HMSNotificationTypes.POLL_LEADERBOARD_SHARED,
|
28
|
-
onEvent: () => {
|
29
|
-
return;
|
30
|
-
},
|
31
|
-
});
|
32
|
-
*/
|
33
|
-
|
34
|
-
useEffect(() => {
|
35
|
-
const fetchLeaderboardData = async () => {
|
36
|
-
if (poll) {
|
37
|
-
const leaderboardData = await hmsActions.interactivityCenter.fetchLeaderboard(poll, 0, 50);
|
38
|
-
setPollLeaderboard(leaderboardData);
|
39
|
-
}
|
40
|
-
};
|
41
|
-
fetchLeaderboardData();
|
42
|
-
}, [poll, hmsActions.interactivityCenter]);
|
43
|
-
|
44
|
-
if (!poll || !pollLeaderboard)
|
45
|
-
return (
|
46
|
-
<Flex align="center" justify="center" css={{ size: '100%' }}>
|
47
|
-
<Loading />
|
48
|
-
</Flex>
|
49
|
-
);
|
50
|
-
const maxPossibleScore = poll.questions?.reduce((total, question) => (total += question.weight || 0), 0) || 0;
|
51
|
-
const questionCount = poll.questions?.length || 0;
|
52
|
-
|
53
|
-
return (
|
54
|
-
<Flex direction="column" css={{ size: '100%' }}>
|
55
|
-
<Flex justify="between" align="center" css={{ pb: '$6', borderBottom: '1px solid $border_bright', mb: '$8' }}>
|
56
|
-
<Flex align="center" css={{ gap: '$4' }}>
|
57
|
-
<Flex
|
58
|
-
css={{ color: '$on_surface_medium', '&:hover': { color: '$on_surface_high', cursor: 'pointer' } }}
|
59
|
-
onClick={() => setPollView(POLL_VIEWS.VOTE)}
|
60
|
-
>
|
61
|
-
<ChevronLeftIcon />
|
62
|
-
</Flex>
|
63
|
-
<Text variant="lg" css={{ fontWeight: '$semiBold' }}>
|
64
|
-
{poll.title}
|
65
|
-
</Text>
|
66
|
-
<StatusIndicator isLive={false} />
|
67
|
-
</Flex>
|
68
|
-
<Flex
|
69
|
-
css={{ color: '$on_surface_medium', '&:hover': { color: '$on_surface_high', cursor: 'pointer' } }}
|
70
|
-
onClick={toggleSidepane}
|
71
|
-
>
|
72
|
-
<CrossIcon />
|
73
|
-
</Flex>
|
74
|
-
</Flex>
|
75
|
-
<Text variant="sm" css={{ fontWeight: '$semiBold' }}>
|
76
|
-
Leaderboard
|
77
|
-
</Text>
|
78
|
-
<Text variant="xs" css={{ color: '$on_surface_medium' }}>
|
79
|
-
Based on score and time taken to cast the correct answer
|
80
|
-
</Text>
|
81
|
-
<Box
|
82
|
-
css={{
|
83
|
-
mt: '$8',
|
84
|
-
overflowY: 'auto',
|
85
|
-
flex: '1 1 0',
|
86
|
-
mr: '-$6',
|
87
|
-
pr: '$6',
|
88
|
-
}}
|
89
|
-
>
|
90
|
-
{pollLeaderboard?.entries &&
|
91
|
-
pollLeaderboard.entries.map(question => (
|
92
|
-
<LeaderboardEntry
|
93
|
-
key={question.position}
|
94
|
-
position={question.position}
|
95
|
-
score={question.score}
|
96
|
-
questionCount={questionCount}
|
97
|
-
correctResponses={question.correctResponses}
|
98
|
-
userName={question.peer.username || ''}
|
99
|
-
maxPossibleScore={maxPossibleScore}
|
100
|
-
/>
|
101
|
-
))}
|
102
|
-
</Box>
|
103
|
-
|
104
|
-
{/* {!sharedLeaderboardRef.current ? (
|
105
|
-
<Button
|
106
|
-
css={{ ml: 'auto', mt: '$8' }}
|
107
|
-
onClick={() => {
|
108
|
-
const currentlySharedLeaderboards = sharedLeaderboards || [];
|
109
|
-
hmsActions.sessionStore.set(SESSION_STORE_KEY.SHARED_LEADERBOARDS, [
|
110
|
-
...currentlySharedLeaderboards,
|
111
|
-
pollID,
|
112
|
-
]);
|
113
|
-
const pollDetails = { initiatorName: '', startedBy: poll.startedBy, id: pollID };
|
114
|
-
sendEvent();
|
115
|
-
sharedLeaderboardRef.current = true;
|
116
|
-
}}
|
117
|
-
>
|
118
|
-
Share Results
|
119
|
-
</Button>
|
120
|
-
) : null} */}
|
121
|
-
</Flex>
|
122
|
-
);
|
123
|
-
};
|
@@ -1,125 +0,0 @@
|
|
1
|
-
// @ts-check
|
2
|
-
import React, { useMemo } from 'react';
|
3
|
-
import { selectLocalPeerID, useHMSStore } from '@100mslive/react-sdk';
|
4
|
-
import { Box, Text } from '../../../../';
|
5
|
-
import { checkCorrectAnswer } from '../../../common/utils';
|
6
|
-
|
7
|
-
/**
|
8
|
-
* @param {{ isQuiz: boolean;
|
9
|
-
* isAdmin: boolean;
|
10
|
-
* pollResult: import("@100mslive/react-sdk").HMSPoll['result'];
|
11
|
-
* questions: import("@100mslive/react-sdk").HMSPoll['questions'] }} param0
|
12
|
-
*/
|
13
|
-
export const PollResultSummary = ({ isQuiz, isAdmin, pollResult, questions }) => {
|
14
|
-
const localPeerID = useHMSStore(selectLocalPeerID);
|
15
|
-
const noAnswers = pollResult?.maxUsers || 0 - (pollResult?.totalUsers || 0);
|
16
|
-
const participationPercentage =
|
17
|
-
pollResult?.maxUsers && pollResult?.maxUsers > 0 ? ((pollResult?.totalUsers || 0) * 100) / pollResult.maxUsers : 0;
|
18
|
-
|
19
|
-
const totalCorrectAnswers = useMemo(() => {
|
20
|
-
let correctAnswers = 0;
|
21
|
-
questions?.forEach(question => {
|
22
|
-
correctAnswers += question.result?.correctResponses || 0;
|
23
|
-
});
|
24
|
-
return correctAnswers;
|
25
|
-
}, [questions]);
|
26
|
-
|
27
|
-
const totalIncorrectAnswers = useMemo(() => {
|
28
|
-
let incorrectAnswers = 0;
|
29
|
-
questions?.forEach(question => {
|
30
|
-
incorrectAnswers +=
|
31
|
-
(question.result?.totalResponses || 0) -
|
32
|
-
(question.result?.correctResponses || 0) -
|
33
|
-
(question.result?.skippedCount || 0);
|
34
|
-
});
|
35
|
-
return incorrectAnswers;
|
36
|
-
}, [questions]);
|
37
|
-
|
38
|
-
const localCorrectAnswers = useMemo(() => {
|
39
|
-
let correctAnswers = 0;
|
40
|
-
questions?.forEach(question => {
|
41
|
-
const localResponse = question.responses?.find(response => response.peer?.peerid === localPeerID);
|
42
|
-
if (checkCorrectAnswer(question.answer, localResponse, question.type)) {
|
43
|
-
correctAnswers++;
|
44
|
-
}
|
45
|
-
});
|
46
|
-
return correctAnswers;
|
47
|
-
}, [localPeerID, questions]);
|
48
|
-
|
49
|
-
const localIncorrectAnswers = useMemo(() => {
|
50
|
-
let incorrectAnswers = 0;
|
51
|
-
questions?.forEach(question => {
|
52
|
-
const localResponse = question.responses?.find(response => response.peer?.peerid === localPeerID);
|
53
|
-
if (!checkCorrectAnswer(question.answer, localResponse, question.type) && localResponse) {
|
54
|
-
incorrectAnswers++;
|
55
|
-
}
|
56
|
-
});
|
57
|
-
return incorrectAnswers;
|
58
|
-
}, [localPeerID, questions]);
|
59
|
-
|
60
|
-
if (!pollResult) {
|
61
|
-
return null;
|
62
|
-
}
|
63
|
-
|
64
|
-
let StatsComponents;
|
65
|
-
|
66
|
-
if (isQuiz && isAdmin) {
|
67
|
-
StatsComponents = (
|
68
|
-
<>
|
69
|
-
<PollStat label="No. of correct answers" value={totalCorrectAnswers} />
|
70
|
-
<PollStat label="No. of wrong answerss" value={totalIncorrectAnswers} />
|
71
|
-
<PollStat label="Peers who didn't answer" value={noAnswers} />
|
72
|
-
<PollStat label="Participation Percentage" value={participationPercentage.toFixed(2) + '%'} />
|
73
|
-
</>
|
74
|
-
);
|
75
|
-
} else if (isQuiz && !isAdmin) {
|
76
|
-
StatsComponents = (
|
77
|
-
<>
|
78
|
-
<PollStat label="No. of correct answers" value={localCorrectAnswers} />
|
79
|
-
<PollStat label="No. of wrong answers" value={localIncorrectAnswers} />
|
80
|
-
</>
|
81
|
-
);
|
82
|
-
} else if (!isQuiz && isAdmin) {
|
83
|
-
StatsComponents = (
|
84
|
-
<>
|
85
|
-
<PollStat label="Peers who didn't answer" value={noAnswers} />
|
86
|
-
<PollStat label="Participation Percentage" value={participationPercentage.toFixed(2) + '%'} />
|
87
|
-
</>
|
88
|
-
);
|
89
|
-
} else {
|
90
|
-
return null;
|
91
|
-
}
|
92
|
-
|
93
|
-
return (
|
94
|
-
<Box
|
95
|
-
css={{
|
96
|
-
display: 'grid',
|
97
|
-
'grid-template-columns': 'repeat(2, 2fr)',
|
98
|
-
gap: '$4',
|
99
|
-
mt: '$3',
|
100
|
-
}}
|
101
|
-
>
|
102
|
-
{StatsComponents}
|
103
|
-
</Box>
|
104
|
-
);
|
105
|
-
};
|
106
|
-
|
107
|
-
const PollStat = ({ label, value }) => {
|
108
|
-
return (
|
109
|
-
<Box css={{ bg: '$surface_bright', p: '$8', r: '$1' }}>
|
110
|
-
<Text
|
111
|
-
variant="overline"
|
112
|
-
css={{
|
113
|
-
fontWeight: '$semiBold',
|
114
|
-
color: '$on_surface_medium',
|
115
|
-
textTransform: 'uppercase',
|
116
|
-
}}
|
117
|
-
>
|
118
|
-
{label}
|
119
|
-
</Text>
|
120
|
-
<Text variant="sub1" css={{ fontWeight: '$semiBold', color: '$on_surface_medium' }}>
|
121
|
-
{value}
|
122
|
-
</Text>
|
123
|
-
</Box>
|
124
|
-
);
|
125
|
-
};
|
File without changes
|