mirror of
https://github.com/suitenumerique/meet.git
synced 2026-07-26 11:58:53 +00:00
📝(docs) add pip component documentation
add jsdoc comments to pip components and hooks
This commit is contained in:
@@ -29,6 +29,12 @@ const copyStyles = (source: Document, target: Document) => {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* React Portal that renders children into a Document Picture-in-Picture window.
|
||||
* Handles PiP window lifecycle, style injection, React root management, and uses UNSAFE_PortalProvider
|
||||
* to ensure React Aria overlays render correctly within the PiP window.
|
||||
* Creates a fresh React root on reopen to prevent black screen issues.
|
||||
*/
|
||||
export const DocumentPiPPortal = ({
|
||||
isOpen,
|
||||
width,
|
||||
|
||||
@@ -9,7 +9,10 @@ import { HandToggle } from './controls/HandToggle'
|
||||
import { OptionsButton } from './controls/Options/OptionsButton'
|
||||
import { StartMediaButton } from './controls/StartMediaButton'
|
||||
|
||||
// Compact PiP toolbar; keep all PiP-specific controls in one place.
|
||||
/**
|
||||
* Compact control bar for the Picture-in-Picture window.
|
||||
* Centralizes all PiP controls (devices, reactions, screen share, options, etc.) in one reusable component.
|
||||
*/
|
||||
export const PipControlBar = ({
|
||||
showScreenShare,
|
||||
}: {
|
||||
|
||||
@@ -23,7 +23,11 @@ const pickTrackForPip = (
|
||||
return tracks[0]
|
||||
}
|
||||
|
||||
// Renders the PiP viewport and a compact control bar inside the PiP window.
|
||||
/**
|
||||
* Main view component for the Picture-in-Picture window.
|
||||
* Handles track selection (prioritizes screen share), layout switching (grid for multiple participants),
|
||||
* and renders the control bar and side panel within the PiP window.
|
||||
*/
|
||||
export const PipView = () => {
|
||||
const tracks = useTracks(
|
||||
[
|
||||
|
||||
@@ -2,6 +2,10 @@ import { DocumentPiPPortal } from './DocumentPiPPortal'
|
||||
import { PipView } from './PipView'
|
||||
import { useRoomPiP } from '../hooks/useRoomPiP'
|
||||
|
||||
/**
|
||||
* Wrapper that mounts the PiP UI when room-level PiP state is enabled.
|
||||
* Bridges RoomPiPProvider state with DocumentPiPPortal and PipView rendering.
|
||||
*/
|
||||
export const RoomPiP = () => {
|
||||
const { isOpen, close } = useRoomPiP()
|
||||
|
||||
|
||||
+5
-2
@@ -11,14 +11,17 @@ type PipOptionsMenuProps = {
|
||||
label: string
|
||||
}
|
||||
|
||||
// PiP-specific options menu positioned locally above the trigger button.
|
||||
/**
|
||||
* PiP-specific options menu with absolute positioning for correct alignment in PiP window.
|
||||
* Renders locally (unlike standard Menu) and closes automatically on item click or outside click.
|
||||
*/
|
||||
export const PipOptionsMenu = ({
|
||||
wrapperRef,
|
||||
isOpen,
|
||||
setIsOpen,
|
||||
label,
|
||||
}: PipOptionsMenuProps) => {
|
||||
// Close menu when a menu item action completes (e.g., transcription, effects).
|
||||
// Close menu when a menu item action completes (e.g., transcription, effects, recording).
|
||||
useEffect(() => {
|
||||
if (!isOpen) return
|
||||
const doc = wrapperRef.current?.ownerDocument ?? document
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import { useCallback, useMemo, useState } from 'react'
|
||||
import { RoomPiPContext } from './roomPiPContext'
|
||||
|
||||
/**
|
||||
* Context Provider that manages Picture-in-Picture state at the room level.
|
||||
* Handles open/closed state, browser support detection, and exposes open/close/toggle functions.
|
||||
* Components access PiP state via the useRoomPiP hook.
|
||||
*/
|
||||
export const RoomPiPProvider = ({
|
||||
children,
|
||||
}: {
|
||||
|
||||
@@ -1,20 +1,23 @@
|
||||
import { useMemo } from 'react'
|
||||
import { useUNSAFE_PortalContext } from '@react-aria/overlays'
|
||||
|
||||
/**
|
||||
* Hook to retrieve the portal container for overlays (menus, tooltips, popovers).
|
||||
* Returns the container from UNSAFE_PortalProvider context (pip-root in PiP, undefined in main window).
|
||||
*/
|
||||
export const useOverlayPortalContainer = () => {
|
||||
const { getContainer } = useUNSAFE_PortalContext()
|
||||
|
||||
// Read the portal container provided by UNSAFE_PortalProvider.
|
||||
// This is how overlays know which document/window they should render into.
|
||||
// "UNSAFE" means we're overriding the library default container on purpose.
|
||||
return useMemo(() => getContainer?.() ?? undefined, [getContainer])
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook to retrieve the boundary element for overlay positioning.
|
||||
* Returns the portal container in PiP (for PiP-relative positioning), undefined in main window.
|
||||
*/
|
||||
export const useOverlayBoundaryElement = () => {
|
||||
const portalContainer = useOverlayPortalContainer()
|
||||
return useMemo(() => {
|
||||
// Use the portal container as the positioning boundary.
|
||||
// In PiP this keeps overlays positioned relative to the PiP window.
|
||||
if (portalContainer) return portalContainer
|
||||
return undefined
|
||||
}, [portalContainer])
|
||||
|
||||
Reference in New Issue
Block a user