From 2215b621f42549ea05545aa6f35c87c71ecf6794 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Thu, 14 Aug 2025 10:31:34 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F(frontend)=20refactor=20audio?= =?UTF-8?q?/video=20tabs=20to=20share=20common=20layout=20components?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extract shared layout components from audio and video tabs to eliminate code duplication and improve maintainability. Creates reusable layout components that both tabs can utilize, reducing redundancy and ensuring consistent styling and behavior across settings tabs. --- .../settings/components/tabs/AudioTab.tsx | 73 +------ .../settings/components/tabs/VideoTab.tsx | 185 +++++------------- .../components/tabs/layout/RowWrapper.tsx | 71 +++++++ 3 files changed, 128 insertions(+), 201 deletions(-) create mode 100644 src/frontend/src/features/settings/components/tabs/layout/RowWrapper.tsx diff --git a/src/frontend/src/features/settings/components/tabs/AudioTab.tsx b/src/frontend/src/features/settings/components/tabs/AudioTab.tsx index eb369067..e15bb9af 100644 --- a/src/frontend/src/features/settings/components/tabs/AudioTab.tsx +++ b/src/frontend/src/features/settings/components/tabs/AudioTab.tsx @@ -1,4 +1,4 @@ -import { DialogProps, Field, H, Switch, Text } from '@/primitives' +import { DialogProps, Field, Switch, Text } from '@/primitives' import { TabPanel, TabPanelProps } from '@/primitives/Tabs' import { @@ -9,78 +9,11 @@ import { import { isSafari } from '@/utils/livekit' import { useTranslation } from 'react-i18next' import { SoundTester } from '@/components/SoundTester' -import { HStack } from '@/styled-system/jsx' import { ActiveSpeaker } from '@/features/rooms/components/ActiveSpeaker' import { usePersistentUserChoices } from '@/features/rooms/livekit/hooks/usePersistentUserChoices' -import { ReactNode } from 'react' -import { css } from '@/styled-system/css' -import posthog from 'posthog-js' import { useNoiseReductionAvailable } from '@/features/rooms/livekit/hooks/useNoiseReductionAvailable' - -type RowWrapperProps = { - heading: string - children: ReactNode[] - beta?: boolean -} - -const BetaBadge = () => ( - - Beta - -) - -const RowWrapper = ({ heading, children, beta }: RowWrapperProps) => { - return ( - <> - - {heading} - {beta && } - - -
- {children[0]} -
-
- {children[1]} -
-
- - ) -} +import posthog from 'posthog-js' +import { RowWrapper } from './layout/RowWrapper' export type AudioTabProps = Pick & Pick diff --git a/src/frontend/src/features/settings/components/tabs/VideoTab.tsx b/src/frontend/src/features/settings/components/tabs/VideoTab.tsx index b301eef5..4bbcf62d 100644 --- a/src/frontend/src/features/settings/components/tabs/VideoTab.tsx +++ b/src/frontend/src/features/settings/components/tabs/VideoTab.tsx @@ -1,11 +1,10 @@ -import { DialogProps, Field, H } from '@/primitives' +import { DialogProps, Field } from '@/primitives' import { TabPanel, TabPanelProps } from '@/primitives/Tabs' import { useMediaDeviceSelect, useRoomContext } from '@livekit/components-react' import { useTranslation } from 'react-i18next' -import { HStack } from '@/styled-system/jsx' import { usePersistentUserChoices } from '@/features/rooms/livekit/hooks/usePersistentUserChoices' -import { ReactNode, useCallback, useEffect, useState } from 'react' +import { useCallback, useEffect, useState } from 'react' import { css } from '@/styled-system/css' import { createLocalVideoTrack, @@ -16,44 +15,7 @@ import { } from 'livekit-client' import { BackgroundProcessorFactory } from '@/features/rooms/livekit/components/blur' import { VideoResolution } from '@/stores/userChoices' - -type RowWrapperProps = { - heading: string - children: ReactNode[] -} - -const RowWrapper = ({ heading, children }: RowWrapperProps) => { - return ( - <> - {heading} - -
- {children[0]} -
-
- {children[1]} -
-
- - ) -} +import { RowWrapper } from './layout/RowWrapper' export type VideoTabProps = Pick & Pick @@ -212,104 +174,65 @@ export const VideoTab = ({ id }: VideoTabProps) => { )} - {t('resolution.heading')} - -
+ { + await handleVideoResolutionChange(key as VideoResolution) }} - > - { - await handleVideoResolutionChange(key as VideoResolution) - }} - style={{ - width: '100%', - }} - /> -
-
- - -
+ + + { + if (key == undefined) return + const selectedQuality = Number(String(key)) + saveVideoSubscribeQuality(selectedQuality) + updateExistingRemoteVideoQuality(selectedQuality) }} - > - { - if (key == undefined) return - const selectedQuality = Number(String(key)) - saveVideoSubscribeQuality(selectedQuality) - updateExistingRemoteVideoQuality(selectedQuality) - }} - style={{ - width: '100%', - }} - /> -
-
- + <> + ) } diff --git a/src/frontend/src/features/settings/components/tabs/layout/RowWrapper.tsx b/src/frontend/src/features/settings/components/tabs/layout/RowWrapper.tsx new file mode 100644 index 00000000..c668bfdc --- /dev/null +++ b/src/frontend/src/features/settings/components/tabs/layout/RowWrapper.tsx @@ -0,0 +1,71 @@ +import { ReactNode } from 'react' +import { H } from '@/primitives' +import { HStack } from '@/styled-system/jsx' +import { css } from '@/styled-system/css' + +export type RowWrapperProps = { + heading?: string + children: ReactNode[] + beta?: boolean +} + +const BetaBadge = () => ( + + Beta + +) + +export const RowWrapper = ({ heading, children, beta }: RowWrapperProps) => { + return ( + <> + {heading && ( + + {heading} + {beta && } + + )} + +
+ {children[0]} +
+
+ {children[1]} +
+
+ + ) +}