@selfcommunity/react-ui
Version:
React UI Components to integrate a Community created with SelfCommunity Platform.
28 lines (27 loc) • 1.49 kB
JavaScript
import { __rest } from "tslib";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import * as React from 'react';
import { Track } from 'livekit-client';
import { useTrackToggle, CameraIcon, CameraDisabledIcon, MicDisabledIcon, MicIcon, ScreenShareIcon, ScreenShareStopIcon } from '@livekit/components-react';
export function getSourceIcon(source, enabled) {
switch (source) {
case Track.Source.Microphone:
return enabled ? _jsx(MicIcon, {}) : _jsx(MicDisabledIcon, {});
case Track.Source.Camera:
return enabled ? _jsx(CameraIcon, {}) : _jsx(CameraDisabledIcon, {});
case Track.Source.ScreenShare:
return enabled ? _jsx(ScreenShareStopIcon, {}) : _jsx(ScreenShareIcon, {});
default:
return undefined;
}
}
/**
* With the `TrackToggle` component it is possible to mute and unmute your camera and microphone.
* The component uses an html button element under the hood so you can treat it like a button.
*/
export const TrackToggle =
/* @__PURE__ */ React.forwardRef(function TrackToggle(_a, ref) {
var { showIcon, disabled } = _a, props = __rest(_a, ["showIcon", "disabled"]);
const { buttonProps, enabled } = useTrackToggle(props);
return (_jsxs("button", Object.assign({ ref: ref }, buttonProps, { disabled: disabled }, { children: [(showIcon !== null && showIcon !== void 0 ? showIcon : true) && getSourceIcon(props.source, enabled && !disabled), props.children] })));
});