From 4a6b84ed50b9a8cedb79980fa4eaba919766f9e2 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Mon, 30 Jun 2025 18:03:20 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8(frontend)=20remove=20redundant=20R?= =?UTF-8?q?eact=20fragments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove unnecessary React fragments that contain only one child or are direct children of HTML elements. Simplifies JSX structure by eliminating redundant wrapper elements that don't add functional value. --- .../controls/Options/OptionsButton.tsx | 24 +- .../effects/EffectsConfiguration.tsx | 218 +++++++++--------- .../prefabs/ControlBar/DesktopControlBar.tsx | 118 +++++----- src/frontend/src/primitives/Spinner.tsx | 74 +++--- 4 files changed, 213 insertions(+), 221 deletions(-) diff --git a/src/frontend/src/features/rooms/livekit/components/controls/Options/OptionsButton.tsx b/src/frontend/src/features/rooms/livekit/components/controls/Options/OptionsButton.tsx index 4de38d59..5bf7d92b 100644 --- a/src/frontend/src/features/rooms/livekit/components/controls/Options/OptionsButton.tsx +++ b/src/frontend/src/features/rooms/livekit/components/controls/Options/OptionsButton.tsx @@ -7,18 +7,16 @@ export const OptionsButton = () => { const { t } = useTranslation('rooms') return ( - <> - - - - - + + + + ) } diff --git a/src/frontend/src/features/rooms/livekit/components/effects/EffectsConfiguration.tsx b/src/frontend/src/features/rooms/livekit/components/effects/EffectsConfiguration.tsx index e87ed39f..80b6397b 100644 --- a/src/frontend/src/features/rooms/livekit/components/effects/EffectsConfiguration.tsx +++ b/src/frontend/src/features/rooms/livekit/components/effects/EffectsConfiguration.tsx @@ -247,9 +247,81 @@ export const EffectsConfiguration = ({ /> )} {isSupported ? ( - <> +
-
+ + {t('blur.title')} + +
+ { + await clearEffect() + }} + isSelected={!getProcessor()} + isDisabled={processorPendingReveal} + > + + + + await toggleEffect(ProcessorType.BLUR, { + blurRadius: BlurRadius.LIGHT, + }) + } + isSelected={isSelected(ProcessorType.BLUR, { + blurRadius: BlurRadius.LIGHT, + })} + data-attr="toggle-blur-light" + > + + + + await toggleEffect(ProcessorType.BLUR, { + blurRadius: BlurRadius.NORMAL, + }) + } + isSelected={isSelected(ProcessorType.BLUR, { + blurRadius: BlurRadius.NORMAL, + })} + data-attr="toggle-blur-normal" + > + + +
+
- {t('blur.title')} + {t('virtual.title')}
- { - await clearEffect() - }} - isSelected={!getProcessor()} - isDisabled={processorPendingReveal} - > - - - - await toggleEffect(ProcessorType.BLUR, { - blurRadius: BlurRadius.LIGHT, - }) - } - isSelected={isSelected(ProcessorType.BLUR, { - blurRadius: BlurRadius.LIGHT, - })} - data-attr="toggle-blur-light" - > - - - - await toggleEffect(ProcessorType.BLUR, { - blurRadius: BlurRadius.NORMAL, - }) - } - isSelected={isSelected(ProcessorType.BLUR, { - blurRadius: BlurRadius.NORMAL, - })} - data-attr="toggle-blur-normal" - > - - -
-
{ + const imagePath = `/assets/backgrounds/${i + 1}.jpg` + const thumbnailPath = `/assets/backgrounds/thumbnails/${i + 1}.jpg` + return ( + + await toggleEffect(ProcessorType.VIRTUAL, { + imagePath, + }) + } + isSelected={isSelected(ProcessorType.VIRTUAL, { + imagePath, + })} + className={css({ + bgSize: 'cover', + })} + style={{ + backgroundImage: `url(${thumbnailPath})`, + }} + data-attr={`toggle-virtual-${i}`} + /> + ) })} - > - - {t('virtual.title')} - -
- {[...Array(8).keys()].map((i) => { - const imagePath = `/assets/backgrounds/${i + 1}.jpg` - const thumbnailPath = `/assets/backgrounds/thumbnails/${i + 1}.jpg` - return ( - - await toggleEffect(ProcessorType.VIRTUAL, { - imagePath, - }) - } - isSelected={isSelected(ProcessorType.VIRTUAL, { - imagePath, - })} - className={css({ - bgSize: 'cover', - })} - style={{ - backgroundImage: `url(${thumbnailPath})`, - }} - data-attr={`toggle-virtual-${i}`} - /> - ) - })} -
- +
) : ( {t('notAvailable')} diff --git a/src/frontend/src/features/rooms/livekit/prefabs/ControlBar/DesktopControlBar.tsx b/src/frontend/src/features/rooms/livekit/prefabs/ControlBar/DesktopControlBar.tsx index 8622d7b5..1874074b 100644 --- a/src/frontend/src/features/rooms/livekit/prefabs/ControlBar/DesktopControlBar.tsx +++ b/src/frontend/src/features/rooms/livekit/prefabs/ControlBar/DesktopControlBar.tsx @@ -22,75 +22,73 @@ export function DesktopControlBar({ const browserSupportsScreenSharing = supportsScreenSharing() const desktopControlBarEl = useRef(null) return ( - <> +
+
-
+ onDeviceError?.({ source: Track.Source.Microphone, error }) + } + onActiveDeviceChange={(deviceId) => + saveAudioInputDeviceId(deviceId ?? '') + } + menuVariant="dark" /> -
- + onDeviceError?.({ source: Track.Source.Camera, error }) + } + onActiveDeviceChange={(deviceId) => + saveVideoInputDeviceId(deviceId ?? '') + } + menuVariant="dark" + /> + + {browserSupportsScreenSharing && ( + - onDeviceError?.({ source: Track.Source.Microphone, error }) + onDeviceError?.({ source: Track.Source.ScreenShare, error }) } - onActiveDeviceChange={(deviceId) => - saveAudioInputDeviceId(deviceId ?? '') - } - menuVariant="dark" /> - - onDeviceError?.({ source: Track.Source.Camera, error }) - } - onActiveDeviceChange={(deviceId) => - saveVideoInputDeviceId(deviceId ?? '') - } - menuVariant="dark" - /> - - {browserSupportsScreenSharing && ( - - onDeviceError?.({ source: Track.Source.ScreenShare, error }) - } - /> - )} - - - - -
- + )} + + + +
- + +
) } diff --git a/src/frontend/src/primitives/Spinner.tsx b/src/frontend/src/primitives/Spinner.tsx index cc1e8513..fb8b8344 100644 --- a/src/frontend/src/primitives/Spinner.tsx +++ b/src/frontend/src/primitives/Spinner.tsx @@ -15,44 +15,42 @@ export const Spinner = ({ return ( {({ percentage }) => ( - <> - - - - - + + + + )} )