Files
element-call/src/components/DeviceMenuStoryFixtures.tsx
T
Timo K.andClaude Opus 5.5 186e1bdc9f Split the media menu into a button and per-device context menus
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>
2026-11-18 16:33:27 +01:00

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;
}