Skip to content

Commit

Permalink
fix: convert tile dimensions to numeric
Browse files Browse the repository at this point in the history
  • Loading branch information
KaustubhKumar05 authored Sep 19, 2023
1 parent d8a7619 commit fc08bbd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
21 changes: 14 additions & 7 deletions packages/roomkit-react/src/Prebuilt/components/VideoTile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,28 @@ const Tile = ({
const onHoverHandler = useCallback(event => {
setIsMouseHovered(event.type === 'mouseenter');
}, []);
const isTileBigEnoughToShowStats = height >= 180 && width >= 180;

const ref = useRef(null);
const calculatedHeight = ref.current?.clientHeight || '';
const calculatedWidth = ref.current?.clientWidth || '';

const isTileBigEnoughToShowStats = calculatedHeight >= 180 && calculatedWidth >= 180;

const avatarSize = useMemo(() => {
if (!width || !height) {
if (!calculatedWidth || !calculatedHeight) {
return undefined;
}
if (width <= 150 || height <= 150) {
if (calculatedWidth <= 150 || calculatedHeight <= 150) {
return 'small';
} else if (width <= 300 || height <= 300) {
} else if (calculatedWidth <= 300 || calculatedHeight <= 300) {
return 'medium';
}
return 'large';
}, [width, height]);
}, [calculatedWidth, calculatedHeight]);

return (
<StyledVideoTile.Root
ref={ref}
css={{
width,
height,
Expand Down Expand Up @@ -134,7 +141,7 @@ const Tile = ({
isAudioMuted ? (
<StyledVideoTile.AudioIndicator
data-testid="participant_audio_mute_icon"
size={getAttributeBoxSize(width, height)}
size={getAttributeBoxSize(calculatedWidth, calculatedHeight)}
>
<MicOffIcon />
</StyledVideoTile.AudioIndicator>
Expand All @@ -151,7 +158,7 @@ const Tile = ({
enableSpotlightingPeer={enableSpotlightingPeer}
/>
) : null}
{!hideMetadataOnTile && <PeerMetadata peerId={peerId} height={height} width={width} />}
{!hideMetadataOnTile && <PeerMetadata peerId={peerId} height={calculatedHeight} width={calculatedWidth} />}

<TileConnection
hideLabel={hideParticipantNameOnTile}
Expand Down
1 change: 0 additions & 1 deletion packages/roomkit-react/src/Prebuilt/layouts/SidePane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ const SidePane = ({
<VideoTile
peerId={activeScreensharePeerId}
trackId={trackId}
width="100%"
height={225}
rootCSS={{ p: 0, alignSelf: 'start', flexShrink: 0 }}
{...tileLayout}
Expand Down

0 comments on commit fc08bbd

Please sign in to comment.