Skip to content

Commit a2e9b41

Browse files
VIDSOL-217: Use global variables to change fontFamily and colors (#240)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 96d0ff7 commit a2e9b41

File tree

40 files changed

+437
-210
lines changed

40 files changed

+437
-210
lines changed

frontend/src/App.tsx

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
22
import './css/App.css';
33
import './css/index.css';
4+
import { CssBaseline, ThemeProvider } from '@mui/material';
45
import Room from './pages/MeetingRoom/index';
56
import GoodBye from './pages/GoodBye/index';
67
import WaitingRoom from './pages/WaitingRoom';
@@ -11,38 +12,42 @@ import { PublisherProvider } from './Context/PublisherProvider';
1112
import RedirectToWaitingRoom from './components/RedirectToWaitingRoom';
1213
import UnsupportedBrowserPage from './pages/UnsupportedBrowserPage';
1314
import RoomContext from './Context/RoomContext';
15+
import customTheme from './utils/customTheme/customTheme';
1416

1517
const App = () => {
1618
return (
17-
<Router>
18-
<Routes>
19-
<Route element={<RoomContext />}>
20-
<Route
21-
path="/waiting-room/:roomName"
22-
element={
23-
<PreviewPublisherProvider>
24-
<WaitingRoom />
25-
</PreviewPublisherProvider>
26-
}
27-
/>
28-
<Route
29-
path="/room/:roomName"
30-
element={
31-
<SessionProvider>
32-
<RedirectToWaitingRoom>
33-
<PublisherProvider>
34-
<Room />
35-
</PublisherProvider>
36-
</RedirectToWaitingRoom>
37-
</SessionProvider>
38-
}
39-
/>
40-
</Route>
41-
<Route path="/goodbye" element={<GoodBye />} />
42-
<Route path="*" element={<LandingPage />} />
43-
<Route path="/unsupported-browser" element={<UnsupportedBrowserPage />} />
44-
</Routes>
45-
</Router>
19+
<ThemeProvider theme={customTheme}>
20+
<CssBaseline />
21+
<Router>
22+
<Routes>
23+
<Route element={<RoomContext />}>
24+
<Route
25+
path="/waiting-room/:roomName"
26+
element={
27+
<PreviewPublisherProvider>
28+
<WaitingRoom />
29+
</PreviewPublisherProvider>
30+
}
31+
/>
32+
<Route
33+
path="/room/:roomName"
34+
element={
35+
<SessionProvider>
36+
<RedirectToWaitingRoom>
37+
<PublisherProvider>
38+
<Room />
39+
</PublisherProvider>
40+
</RedirectToWaitingRoom>
41+
</SessionProvider>
42+
}
43+
/>
44+
</Route>
45+
<Route path="/goodbye" element={<GoodBye />} />
46+
<Route path="*" element={<LandingPage />} />
47+
<Route path="/unsupported-browser" element={<UnsupportedBrowserPage />} />
48+
</Routes>
49+
</Router>
50+
</ThemeProvider>
4651
);
4752
};
4853

frontend/src/components/BackgroundEffects/SelectableOption/SelectableOption.spec.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ describe('SelectableOption', () => {
1919

2020
it('renders with image when image is provided', () => {
2121
render(
22-
<SelectableOption isSelected={false} onClick={() => {}} id="img-option" image="/test.jpg" />
22+
<SelectableOption
23+
isSelected={false}
24+
onClick={() => {}}
25+
title="background"
26+
id="img-option"
27+
image="/test.jpg"
28+
/>
2329
);
2430
expect(screen.getByTestId('background-img-option')).toBeInTheDocument();
2531
expect(screen.getByAltText('background')).toHaveAttribute('src', '/test.jpg');

frontend/src/components/BackgroundEffects/SelectableOption/SelectableOption.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ReactElement, ReactNode } from 'react';
22
import { Box, Paper, Tooltip } from '@mui/material';
33
import { DEFAULT_SELECTABLE_OPTION_WIDTH } from '../../../utils/constants';
4+
import { colors } from '../../../utils/customTheme/customTheme';
45

56
export type SelectableOptionProps = {
67
isSelected: boolean;
@@ -63,13 +64,13 @@ const SelectableOption = ({
6364
height: size,
6465
overflow: 'hidden',
6566
borderRadius: '16px',
66-
border: isSelected ? '2px solid #1976d2' : '',
67+
border: isSelected ? `2px solid ${colors.primary}` : '',
6768
cursor: isDisabled ? 'not-allowed' : 'pointer',
6869
display: 'flex',
6970
alignItems: 'center',
7071
justifyContent: 'center',
7172
transition: 'all 0.1s ease-in-out',
72-
backgroundColor: isDisabled ? '#f5f5f5' : '#fff',
73+
backgroundColor: isDisabled ? colors.backgroundDisabled : colors.background,
7374
opacity: isDisabled ? 0.5 : 1,
7475
}}
7576
{...otherProps}
@@ -88,7 +89,7 @@ const SelectableOption = ({
8889
<img
8990
src={image}
9091
title={title}
91-
alt="background"
92+
alt={title}
9293
style={{ width: '100%', height: '100%', objectFit: 'cover' }}
9394
/>
9495
) : (

frontend/src/components/MeetingRoom/DeviceControlButton/DeviceControlButton.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import DeviceSettingsMenu from '../DeviceSettingsMenu';
1313
import useBackgroundPublisherContext from '../../../hooks/useBackgroundPublisherContext';
1414
import useConfigContext from '../../../hooks/useConfigContext';
1515
import getControlButtonTooltip from '../../../utils/getControlButtonTooltip';
16+
import { colors } from '../../../utils/customTheme/customTheme';
1617

1718
export type DeviceControlButtonProps = {
1819
deviceType: 'audio' | 'video';
@@ -115,7 +116,7 @@ const DeviceControlButton = ({
115116
data-testid={isAudio ? 'audio-dropdown-button' : 'video-dropdown-button'}
116117
>
117118
{open ? (
118-
<ArrowDropDown sx={{ color: 'rgb(138, 180, 248)' }} />
119+
<ArrowDropDown sx={{ color: colors.primaryLight }} />
119120
) : (
120121
<ArrowDropUp className="text-gray-400" />
121122
)}

frontend/src/components/MeetingRoom/DeviceSettingsMenu/DeviceSettingsMenu.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import VideoDevices from '../VideoDevices';
1414
import DropdownSeparator from '../DropdownSeparator';
1515
import VideoDevicesOptions from '../VideoDevicesOptions';
1616
import useConfigContext from '../../../hooks/useConfigContext';
17+
import { colors } from '../../../utils/customTheme/customTheme';
1718

1819
export type DeviceSettingsMenuProps = {
1920
deviceType: 'audio' | 'video';
@@ -55,7 +56,6 @@ const DeviceSettingsMenu = ({
5556
const config = useConfigContext();
5657
const isAudio = deviceType === 'audio';
5758
const theme = useTheme();
58-
const customLightBlueColor = 'rgb(138, 180, 248)';
5959
const { allowBackgroundEffects } = config.videoSettings;
6060
const shouldDisplayBackgroundEffects = hasMediaProcessorSupport() && allowBackgroundEffects;
6161

@@ -70,16 +70,16 @@ const DeviceSettingsMenu = ({
7070
if (isAudio) {
7171
return (
7272
<>
73-
<InputDevices handleToggle={handleToggle} customLightBlueColor={customLightBlueColor} />
74-
<OutputDevices handleToggle={handleToggle} customLightBlueColor={customLightBlueColor} />
75-
<ReduceNoiseTestSpeakers customLightBlueColor={customLightBlueColor} />
73+
<InputDevices handleToggle={handleToggle} />
74+
<OutputDevices handleToggle={handleToggle} />
75+
<ReduceNoiseTestSpeakers />
7676
</>
7777
);
7878
}
7979

8080
return (
8181
<>
82-
<VideoDevices handleToggle={handleToggle} customLightBlueColor={customLightBlueColor} />
82+
<VideoDevices handleToggle={handleToggle} />
8383
{shouldDisplayBackgroundEffects && (
8484
<>
8585
<DropdownSeparator />
@@ -110,14 +110,14 @@ const DeviceSettingsMenu = ({
110110
<ClickAwayListener onClickAway={handleClose}>
111111
<Paper
112112
sx={{
113-
backgroundColor: 'rgb(32, 33, 36)',
114-
color: '#fff',
115-
padding: { xs: 1, sm: 2 }, // responsive padding
113+
backgroundColor: colors.darkGrey,
114+
color: colors.onPrimary,
115+
padding: { xs: 1, sm: 2 },
116116
borderRadius: 2,
117117
zIndex: 1,
118118
transform: isAudio
119119
? 'translateY(-2%) translateX(5%)'
120-
: 'translateY(-5%) translateX(-15%)', // default transform
120+
: 'translateY(-5%) translateX(-15%)',
121121
[theme.breakpoints.down(741)]: {
122122
transform: isAudio
123123
? 'translateY(-2%) translateX(-10%)'
@@ -128,9 +128,9 @@ const DeviceSettingsMenu = ({
128128
? 'translateY(-2%) translateX(-5%)'
129129
: 'translateY(-5%) translateX(-5%)',
130130
},
131-
width: { xs: '90vw', sm: '100%' }, // responsive width
132-
maxWidth: 400, // max width for larger screens
133-
position: 'relative', // ensures the transform is applied correctly
131+
width: { xs: '90vw', sm: '100%' },
132+
maxWidth: 400,
133+
position: 'relative',
134134
}}
135135
>
136136
{renderSettingsMenu()}

frontend/src/components/MeetingRoom/EmojiGrid/EmojiGridDesktop.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ReactElement, RefObject, useEffect, useState } from 'react';
33
import { PopperChildrenProps } from '@mui/base';
44
import SendEmojiButton from '../SendEmojiButton';
55
import emojiMap from '../../../utils/emojis';
6+
import { colors } from '../../../utils/customTheme/customTheme';
67

78
export type EmojiGridDesktopProps = {
89
handleClickAway: (event: MouseEvent | TouchEvent) => void;
@@ -57,8 +58,8 @@ const EmojiGridDesktop = ({
5758
className="flex items-center justify-center"
5859
data-testid="emoji-grid"
5960
sx={{
60-
backgroundColor: 'rgb(32, 33, 36)',
61-
color: '#fff',
61+
backgroundColor: colors.darkGrey,
62+
color: colors.onPrimary,
6263
padding: { xs: 1 },
6364
borderRadius: 2,
6465
zIndex: 1,

frontend/src/components/MeetingRoom/EmojiGridButton/EmojiGridButton.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useTranslation } from 'react-i18next';
55
import ToolbarButton from '../ToolbarButton';
66
import EmojiGrid from '../EmojiGrid/EmojiGrid';
77
import useConfigContext from '../../../hooks/useConfigContext';
8+
import { colors } from '../../../utils/customTheme/customTheme';
89

910
export type EmojiGridProps = {
1011
isEmojiGridOpen: boolean;
@@ -46,7 +47,7 @@ const EmojiGridButton = ({
4647
onClick={handleToggle}
4748
icon={
4849
<EmojiEmotions
49-
style={{ color: `${!isEmojiGridOpen ? 'white' : 'rgb(138, 180, 248)'}` }}
50+
style={{ color: `${!isEmojiGridOpen ? 'white' : colors.primaryLight}` }}
5051
/>
5152
}
5253
ref={anchorRef}

frontend/src/components/MeetingRoom/InputDevices/InputDevices.spec.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ describe('InputDevices Component', () => {
7474
});
7575

7676
it('renders all available audio input devices', () => {
77-
render(<InputDevices handleToggle={mockHandleToggle} customLightBlueColor="#00f" />);
77+
render(<InputDevices handleToggle={mockHandleToggle} />);
7878

7979
expect(screen.getByText('Microphone')).toBeInTheDocument();
8080

@@ -85,7 +85,7 @@ describe('InputDevices Component', () => {
8585
});
8686

8787
it('changes audio input device on menu item click', () => {
88-
render(<InputDevices handleToggle={mockHandleToggle} customLightBlueColor="#00f" />);
88+
render(<InputDevices handleToggle={mockHandleToggle} />);
8989

9090
const micItem = screen.getByText('MacBook Pro Microphone (Built-in)');
9191
fireEvent.click(micItem);
@@ -97,7 +97,7 @@ describe('InputDevices Component', () => {
9797
});
9898

9999
it('does not call setAudioSource if selected device is not found', () => {
100-
render(<InputDevices handleToggle={mockHandleToggle} customLightBlueColor="#00f" />);
100+
render(<InputDevices handleToggle={mockHandleToggle} />);
101101

102102
const bogusItem = document.createElement('li');
103103
bogusItem.textContent = 'Nonexistent Microphone';
@@ -110,7 +110,7 @@ describe('InputDevices Component', () => {
110110
publisherContext.publisher = null;
111111
mockUsePublisherContext.mockReturnValue(publisherContext);
112112

113-
render(<InputDevices handleToggle={mockHandleToggle} customLightBlueColor="#00f" />);
113+
render(<InputDevices handleToggle={mockHandleToggle} />);
114114

115115
const micItem = screen.getByText('MacBook Pro Microphone (Built-in)');
116116
fireEvent.click(micItem);
@@ -120,7 +120,7 @@ describe('InputDevices Component', () => {
120120
});
121121

122122
it('shows check icon for selected device', () => {
123-
render(<InputDevices handleToggle={mockHandleToggle} customLightBlueColor="#00f" />);
123+
render(<InputDevices handleToggle={mockHandleToggle} />);
124124

125125
// The default audio device should be selected
126126
const checkIcon = screen.getByTestId('CheckIcon');
@@ -131,13 +131,13 @@ describe('InputDevices Component', () => {
131131
mockConfigContext.meetingRoomSettings.allowDeviceSelection = false;
132132
mockUseConfigContext.mockReturnValue(mockConfigContext);
133133

134-
render(<InputDevices handleToggle={mockHandleToggle} customLightBlueColor="#00f" />);
134+
render(<InputDevices handleToggle={mockHandleToggle} />);
135135

136136
expect(screen.queryByText('Microphone')).not.toBeInTheDocument();
137137
});
138138

139139
it('handles click event when audioDeviceId is found', () => {
140-
render(<InputDevices handleToggle={mockHandleToggle} customLightBlueColor="#00f" />);
140+
render(<InputDevices handleToggle={mockHandleToggle} />);
141141

142142
const micItem = screen.getByText('Soundcore Life A2 NC (Bluetooth)');
143143
fireEvent.click(micItem);

frontend/src/components/MeetingRoom/InputDevices/InputDevices.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import usePublisherContext from '../../../hooks/usePublisherContext';
99
import { setStorageItem, STORAGE_KEYS } from '../../../utils/storage';
1010
import useConfigContext from '../../../hooks/useConfigContext';
1111
import cleanAndDedupeDeviceLabels from '../../../utils/cleanAndDedupeDeviceLabels';
12+
import { colors } from '../../../utils/customTheme/customTheme';
1213

1314
export type InputDevicesProps = {
1415
handleToggle: () => void;
15-
customLightBlueColor: string;
1616
};
1717

1818
/**
@@ -21,13 +21,9 @@ export type InputDevicesProps = {
2121
* Displays the audio input devices for a user. Handles switching audio input devices.
2222
* @param {InputDevicesProps} props - The props for the component.
2323
* @property {Function} handleToggle - The click handler to handle closing the menu.
24-
* @property {string} customLightBlueColor - The custom color used for the toggled icon.
2524
* @returns {ReactElement | false} - The InputDevices component.
2625
*/
27-
const InputDevices = ({
28-
handleToggle,
29-
customLightBlueColor,
30-
}: InputDevicesProps): ReactElement | false => {
26+
const InputDevices = ({ handleToggle }: InputDevicesProps): ReactElement | false => {
3127
const { t } = useTranslation();
3228
const { publisher } = usePublisherContext();
3329
const { meetingRoomSettings } = useConfigContext();
@@ -83,22 +79,23 @@ const InputDevices = ({
8379
backgroundColor: 'transparent',
8480
'&.Mui-selected': {
8581
backgroundColor: 'transparent',
86-
color: customLightBlueColor,
82+
color: colors.primaryLight,
8783
},
8884
'&:hover': {
89-
backgroundColor: 'rgba(25, 118, 210, 0.12)',
85+
backgroundColor: colors.primaryHover,
9086
},
9187
}}
9288
>
9389
<Box
90+
key={`${option}-input-device`}
9491
sx={{
9592
display: 'flex',
9693
mb: 0.5,
9794
overflow: 'hidden',
9895
}}
9996
>
10097
{isSelected ? (
101-
<CheckIcon sx={{ color: customLightBlueColor, fontSize: 24, mr: 2 }} />
98+
<CheckIcon sx={{ color: colors.primaryLight, fontSize: 24, mr: 2 }} />
10299
) : (
103100
<Box sx={{ width: 40 }} /> // Placeholder when CheckIcon is not displayed
104101
)}

0 commit comments

Comments
 (0)