Skip to content

Commit 6a9221c

Browse files
committed
added: extension management and first extension point in info panel
1 parent 5a2a661 commit 6a9221c

File tree

4 files changed

+70
-4
lines changed

4 files changed

+70
-4
lines changed

src/App.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ const params = new URLSearchParams(window.location.search)
1111
const meetingProps: HxMeetingProps = {
1212
livekitUrl: params.get("livekitUrl") || import.meta.env.VITE_LIVEKIT_URL,
1313
livekitToken: params.get("livekitToken") || import.meta.env.VITE_LIVEKIT_TOKEN,
14+
extensions: {
15+
'sidebar.info.body': "Hallo"
16+
}
1417
}
1518
1619
</script>

src/components/HxMeeting.vue

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</template>
3737

3838
<script setup lang="ts">
39-
import {onMounted, onUnmounted} from "vue";
39+
import {onMounted, onUnmounted, watch, type Ref} from "vue";
4040
import HxToolbarTop from "./toolbar/HxToolbarTop.vue";
4141
import HxToolbar from "./toolbar/HxToolbar.vue";
4242
import HxSidebarPanel from "./HxSidebarPanel.vue";
@@ -56,16 +56,37 @@ import {
5656
import {useClickSidebarButton, useModal} from "../composable/ui.ts";
5757
import {useThrottleFn} from "@vueuse/core";
5858
import {defineShortcuts2 as defineShortcuts} from "../composable/nuxtui/defineShortcuts2.ts";
59+
import {type ComponentDescriptor, useExtensions} from "../composable/useExtensions.ts";
60+
5961
const { hideSidebar } = useUIState();
6062
const {closeAllModals} = useModal()
6163
6264
export interface HxMeetingProps {
6365
livekitUrl: string,
6466
livekitToken: string,
67+
extensions?: Record<string, string | Ref | ComponentDescriptor>;
6568
}
6669
6770
const props = defineProps<HxMeetingProps>()
6871
72+
// ----------------------------------------------------------
73+
// Extensions
74+
// ----------------------------------------------------------
75+
76+
const { set } = useExtensions();
77+
78+
watch(() => props.extensions, (extensions) => {
79+
console.log("extensions changed", extensions);
80+
if (!extensions) return;
81+
for (const [name, item] of Object.entries(extensions)) set(name, item);
82+
},
83+
{ immediate: true, deep: true }
84+
);
85+
86+
// ----------------------------------------------------------
87+
// ----------------------------------------------------------
88+
// ----------------------------------------------------------
89+
6990
onBeforeMount(() => {
7091
provideLivekitConfig(
7192
props.livekitUrl,

src/components/sidebar/HxInfoPanel.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<template>
22
<HxPanel title="Info">
33
<div class="text-sm" :class="{ 'select-none': sidebarResizing }">
4+
5+
<span v-if="bodyExtension && (isRef(bodyExtension) || typeof bodyExtension === 'string')">{{ bodyExtension }}</span>
6+
<component
7+
v-else-if="bodyExtension"
8+
:is="(bodyExtension as ComponentDescriptor).component"
9+
v-bind="(bodyExtension as ComponentDescriptor).props"
10+
/>
11+
412
</div>
513
<template #footer>
614
<div class="flex justify-between items-center">
@@ -26,19 +34,21 @@
2634
</template>
2735

2836
<script setup lang="ts">
29-
import {ref, onMounted} from "vue";
37+
import {ref, onMounted, isRef} from "vue";
3038
import type { DropdownMenuItem } from '@nuxt/ui'
3139
import UDropdownMenu from "@nuxt/ui/components/DropdownMenu.vue";
3240
import UTooltip from "@nuxt/ui/components/Tooltip.vue";
3341
import UButton from "@nuxt/ui/components/Button.vue";
34-
3542
import {useUIState} from "../../composable/conferenceState.ts";
3643
import HxPanel from "./HxPanel.vue";
37-
44+
import {type ComponentDescriptor, useExtensions} from '../../composable/useExtensions.ts';
3845
const { sidebarResizing } = useUIState();
3946
47+
const { get } = useExtensions();
4048
const helpItems = ref<DropdownMenuItem[][]>([]);
4149
50+
const bodyExtension = get('sidebar.info.body')
51+
4252
onMounted(async () => {
4353
helpItems.value.push([
4454
{ label: "Follow us for more news", icon: "i-hugeicons-new-twitter-ellipse", to: "https://x.com/hxmeet", target: "_blank" }

src/composable/useExtensions.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { shallowRef, type Ref, type Component, isRef } from 'vue';
2+
3+
export type ComponentDescriptor = { component: Component; props?: Record<string, any> };
4+
type ExtensionValue = Ref<string> | ComponentDescriptor;
5+
type ExtensionMap = Map<string, ExtensionValue>;
6+
const extensions: ExtensionMap = new Map();
7+
8+
export function useExtensions() {
9+
10+
const set = (name: string, item: string | Ref | ComponentDescriptor) => {
11+
if (typeof item === 'string') {
12+
console.log("set (string)", name, item)
13+
extensions.set(name, shallowRef<string>(item));
14+
} else if (isRef(item)) {
15+
console.log("set (ref)", name, item)
16+
extensions.set(name, item as Ref);
17+
} else {
18+
console.log("set (comp-descriptor)", name, item)
19+
extensions.set(name, item as ComponentDescriptor);
20+
}
21+
}
22+
23+
const get = (name: string): ExtensionValue | undefined => {
24+
return extensions.get(name);
25+
}
26+
27+
return {
28+
extensions,
29+
get,
30+
set
31+
};
32+
}

0 commit comments

Comments
 (0)