Skip to content

Commit f201e3d

Browse files
authored
Merge pull request #29 from oslabs-beta/feature/garrett
Feature/garrett
2 parents d14f327 + 1fa5e0b commit f201e3d

32 files changed

+539
-620
lines changed

src/app/App.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@ import React from 'react';
22
import { MemoryRouter as Router } from 'react-router-dom';
33
import MainContainer from './containers/MainContainer';
44
import { Toaster } from 'react-hot-toast';
5-
6-
/*
7-
'currentTab' is the current active tab within Google Chrome.
8-
This is used to decide what tab Reactime should be monitoring. This can be "locked" currentTabInApp is the current active tab within Reactime (Map, Performance, History, etc).
9-
This is used to determine the proper tutorial to render when How To button is pressed.
10-
*/
5+
import { ThemeProvider } from './ThemeProvider';
116

127
function App(): JSX.Element {
138
return (
14-
<Router>
15-
<Toaster />
16-
<MainContainer />
17-
</Router>
9+
<ThemeProvider>
10+
<Router>
11+
<Toaster />
12+
<MainContainer />
13+
</Router>
14+
</ThemeProvider>
1815
);
1916
}
2017

src/app/FrontendTypes.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export interface BarStackProp {
4444
currentTab?: string;
4545
}
4646

47-
// On-hover data for BarGraph/BarGraphComparison.tsx
4847
export interface TooltipData {
4948
bar: SeriesPoint<snapshot>;
5049
key: string;
@@ -105,9 +104,6 @@ export interface BarGraphComparisonAction {
105104
}
106105

107106
export interface ActionContainerProps {
108-
actionView: boolean;
109-
setActionView: React.Dispatch<React.SetStateAction<boolean>>;
110-
toggleActionContainer: () => void;
111107
snapshots: any;
112108
currLocation: any;
113109
}
@@ -223,15 +219,13 @@ export interface ActionProps {
223219
last: boolean;
224220
index: number;
225221
sliderIndex: number;
226-
// dispatch: (a: { type: string; payload: unknown }) => void;
227222
displayName: string;
228223
componentName: string;
229224
componentData: { actualDuration: number } | undefined;
230225
routePath: unknown;
231226
state?: Record<string, unknown>;
232227
viewIndex: number | undefined;
233228
isCurrIndex: boolean;
234-
handleOnkeyDown: (e: KeyboardEvent, i: number) => void;
235229
}
236230

237231
export interface DiffRouteProps {
@@ -315,7 +309,6 @@ export interface LinkControlProps {
315309
}
316310

317311
export interface ControlStyles {
318-
//fontSize: string;
319312
padding: string;
320313
}
321314

@@ -333,7 +326,6 @@ export interface DropDownStyle {
333326
export interface Node {
334327
children?: Node[];
335328
name?: string;
336-
// other properties here
337329
}
338330

339331
export interface LinkComponent {

src/app/ThemeProvider.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React, { createContext, useContext, useState, useEffect } from 'react';
2+
3+
const ThemeContext = createContext({
4+
isDark: false,
5+
toggleTheme: () => {},
6+
});
7+
8+
export const ThemeProvider = ({ children }) => {
9+
const [isDark, setIsDark] = useState(false);
10+
11+
// Check for system preference on mount
12+
useEffect(() => {
13+
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
14+
setIsDark(prefersDark);
15+
}, []);
16+
17+
// Update body class when theme changes
18+
useEffect(() => {
19+
if (isDark) {
20+
document.documentElement.classList.add('dark');
21+
} else {
22+
document.documentElement.classList.remove('dark');
23+
}
24+
}, [isDark]);
25+
26+
const toggleTheme = () => {
27+
setIsDark((prev) => !prev);
28+
};
29+
30+
return <ThemeContext.Provider value={{ isDark, toggleTheme }}>{children}</ThemeContext.Provider>;
31+
};
32+
33+
export const useTheme = () => {
34+
const context = useContext(ThemeContext);
35+
if (context === undefined) {
36+
throw new Error('useTheme must be used within a ThemeProvider');
37+
}
38+
return context;
39+
};

src/app/components/Actions/Action.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,8 @@ import { useDispatch } from 'react-redux';
77
const Action = (props: ActionProps): JSX.Element => {
88
const dispatch = useDispatch();
99

10-
const {
11-
selected,
12-
last,
13-
index,
14-
sliderIndex,
15-
displayName,
16-
componentData,
17-
viewIndex,
18-
isCurrIndex,
19-
handleOnkeyDown,
20-
} = props;
10+
const { selected, last, index, sliderIndex, displayName, componentData, viewIndex, isCurrIndex } =
11+
props;
2112

2213
const cleanTime = (): string => {
2314
if (!componentData || !componentData.actualDuration) {
@@ -64,7 +55,6 @@ const Action = (props: ActionProps): JSX.Element => {
6455
<div className='individual-action'>
6556
<div
6657
// @ts-ignore
67-
onKeyDown={(e): void => handleOnkeyDown(e, viewIndex)}
6858
className={selected || last ? 'action-component selected' : 'action-component'}
6959
onClick={() => {
7060
dispatch(changeView(index));

src/app/components/Actions/DropDown.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const DropDown = ({
2121
<div className='dropdown-container'>
2222
<Select
2323
placeholder='Select Hook'
24+
classNamePrefix='react-select'
2425
onChange={handleChange}
2526
options={options}
2627
value={options.find((option) => option.value === dropdownSelection)}

src/app/components/Actions/RecordButton.tsx

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,41 @@
11
import React from 'react';
22
import { Switch } from '@mui/material';
3+
import ThemeToggle from './ThemeToggle';
34

45
const RecordButton = ({ isRecording, onToggle }) => {
56
return (
67
<div className='record-button-container'>
7-
<div className='record-label'>
8-
<div
9-
className={`record-icon ${isRecording ? 'recording' : ''}`}
10-
style={{
11-
backgroundColor: isRecording ? '#ef4444' : '#9ca3af',
12-
transition: 'background-color 0.3s ease',
8+
<div className='record-controls'>
9+
<div className='record-label'>
10+
<div
11+
className={`record-icon ${isRecording ? 'recording' : ''}`}
12+
style={{
13+
backgroundColor: isRecording ? '#ef4444' : '#9ca3af',
14+
transition: 'background-color 0.3s ease',
15+
}}
16+
/>
17+
<span>Record</span>
18+
</div>
19+
<Switch
20+
checked={isRecording}
21+
onChange={onToggle}
22+
sx={{
23+
'& .MuiSwitch-switchBase': {
24+
color: '#9ca3af',
25+
},
26+
'& .MuiSwitch-track': {
27+
backgroundColor: '#e5e7eb',
28+
},
29+
'& .MuiSwitch-switchBase.Mui-checked': {
30+
color: '#374151',
31+
},
32+
'& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track': {
33+
backgroundColor: '#0284c7',
34+
},
1335
}}
1436
/>
15-
<span>Record</span>
1637
</div>
17-
<Switch
18-
checked={isRecording}
19-
onChange={onToggle}
20-
sx={{
21-
'& .MuiSwitch-switchBase': {
22-
color: '#9ca3af',
23-
},
24-
'& .MuiSwitch-track': {
25-
backgroundColor: '#e5e7eb',
26-
},
27-
'& .MuiSwitch-switchBase.Mui-checked': {
28-
color: '#374151',
29-
},
30-
'& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track': {
31-
backgroundColor: '#0284c7',
32-
},
33-
}}
34-
/>
38+
<ThemeToggle />
3539
</div>
3640
);
3741
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from 'react';
2+
import { Moon, Sun } from 'lucide-react';
3+
import { useTheme } from '../../ThemeProvider';
4+
5+
const ThemeToggle = () => {
6+
const { isDark, toggleTheme } = useTheme();
7+
8+
return (
9+
<button
10+
className={`theme-toggle ${isDark ? 'dark' : ''}`}
11+
onClick={toggleTheme}
12+
aria-label={`Switch to ${isDark ? 'light' : 'dark'} mode`}
13+
>
14+
<div className='theme-toggle-icons'>
15+
<Moon className='theme-toggle-icon moon' />
16+
<Sun className='theme-toggle-icon sun' />
17+
</div>
18+
<div className='theme-toggle-slider' />
19+
</button>
20+
);
21+
};
22+
23+
export default ThemeToggle;

src/app/components/StateRoute/AxMap/axLinkControls.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ const AxLinkControls = ({
4040
onChange={(e) => setOrientation(e.target.value)}
4141
value={orientation}
4242
>
43-
<option value='vertical'>vertical</option>
44-
<option value='horizontal'>horizontal</option>
43+
<option value='vertical'>Vertical</option>
44+
<option value='horizontal'>Horizontal</option>
4545
</select>
4646
</div>
4747

@@ -53,10 +53,10 @@ const AxLinkControls = ({
5353
onChange={(e) => setLinkType(e.target.value)}
5454
value={linkType}
5555
>
56-
<option value='diagonal'>diagonal</option>
57-
<option value='step'>step</option>
58-
<option value='curve'>curve</option>
59-
<option value='line'>line</option>
56+
<option value='diagonal'>Diagonal</option>
57+
<option value='step'>Step</option>
58+
<option value='curve'>Curve</option>
59+
<option value='line'>Line</option>
6060
</select>
6161
</div>
6262

src/app/components/StateRoute/ComponentMap/ToolTipDataDisplay.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const ToolTipDataDisplay = ({ data }) => {
77
const jsonTheme = {
88
scheme: 'custom',
99
base00: 'transparent',
10-
base0B: '#1f2937', // dark navy for strings
10+
base0B: '#14b8a6', // dark navy for strings
1111
base0D: '#60a5fa', // Keys
1212
base09: '#f59e0b', // Numbers
1313
base0C: '#EF4444', // Null values

src/app/components/StateRoute/History.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function History(props: Record<string, unknown>): JSX.Element {
9898
return changedState;
9999
}
100100

101-
if (index === 0) return 'Initial State';
101+
if (index === 0) return '<span class="initial-state">Initial State</span>';
102102

103103
// Add null checks for snapshots
104104
if (!snapshots || !snapshots[index] || !snapshots[index - 1]) {
@@ -111,7 +111,7 @@ function History(props: Record<string, unknown>): JSX.Element {
111111
statelessCleaning(snapshots[index]),
112112
);
113113

114-
if (!delta) return 'No state changes';
114+
if (!delta) return '<span class="no-changes">No State Changes</span>';
115115

116116
const changedState = findStateChangeObj(delta);
117117
return changedState.length > 0 ? formatters.html.format(changedState[0]) : 'No state changes';

0 commit comments

Comments
 (0)