mirror of
https://github.com/element-hq/element-call.git
synced 2026-11-22 12:17:37 +00:00
MediaButtonWithContextMenu holds the mute button, the chevron and the menu's open state; AudioContextMenu and CameraContextMenu are its content, and AudioMenuButton and CameraMenuButton wire each to its own view model. The view model is split the same way: the audio menu carries the output devices, the camera menu the background effects and the preview. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
/*
|
|
Copyright 2026 Element Creations Ltd.
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
Please see LICENSE in the repository root for full details.
|
|
*/
|
|
|
|
import { useState, type FC, type ReactNode } from "react";
|
|
|
|
import { RootElementProvider } from "../RootElementContext";
|
|
|
|
/** Supplies a call-sized root. Without one the list is bounded by the whole Storybook frame. */
|
|
export const WithACallArea: FC<{ children: ReactNode; blockSize?: number }> = ({
|
|
children,
|
|
// A call's size: anything smaller makes a short device list scroll, and a
|
|
// narrower one narrows the menu.
|
|
blockSize = 720,
|
|
}) => {
|
|
const [callArea, setCallArea] = useState<HTMLElement | null>(null);
|
|
return (
|
|
<div
|
|
ref={setCallArea}
|
|
style={{
|
|
blockSize,
|
|
inlineSize: 1024,
|
|
display: "flex",
|
|
alignItems: "flex-end",
|
|
justifyContent: "center",
|
|
}}
|
|
>
|
|
{callArea !== null && (
|
|
<RootElementProvider value={callArea}>{children}</RootElementProvider>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
/** Painted outline width, in px. */
|
|
export function outlineWidth(element: HTMLElement): number {
|
|
const { outlineStyle, outlineWidth } = getComputedStyle(element);
|
|
if (outlineStyle === "none") return 0;
|
|
return Number.parseFloat(outlineWidth) || 0;
|
|
}
|