UNPKG

communication-react-19

Version:

React library for building modern communication user experiences utilizing Azure Communication Services (React 19 compatible fork)

50 lines 1.75 kB
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. /** * @internal * Converts units of rem to units of pixels * @param rem - units of rem * @returns units of pixels */ export const _convertRemToPx = (rem) => { return rem * getBrowserFontSizeInPx(); }; /** * @internal * Converts units of pixels to units of rem * @param px - units of px * @returns units of rem */ export const _convertPxToRem = (px) => { return px / getBrowserFontSizeInPx(); }; const getBrowserFontSizeInPx = () => { let fontSizeInPx = parseFloat(getComputedStyle(document.documentElement).fontSize); // If browser font size is not a number, default to 16 px if (Number.isNaN(fontSizeInPx)) { fontSizeInPx = 16; } return fontSizeInPx; }; /** * @internal * Disable dismiss on resize to work around a couple Fluent UI bugs * - The Callout is dismissed whenever *any child of window (inclusive)* is resized. In practice, this * happens when we change the VideoGallery layout, or even when the video stream element is internally resized * by the headless SDK. * - We also want to prevent dismiss when chat pane is scrolling especially a new message is added. * A side effect of this workaround is that the context menu stays open when window is resized, and may * get detached from original target visually. That bug is preferable to the bug when this value is not set - * The Callout (frequently) gets dismissed automatically. */ export const _preventDismissOnEvent = (ev) => { return ev.type === 'resize' || ev.type === 'scroll'; }; /** * @internal * Helper function to get the keys of an object */ export function _getKeys(obj) { return Object.keys(obj); } //# sourceMappingURL=common.js.map