-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
59 lines (48 loc) · 1.66 KB
/
index.ts
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
import { DyteUIBuilder, UIConfig } from "@dytesdk/ui-kit";
import { Meeting } from "@dytesdk/ui-kit/dist/types/types/dyte-client";
import CustomMenu, { ParticipantMenuItemArgs } from "./CustomMenuItem";
/**
* A class that represents a custom menu item in the participant menu.
* @class ParticipantTileMenu
* @example
* ```typescript
* const participantMenu = new ParticipantTileMenu([{
* label: "Custom Toggle",
* onClick: (participantId) => {
* console.log('Clicked on custom toggle for ', participantId);
* }
* }], 'top-right');
*
* const config = registerAddons([participantMenu], meeting);
* ```
*/
export default class ParticipantTileMenu {
meeting?: Meeting;
args: ParticipantMenuItemArgs[] = []
position: string;
constructor(args: ParticipantMenuItemArgs[], position: 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left') {
this.args = args;
this.position = position;
}
async unregister() {
return;
}
register(config: UIConfig, meeting: Meeting, getBuilder: (c: UIConfig) => DyteUIBuilder) {
if (!customElements.get("dyte-participant-tile-menu")) {
customElements.define(
"dyte-participant-tile-menu",
CustomMenu
);
}
this.meeting = meeting;
// Add buttons with config
const builder = getBuilder(config);
const dyteParticipant = builder.find(`dyte-participant-tile`);
dyteParticipant.add("dyte-participant-tile-menu", {
items: this.args as any,
position: this.position
});
// Return the updated config
return builder.build();
}
}