Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: dark theme support #148

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from

Conversation

AmitChauhan63390
Copy link
Contributor

@AmitChauhan63390 AmitChauhan63390 commented Nov 6, 2024

20241106-1902-08.3805076.mp4

Hey, I have added the dark theme.

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a theme management system allowing users to toggle between light and dark modes.
    • Enhanced components like Loader, NavBar, and ActionDescriptionBox to support dynamic theming.
  • Improvements

    • Updated styling for various components to improve visual consistency in dark mode.
    • Enhanced user interface elements, including buttons and tabs, for better responsiveness and aesthetics.
    • Improved layout and styling of the BrowserContent, RightSidePanel, and MainMenu components to adapt to theme changes.
    • Streamlined the Login, Register, and RecordingPage components for improved user experience.
  • Bug Fixes

    • Improved cookie handling in the IntegrationSettings component for better user experience.
  • Chores

    • Cleaned up code and formatting across multiple components for improved readability.

@amhsirak amhsirak changed the base branch from master to develop November 6, 2024 19:37
@amhsirak amhsirak changed the title dark theme added feat: dark theme support Nov 6, 2024
@amhsirak
Copy link
Member

amhsirak commented Nov 6, 2024

@AmitChauhan63390 looks great, just take a look at discord to make some fixes

@amhsirak amhsirak added the Type: Enhancement Improvements to existing features label Nov 6, 2024
@amhsirak amhsirak self-requested a review November 6, 2024 19:53
@AmitChauhan63390
Copy link
Contributor Author

Did as you told me on discord. Hope you like it

@amhsirak amhsirak requested a review from RohitR311 November 7, 2024 15:44
@amhsirak
Copy link
Member

amhsirak commented Nov 7, 2024

@RohitR311 do take a look

@amhsirak amhsirak added the Status: In Review This PR is being reviewed label Nov 8, 2024
@AmitChauhan63390
Copy link
Contributor Author

rob1.mp4

@amhsirak amhsirak added the Status: On Hold Work on this has been temporarily paused label Nov 19, 2024
Copy link
Member

@amhsirak amhsirak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at a lot of places, the theme has been reset to default MUI theme. @RohitR311 can you take it from here

Copy link

coderabbitai bot commented Dec 7, 2024

Warning

Rate limit exceeded

@AmitChauhan63390 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 48 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 9b667c9 and f11b36b.

Walkthrough

The changes in this pull request primarily focus on enhancing the theming capabilities of the application. The ThemeProvider has been replaced with a new ThemeModeProvider, which manages light and dark themes. Various components have been updated to utilize the new theming context, allowing for dynamic styling based on the current theme. Additionally, several components have been modified to support dark mode styling, improving their visual presentation and responsiveness to theme changes. Some components also underwent minor layout adjustments and enhancements to maintain consistency across the application.

Changes

File Change Summary
src/App.tsx Removed ThemeProvider, introduced ThemeModeProvider, updated component tree structure.
src/components/atoms/Loader.tsx Added useThemeMode import, updated StyledParagraph to accept darkMode prop, modified styles accordingly.
src/components/atoms/RecorderIcon.tsx Changed SVG fill attribute from "white" to "black".
src/components/atoms/buttons/buttons.tsx Updated NavBarButton to accept mode prop for light/dark styling, removed previous hover/active states.
src/components/atoms/canvas.tsx Increased <canvas> height from 400 to 1000.
src/components/molecules/ActionDescriptionBox.tsx Added isDarkMode prop, updated styles based on dark mode.
src/components/molecules/ActionSettings.tsx Introduced optional darkMode prop, updated styles accordingly.
src/components/molecules/BrowserNavBar.tsx Added useThemeMode, updated StyledNavBar and created IconButton for theme-based styling.
src/components/molecules/BrowserRecordingSave.tsx Adjusted inline styles for layout improvements.
src/components/molecules/BrowserTabs.tsx Added useThemeMode, updated styles based on dark mode, enhanced tab styling.
src/components/molecules/IntegrationSettings.tsx Replaced js-cookie library with custom cookie handling functions.
src/components/molecules/InterpretationLog.tsx Added useThemeMode for theme-based styling adjustments.
src/components/molecules/NavBar.tsx Introduced useThemeMode, refactored rendering logic, updated styles based on theme.
src/components/molecules/RunContent.tsx Modified tab styles for improved visual feedback based on theme.
src/components/molecules/SaveRecording.tsx Updated button variant to "contained" and enhanced confirmation flow for saving recordings.
src/components/organisms/BrowserContent.tsx Updated styles for layout improvements.
src/components/organisms/BrowserWindow.tsx Set height for main <div> and child components to 400px.
src/components/organisms/MainMenu.tsx Utilized useTheme for dynamic styling based on theme mode.
src/components/organisms/ProxyForm.tsx Added custom styled components for tabs, updated styles based on theme.
src/components/organisms/RightSidePanel.tsx Integrated useThemeMode for theme-based styling adjustments.
src/context/theme-provider.tsx Introduced theme management context with lightTheme and darkTheme, created ThemeModeProvider.
src/index.css Added empty rules for future styles.
src/pages/Login.tsx Added { withCredentials: true } to axios.post for cookie handling.
src/pages/RecordingPage.tsx Integrated useThemeMode to conditionally set document body background.
src/pages/Register.tsx Added console log for successful registration response.
src/pages/PageWrapper.tsx Added conditional rendering of NavBar based on browserId, wrapped RecordingPage in BrowserDimensionsProvider.

Poem

🐰 In the land of code where themes do play,
A rabbit hops, brightening the day.
With dark and light, we dance and twirl,
Making interfaces that shine and swirl.
So let us cheer for the changes made,
In our coding burrow, let joy cascade! 🌈


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 15

🧹 Outside diff range and nitpick comments (25)
src/components/molecules/RunContent.tsx (1)

78-121: Refactor tab styling to improve maintainability and consistency

While the dark theme implementation looks good, there are a few improvements that could enhance maintainability:

  1. Use theme tokens instead of hardcoded colors
  2. Extract duplicate tab styles to reduce code duplication
  3. Consider adding smooth transitions for hover effects

Here's a suggested refactor:

 <Tabs 
   value={tab} 
   onChange={(e, newTab) => setTab(newTab)} 
   aria-label="run-content-tabs"
   sx={{
     '& .MuiTabs-indicator': {
-      backgroundColor: '#FF00C3',
+      backgroundColor: theme => theme.palette.primary.main,
     },
     '& .MuiTab-root': {
       '&.Mui-selected': {
-        color: '#FF00C3',
+        color: theme => theme.palette.primary.main,
       },
     }
   }}
 >
+  {[
+    { label: "Output Data", value: 'output' },
+    { label: "Log", value: 'log' }
+  ].map(({ label, value }) => (
     <Tab 
-      label="Output Data" 
-      value='output' 
+      key={value}
+      label={label} 
+      value={value}
       sx={{
         color: (theme) => theme.palette.mode === 'dark' ? '#fff' : '#000',
         '&:hover': {
-          color: '#FF00C3'
+          color: theme => theme.palette.primary.main,
+          transition: theme => theme.transitions.create('color'),
         },
         '&.Mui-selected': {
-          color: '#FF00C3',
+          color: theme => theme.palette.primary.main,
         }
       }} 
     />
+  ))}
-  <Tab 
-    label="Log" 
-    value='log' 
-    sx={{...}}  // Removed duplicate styling
-  />
src/components/molecules/InterpretationLog.tsx (1)

127-129: Consider using theme tokens for colors and removing empty line

A few suggestions to improve the styling:

  1. Replace the hard-coded color #ff00c3 with a theme token for better maintainability and theme consistency
  2. Remove the empty line in the styling object (line 129)
 sx={{
   borderRadius: ' 0 0 10px 10px',
-           
   color: 'white',
   position: 'absolute',
-  background: '#ff00c3',
+  background: theme.palette.primary.main,
   border: 'none',
   padding: '10px 20px',
   width: '900px',
   overflow: 'hidden',
   textAlign: 'left',
   justifyContent: 'flex-start',
   '&:hover': {
-    backgroundColor: '#ff00c3',
+    backgroundColor: theme.palette.primary.dark,
   },
 }}
src/components/organisms/BrowserContent.tsx (3)

143-143: Move inline styles to styled component

Consider moving the inline styles to the BrowserContentWrapper styled component for better maintainability and consistency with the project's styling approach.

-<div id="browser" style={{ display: "flex", flexDirection: "column" }}  >
+<div id="browser">

Then add to BrowserContentWrapper:

 const BrowserContentWrapper = styled.div`
   position: relative;
   width: 100vw;
   height: 100vh;
   overflow: hidden;
+  display: flex;
+  flex-direction: column;
 `;

163-167: Consider theme-aware styling and mobile viewport handling

Two suggestions for improvement:

  1. Since this PR implements dark theme support, consider adding theme-aware styling:
-const BrowserContentWrapper = styled.div`
+const BrowserContentWrapper = styled.div<{ theme: Theme }>`
   position: relative;
   width: 100vw;
   height: 100vh;
   overflow: hidden;
+  background-color: ${({ theme }) => theme.palette.background.default};
+  color: ${({ theme }) => theme.palette.text.primary};
 `;
  1. The use of 100vh can cause issues on mobile browsers due to dynamic viewport height behavior with toolbars. Consider using alternative approaches:
 const BrowserContentWrapper = styled.div`
   position: relative;
   width: 100vw;
-  height: 100vh;
+  height: 100%;
+  min-height: 100vh;
+  min-height: 100dvh; /* dynamic viewport height */
   overflow: hidden;
 `;

Theme implementation needs attention in browser components

The verification reveals several components that need theme-related updates:

  • BrowserWindow uses inline styles without theme integration
  • BrowserTabs imports useThemeMode but doesn't appear to use it for styling
  • BrowserContent uses basic styling without theme consideration

Specific locations requiring theme implementation:

  • BrowserWindow's container div and modal styles should use theme colors
  • BrowserTabs should implement theme-aware styled components
  • BrowserContent's container should use theme-aware styling for consistent dark mode support
🔗 Analysis chain

Line range hint 18-161: Verify theme implementation completeness

Given that this PR implements dark theme support, we should verify if this component needs additional theme-related changes for child components.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if BrowserNavBar and BrowserWindow components implement theme support
ast-grep --pattern 'const $_ = styled.$_`
  $$$
  ${({ theme }) => $$$}
  $$$
`' src/components/molecules/BrowserNavBar.tsx src/components/organisms/BrowserWindow.tsx

# Check for useTheme or useThemeMode hook usage
rg -l "useTheme|useThemeMode" src/components/molecules/BrowserNavBar.tsx src/components/organisms/BrowserWindow.tsx

Length of output: 329


Script:

#!/bin/bash
# Let's check the actual implementation of BrowserNavBar and BrowserWindow
# to see their theme-related code

# Check BrowserNavBar implementation
rg -A 5 "useTheme|theme" src/components/molecules/BrowserNavBar.tsx

# Check BrowserWindow styled components and theme usage
rg -A 5 "styled\.|theme" src/components/organisms/BrowserWindow.tsx

# Check if there are any theme-related styles in BrowserTabs
rg -A 5 "styled\.|theme" src/components/molecules/BrowserTabs.tsx

Length of output: 800


Script:

#!/bin/bash
# Let's check the styled components in BrowserTabs and their theme implementation
rg -A 10 "styled\." src/components/molecules/BrowserTabs.tsx

# Check if BrowserWindow has any styling that might need theme support
rg -A 10 "styled\.|className|style" src/components/organisms/BrowserWindow.tsx

# Check if there are any color-related styles in the BrowserContent itself
rg -A 5 "background|color|border|style=" src/components/organisms/BrowserContent.tsx

Length of output: 3144

src/components/molecules/BrowserTabs.tsx (3)

126-138: Adjust CloseButton styles to adapt to theme mode

The CloseButton component uses hardcoded colors that may not align with the current theme. Adjust the backgroundColor and hover styles based on isDarkMode for consistent theming.

Apply this diff to make the CloseButton styles adapt to the theme mode:

          sx={{
            height: '28px',
            width: '28px',
            padding: '4px',
-           backgroundColor: '#3A3A3A', // Synced dark gray background
+           backgroundColor: `${isDarkMode ? '#3A3A3A' : '#FFFFFF'}`, // Adjust background color based on theme
            borderRadius: '50%',
            '&:hover': {
-             backgroundColor: '#505050', // Synced hover color for close button
-             color: '#FFFFFF',
+             backgroundColor: `${isDarkMode ? '#505050' : '#F0F0F0'}`, // Adjust hover background color
+             color: `${isDarkMode ? '#FFFFFF' : '#000000'}`, // Adjust hover text color
            },
            '&.Mui-disabled': {
              opacity: 0.4, // Lower opacity for disabled state
            },
            transition: 'background-color 0.3s ease, color 0.3s ease',
          }}

42-42: Consider making width responsive

Setting a fixed width can impact responsiveness. Use relative units like percentages to ensure the component adjusts to different screen sizes.

Apply this diff to make the width responsive:

-         width: '900px', // Fixed width
+         width: '100%', // Make width responsive

97-108: Remove commented-out code

There is a block of commented-out code related to the IconButton. Remove unused code to keep the codebase clean and maintainable.

src/components/molecules/NavBar.tsx (1)

215-225: Adjust discardButton styles to adapt to theme mode

The discardButton styles use hardcoded colors that might not provide optimal contrast in dark mode. Adjust the background and color properties based on darkMode for better visibility and theme consistency.

Modify the discardButton style to be a function that accepts darkMode:

-     discardButton: {
+     discardButton: (darkMode: boolean) => ({
        borderRadius: '5px',
        padding: '8px',
-       background: 'red',
+       background: darkMode ? '#ff4d4d' : 'red',
        color: 'white',
        marginRight: '10px',
        '&:hover': { 
          color: 'white', 
          backgroundColor: '#ff0000' 
        }
-     }
+     }),

Update the usage in the component:

<IconButton 
  onClick={goToMainMenu} 
- sx={styles.discardButton}
+ sx={styles.discardButton(darkMode)}
>
src/App.tsx (1)

3-3: Remove unused import createTheme

The createTheme import is no longer used after removing ThemeProvider. Remove unused imports to clean up the code.

Apply this diff to remove the unused import:

-import {  createTheme } from "@mui/material/styles";
src/context/theme-provider.tsx (1)

5-75: Consider extracting theme configuration to separate files

The light and dark theme configurations contain duplicated values and could benefit from better organization.

Consider:

  1. Extract shared values to a common configuration:
// src/theme/constants.ts
export const THEME_COLORS = {
  primary: '#ff00c3',
  primaryHover: '#e600b3',
}
  1. Create separate files for light and dark themes:
// src/theme/lightTheme.ts
import { THEME_COLORS } from './constants';
export const lightTheme = createTheme({...})
src/components/molecules/ActionSettings.tsx (1)

9-9: Consider using theme context instead of prop drilling

The component could directly use the theme context instead of receiving darkMode as a prop.

- interface ActionSettingsProps {
-   action: string;
-   darkMode?: boolean;
- }
+ interface ActionSettingsProps {
+   action: string;
+ }

- export const ActionSettings = ({ action, darkMode = false }: ActionSettingsProps) => {
+ export const ActionSettings = ({ action }: ActionSettingsProps) => {
+   const { darkMode } = useThemeMode();

Also applies to: 12-12

src/components/molecules/BrowserRecordingSave.tsx (1)

Line range hint 14-22: Add error handling for stopRecording

The navigation function doesn't properly handle API errors.

  const goToMainMenu = async () => {
    if (browserId) {
+     try {
        await stopRecording(browserId);
        notify('warning', 'Current Recording was terminated');
        setBrowserId(null);
+     } catch (error) {
+       console.error('Failed to stop recording:', error);
+       notify('error', 'Failed to stop recording');
+       return;
+     }
    }
    navigate('/');
  };
src/pages/Login.tsx (1)

Line range hint 63-71: Implement dark theme support

The login form uses a hard-coded white background color which doesn't align with the dark theme implementation. Consider using theme-aware colors:

 sx={{
   textAlign: "center",
-  backgroundColor: "#ffffff",
+  backgroundColor: theme.palette.background.paper,
   padding: 6,
   borderRadius: 5,
-  boxShadow: "0px 20px 40px rgba(0, 0, 0, 0.2), 0px -5px 10px rgba(0, 0, 0, 0.15)",
+  boxShadow: theme.shadows[4],
   display: "flex",
   flexDirection: "column",
   alignItems: "center",
   maxWidth: 400,
   width: "100%",
 }}

Don't forget to import and use the useTheme hook:

+import { useTheme } from "@mui/material/styles";

 const Login = () => {
+  const theme = useTheme();
   // ... rest of the component
src/components/organisms/MainMenu.tsx (2)

25-27: Centralize theme color constants

Consider moving the color constants to a theme configuration file for better maintainability:

-  const defaultcolor = theme.palette.mode === 'light' ? 'black' : 'white';
-  const selectedPink = '#FF00C3';
+  const defaultcolor = theme.palette.text.primary;
+  const selectedPink = theme.palette.primary.main;

Create a theme configuration file (e.g., src/theme/index.ts) to define these colors:

export const themeConfig = {
  palette: {
    primary: {
      main: '#FF00C3',
    },
    // ... other theme configurations
  },
};

46-69: Extract tab styles to a separate styled component

The inline styles for tabs are quite lengthy. Consider extracting them to a styled component for better maintainability:

const StyledTabs = styled(Tabs)(({ theme }) => ({
  alignItems: 'flex-start',
  '& .MuiTab-root': {
    color: theme.palette.text.primary,
    textTransform: 'none',
    fontSize: 'medium',
    justifyContent: 'flex-start',
    textAlign: 'left',
    '&.Mui-selected': {
      color: theme.palette.primary.main,
    },
    '& .MuiTabs-indicator': {
      backgroundColor: theme.palette.primary.main,
    },
  },
}));

Then use it in your component:

-<Tabs
+<StyledTabs
   value={value}
   onChange={handleChange}
   orientation="vertical"
   TabIndicatorProps={{
     style: {
-      backgroundColor: '#ff00c3',
+      backgroundColor: theme.palette.primary.main,
       width: '2px',
       right: 0,
     },
   }}
-  sx={{...}}
/>
src/components/molecules/BrowserNavBar.tsx (3)

16-26: Consider using MUI's styling system for consistency

The component mixes styled-components with Material-UI. Consider using MUI's styling system for consistency:

import { styled } from '@mui/material/styles';

const StyledNavBar = styled('div')<{ browserWidth: number }>(
  ({ theme, browserWidth }) => ({
    display: 'flex',
    alignItems: 'center',
    padding: '10px 20px',
    backgroundColor: theme.palette.background.paper,
    width: `${browserWidth}px`,
    borderRadius: '0px 0px 8px 8px',
    boxShadow: theme.shadows[1],
    transition: theme.transitions.create(['background-color', 'box-shadow']),
    marginBottom: '15px',
  })
);

28-46: Extract IconButton component to a separate file

The IconButton component has significant styling logic. Consider moving it to a separate file:

// src/components/atoms/buttons/IconButton.tsx
import { styled } from '@mui/material/styles';
import { NavBarButton } from './buttons';

export const IconButton = styled(NavBarButton)(({ theme }) => ({
  display: 'flex',
  alignItems: 'center',
  justifyContent: 'center',
  padding: '8px',
  marginRight: '12px',
  backgroundColor: theme.palette.mode === 'dark' ? '#40444B' : '#E0E0E0',
  borderRadius: '50%',
  transition: theme.transitions.create(['background-color', 'transform']),
  color: theme.palette.text.primary,
  cursor: 'pointer',

  '&:hover': {
    backgroundColor: theme.palette.mode === 'dark' ? '#586069' : '#D0D0D0',
  },

  '&:active': {
    transform: 'scale(0.95)',
  },
}));

106-140: Extract navigation buttons into a separate component

The repeated button pattern could be extracted into a reusable component:

interface NavButtonProps {
  onClick: () => void;
  icon: React.ReactNode;
  mode: string;
}

const NavigationButton: React.FC<NavButtonProps> = ({ onClick, icon, mode }) => (
  <IconButton
    type="button"
    onClick={onClick}
    disabled={false}
    mode={mode}
  >
    {icon}
  </IconButton>
);

Usage:

<NavigationButton
  onClick={() => socket?.emit('input:back')}
  icon={<ArrowBackIcon />}
  mode={isDarkMode ? 'dark' : 'light'}
/>
src/components/molecules/ActionDescriptionBox.tsx (1)

97-104: Simplify checkbox styling using theme tokens

The checkbox styling can be simplified by using MUI's theme tokens instead of conditional colors.

Consider this implementation:

- sx={{
-   color: isDarkMode ? 'white' : 'default',
-   '&.Mui-checked': {
-     color: isDarkMode ? '#90caf9' : '#1976d2',
-   },
- }}
+ sx={(theme) => ({
+   color: theme.palette.text.primary,
+   '&.Mui-checked': {
+     color: theme.palette.primary.main,
+   },
+ })}
src/components/molecules/IntegrationSettings.tsx (1)

Line range hint 307-322: Consider extracting theme-specific styles to a theme configuration.

While the dark mode implementation works, the hardcoded colors could be moved to a theme configuration for better maintainability.

Consider creating a theme configuration:

const themeColors = {
  dark: {
    alertBg: '#3b002d',
    alertBorder: '#ff00c3',
    text: 'white'
  },
  light: {
    alertBg: '#ffc4f1',
    alertBorder: '#ff00c3',
    text: 'black'
  }
};
src/components/organisms/ProxyForm.tsx (1)

Accessibility concerns identified in dark mode color contrasts

The code reveals potential WCAG contrast issues:

  • The pink accent color (#ff00c3) is used consistently across both light and dark modes without adjustment
  • Alert component in dark mode uses a very dark purple background (#3b002d) with white text
  • Tab indicators and hover states use the same pink (#FF69B4) regardless of theme

To ensure better accessibility:

  • Consider using a lighter shade of pink for dark mode to maintain sufficient contrast
  • Validate the contrast ratio between the dark purple background (#3b002d) and white text
  • Ensure the pink accent colors meet a minimum contrast ratio of 4.5:1 for normal text and 3:1 for large text
🔗 Analysis chain

Line range hint 300-322: Consider improving accessibility for dark mode.

While the color scheme is visually appealing, ensure all interactive elements meet WCAG contrast requirements in both themes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for potential accessibility issues in theme-related styles
ast-grep --pattern 'style={{ color:' # Find inline color styles
ast-grep --pattern 'sx={{ color:' # Find MUI sx color props

Length of output: 74


Script:

#!/bin/bash
# Search for color-related styles in the ProxyForm component with more context
rg -A 2 -B 2 "color:|backgroundColor:" "src/components/organisms/ProxyForm.tsx"

# Search for theme-related configurations
rg -A 5 "createTheme|ThemeProvider|useTheme|isDarkMode" "src/components/organisms/ProxyForm.tsx"

Length of output: 3773

src/components/organisms/RightSidePanel.tsx (2)

Line range hint 444-474: Consolidate repeated theme-specific styles.

Multiple components share similar theme-specific styling. Consider extracting these into a shared style configuration.

const commonStyles = {
  background: isDarkMode ? "#1E2124" : 'white',
  color: isDarkMode ? "white" : 'black'
};

415-415: Standardize button styling across the component.

Multiple buttons share the same styling properties. Consider creating a custom Button component with theme-aware styling.

const ThemedButton = styled(Button)(({ theme }) => ({
  backgroundColor: "#ff00c3",
  color: theme.darkMode ? 'white' : 'black'
}));

Also applies to: 482-482, 491-491

src/index.css (1)

14-14: Remove unnecessary empty lines

These empty lines within the CSS rules don't serve any purpose and should be removed for better code cleanliness.

body {
  scrollbar-gutter: stable;
  overflow-y: auto;
-
}

#browser-recorder {
  overflow: hidden;
  position: relative;
-
}

Also applies to: 47-47

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 600c36d and 587dacd.

📒 Files selected for processing (25)
  • src/App.tsx (1 hunks)
  • src/components/atoms/Loader.tsx (2 hunks)
  • src/components/atoms/RecorderIcon.tsx (1 hunks)
  • src/components/atoms/buttons/buttons.tsx (1 hunks)
  • src/components/atoms/canvas.tsx (1 hunks)
  • src/components/molecules/ActionDescriptionBox.tsx (6 hunks)
  • src/components/molecules/ActionSettings.tsx (3 hunks)
  • src/components/molecules/BrowserNavBar.tsx (5 hunks)
  • src/components/molecules/BrowserRecordingSave.tsx (1 hunks)
  • src/components/molecules/BrowserTabs.tsx (4 hunks)
  • src/components/molecules/IntegrationSettings.tsx (4 hunks)
  • src/components/molecules/InterpretationLog.tsx (4 hunks)
  • src/components/molecules/NavBar.tsx (2 hunks)
  • src/components/molecules/RunContent.tsx (2 hunks)
  • src/components/molecules/SaveRecording.tsx (1 hunks)
  • src/components/organisms/BrowserContent.tsx (3 hunks)
  • src/components/organisms/BrowserWindow.tsx (1 hunks)
  • src/components/organisms/MainMenu.tsx (3 hunks)
  • src/components/organisms/ProxyForm.tsx (4 hunks)
  • src/components/organisms/RightSidePanel.tsx (11 hunks)
  • src/context/theme-provider.tsx (1 hunks)
  • src/index.css (3 hunks)
  • src/pages/Login.tsx (1 hunks)
  • src/pages/RecordingPage.tsx (4 hunks)
  • src/pages/Register.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • src/components/atoms/RecorderIcon.tsx
  • src/pages/Register.tsx
  • src/components/atoms/canvas.tsx
  • src/components/organisms/BrowserWindow.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
src/index.css

[error] 60-62: An empty block isn't allowed.

Consider removing the empty block or adding styles inside it.

(lint/suspicious/noEmptyBlock)

🔇 Additional comments (6)
src/components/molecules/InterpretationLog.tsx (1)

20-20: LGTM: Theme hook integration looks good!

The integration of the useThemeMode hook is clean and follows React best practices.

Also applies to: 117-118

src/components/atoms/Loader.tsx (1)

Line range hint 10-35: LGTM!

The implementation correctly adapts the loader text color based on the theme mode.

src/pages/Login.tsx (1)

41-41: LGTM: Proper CORS configuration

The addition of withCredentials: true is correct for handling cross-origin authentication properly.

src/components/molecules/IntegrationSettings.tsx (1)

30-42: LGTM: Cookie management implementation is secure and well-typed.

The custom cookie management functions provide a good replacement for the js-cookie library. The implementation follows security best practices by using HttpOnly cookies and proper expiration handling.

src/components/organisms/ProxyForm.tsx (1)

26-45: LGTM: Well-structured custom tab components with proper theme integration.

The custom styled components provide consistent styling and good user experience with proper hover states and selection indicators.

src/index.css (1)

60-62: ⚠️ Potential issue

Add dark theme styles to the empty #browser selector

Given that this PR implements dark theme support, the empty #browser selector should include theme-specific styles. Consider adding background color, text color, and other relevant dark theme properties.

Let's verify the theme implementation in other files:

Example implementation:

#browser {
  background-color: var(--background-color);
  color: var(--text-color);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dark theme */
[data-theme="dark"] #browser {
  --background-color: #1a1a1a;
  --text-color: #ffffff;
}

/* Light theme */
[data-theme="light"] #browser {
  --background-color: #ffffff;
  --text-color: #000000;
}
🧰 Tools
🪛 Biome (1.9.4)

[error] 60-62: An empty block isn't allowed.

Consider removing the empty block or adding styles inside it.

(lint/suspicious/noEmptyBlock)

@@ -159,6 +199,7 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe
background: 'rgba(0,0,0,0.06)',
maxHeight: '300px',
overflow: 'scroll',
backgroundColor: '#19171c'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use theme-aware background color

The background color should adapt to the current theme mode instead of using a hardcoded dark color.

-  backgroundColor: '#19171c'
+  backgroundColor: theme => theme.palette.mode === 'dark' ? theme.palette.grey[900] : theme.palette.grey[100]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
backgroundColor: '#19171c'
backgroundColor: theme => theme.palette.mode === 'dark' ? theme.palette.grey[900] : theme.palette.grey[100]

Comment on lines +153 to +154
background: `${isDarkMode ? '#1e2124' : 'white'}`,
color: `${isDarkMode ? 'white' : 'black'}`,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider using MUI's theme system for better integration

Instead of directly using template literals for theme conditions, consider using MUI's theme system for better integration and maintainability:

 PaperProps={{
   sx: {
-    background: `${isDarkMode ? '#1e2124' : 'white'}`,
-    color: `${isDarkMode ? 'white' : 'black'}`,
+    bgcolor: 'background.paper',
+    color: 'text.primary',
     padding: '10px',
     height: 500,
     width: width - 10,

This approach:

  1. Uses MUI's theme tokens which automatically handle light/dark modes
  2. Provides better type safety
  3. Ensures consistency with MUI's theming system
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
background: `${isDarkMode ? '#1e2124' : 'white'}`,
color: `${isDarkMode ? 'white' : 'black'}`,
bgcolor: 'background.paper',
color: 'text.primary',

@@ -12,6 +12,7 @@ import {
} from "../../api/recording";
import { Box } from "@mui/material";
import { InterpretationLog } from "../molecules/InterpretationLog";
import { Height } from "@mui/icons-material";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove unused import Height

The Height icon from MUI is imported but never used in the component.

-import { Height } from "@mui/icons-material";

Comment on lines +66 to +74
backgroundColor: '#f5f5f5', // Synced dark background for tabs
borderRadius: '8px 8px 0px 0px',
marginRight: '8px',
minHeight: '48px',
textTransform: 'none',
fontWeight: '500',
fontSize: '14px',
color: 'black', // Synced light gray text color

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Adjust Tab styles to adapt to theme mode

The backgroundColor and color properties for the Tab component are hardcoded and do not change with the theme. To ensure consistent theming, adjust these properties based on isDarkMode.

Apply this diff to make the Tab styles adapt to the theme mode:

                  sx={{
-                     backgroundColor: '#f5f5f5', // Synced dark background for tabs
+                     backgroundColor: `${isDarkMode ? '#2a2a2a' : '#f5f5f5'}`, // Adjust background color based on theme
                      borderRadius: '8px 8px 0px 0px',
                      marginRight: '8px',
                      minHeight: '48px',
                      textTransform: 'none',
                      fontWeight: '500',
                      fontSize: '14px',
-                     color: 'black', // Synced light gray text color
+                     color: `${isDarkMode ? '#FFFFFF' : 'black'}`, // Adjust text color based on theme
                      
                      '&.Mui-selected': {
                        backgroundColor: `${isDarkMode ? '#2a2a2a' : '#f5f5f5'}`, // Synced selected tab color
                        color: '#ff00c3', // Slightly lighter text when selected
                      },
                    }}

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +6 to +19
export const NavBarButton = styled.button<{ disabled: boolean, mode: 'light' | 'dark' }>`
margin-left: 10px;
margin-right: 5px;
padding: 0;
border: none;
background-color: transparent;
background-color: ${mode => mode ? '#333' : '#ffffff'};
cursor: ${({ disabled }) => disabled ? 'default' : 'pointer'};
width: 24px;
height: 24px;
border-radius: 12px;
outline: none;
color: ${({ disabled }) => disabled ? '#999' : '#333'};
color: ${mode => mode ? '#ffffff' : '#333333'};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix style functions to correctly access the mode prop

In the styled component, the template literals should access the mode prop correctly. Currently, background-color: ${mode => mode ? ...} does not access the mode prop as intended.

Apply this diff to fix the issue:

 export const NavBarButton = styled.button<{ disabled: boolean, mode: 'light' | 'dark' }>`
     margin-left: 10px;
     margin-right: 5px;
     padding: 0;
     border: none;
-    background-color: ${mode => mode ? '#333' : '#ffffff'};
+    background-color: ${({ mode }) => mode === 'dark' ? '#333' : '#ffffff'};
     cursor: ${({ disabled }) => disabled ? 'default' : 'pointer'};
     width: 24px;
     height: 24px;
     border-radius: 12px;
     outline: none;
-    color: ${mode => mode ? '#ffffff' : '#333333'};
+    color: ${({ mode }) => mode === 'dark' ? '#ffffff' : '#333333'};
  
 `;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const NavBarButton = styled.button<{ disabled: boolean, mode: 'light' | 'dark' }>`
margin-left: 10px;
margin-right: 5px;
padding: 0;
border: none;
background-color: transparent;
background-color: ${mode => mode ? '#333' : '#ffffff'};
cursor: ${({ disabled }) => disabled ? 'default' : 'pointer'};
width: 24px;
height: 24px;
border-radius: 12px;
outline: none;
color: ${({ disabled }) => disabled ? '#999' : '#333'};
color: ${mode => mode ? '#ffffff' : '#333333'};
export const NavBarButton = styled.button<{ disabled: boolean, mode: 'light' | 'dark' }>`
margin-left: 10px;
margin-right: 5px;
padding: 0;
border: none;
background-color: ${({ mode }) => mode === 'dark' ? '#333' : '#ffffff'};
cursor: ${({ disabled }) => disabled ? 'default' : 'pointer'};
width: 24px;
height: 24px;
border-radius: 12px;
outline: none;
color: ${({ mode }) => mode === 'dark' ? '#ffffff' : '#333333'};

Comment on lines +7 to +10
interface CustomBoxContainerProps {
isDarkMode: boolean;
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider using MUI's theme system instead of prop drilling

The isDarkMode prop is being passed through multiple components when MUI's theme system could handle this more elegantly.

Consider using MUI's theme system:

interface CustomBoxContainerProps {
  theme: Theme;  // Use MUI's Theme type
}

Comment on lines +18 to +19
background-color: ${({ isDarkMode }) => (isDarkMode ? '#313438' : 'white')};
color: ${({ isDarkMode }) => (isDarkMode ? 'white' : 'black')};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use theme tokens instead of hardcoded colors

Hardcoded colors (#313438, white) should be replaced with theme tokens for better maintainability and consistency.

Consider this implementation:

- background-color: ${({ isDarkMode }) => (isDarkMode ? '#313438' : 'white')};
- color: ${({ isDarkMode }) => (isDarkMode ? 'white' : 'black')};
+ background-color: ${({ theme }) => theme.palette.background.paper};
+ color: ${({ theme }) => theme.palette.text.primary};

- border-bottom: 20px solid ${({ isDarkMode }) => (isDarkMode ? '#313438' : 'white')};
+ border-bottom: 20px solid ${({ theme }) => theme.palette.background.paper};

Also applies to: 33-33

Comment on lines +61 to +72
if (darkMode) {

document.body.style.background = 'rgba(18,18,18,1)';

} else {
document.body.style.background = 'radial-gradient(circle, rgba(255, 255, 255, 1) 0%, rgba(232, 191, 222, 1) 100%, rgba(255, 255, 255, 1) 100%)';
}

return () => {
// Cleanup the background when leaving the page
document.body.style.background = '';
document.body.style.filter = '';
};
}, []);
}, [darkMode]);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Avoid direct DOM manipulation for theming

Direct manipulation of document.body.style is not recommended for theming. This approach can lead to conflicts with other styles and doesn't leverage MUI's theme system.

Consider these alternatives:

  1. Use MUI's theme system with styled components:
const PageWrapper = styled('div')(({ theme }) => ({
  background: theme.palette.mode === 'dark' 
    ? theme.palette.background.default
    : 'radial-gradient(circle, rgba(255, 255, 255, 1) 0%, rgba(232, 191, 222, 1) 100%, rgba(255, 255, 255, 1) 100%)',
  minHeight: '100vh'
}));
  1. Or use CSS variables for dynamic theming:
// In your theme setup
document.documentElement.style.setProperty(
  '--page-background',
  theme.palette.mode === 'dark' 
    ? 'rgba(18,18,18,1)' 
    : 'radial-gradient(...)'
);

// In your styled component
const PageWrapper = styled('div')`
  background: var(--page-background);
  min-height: 100vh;
`;

@@ -159,4 +164,5 @@ const RecordingPageWrapper = styled.div`
width: 100vw;
height: 100vh;
overflow: hidden;

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add theme-aware background to RecordingPageWrapper

The styled RecordingPageWrapper component should include theme-aware background styling.

const RecordingPageWrapper = styled.div`
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
+ background: ${({ theme }) => theme.palette.background.default};
`;

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +394 to +409
<Paper
sx={{
borderRadius: '8px 8px 0px 0px', // Slightly more rounded corners for a smoother look
height: '520px',
width: 'auto',
alignItems: "center",
padding: '16px', // Add padding for spacing inside the component
background: isDarkMode
? 'linear-gradient(135deg, #1E2124 0%, #292C2F 100%)' // Subtle gradient for dark mode
: 'linear-gradient(135deg, #f5f5f5 0%, #ffffff 100%)', // Subtle gradient for light mode
color: isDarkMode ? '#E0E0E0' : '#333333', // Adjusted color for better contrast
// Smooth transition for shadows and background changes
}}
id="browser-actions"
elevation={0}
>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider using MUI's theme system for consistent styling.

The current implementation uses inline styles for theme-specific colors. Consider leveraging MUI's theme system for better maintainability and consistency.

Example implementation:

const theme = createTheme({
  palette: {
    mode: isDarkMode ? 'dark' : 'light',
    background: {
      paper: isDarkMode 
        ? 'linear-gradient(135deg, #1E2124 0%, #292C2F 100%)'
        : 'linear-gradient(135deg, #f5f5f5 0%, #ffffff 100%)'
    }
  }
});

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (6)
src/pages/PageWrappper.tsx (2)

15-15: Remove unused import

The AppBar component from @mui/material is imported but never used in the code.

-import { AppBar } from '@mui/material';

54-56: Consider simplifying the NavBar conditional rendering

The current conditional rendering can be simplified by moving the condition inside the NavBar component or using the logical AND operator.

-{!browserId && <NavBar recordingName={recordingName} isRecording={!!browserId} />}
+<NavBar 
+  recordingName={recordingName} 
+  isRecording={!!browserId} 
+  show={!browserId} 
+/>
src/components/molecules/NavBar.tsx (4)

101-108: Enhance iframe accessibility and performance

The GitHub button iframe could benefit from some improvements:

  1. Loading attribute for performance
  2. More descriptive title for accessibility
 <iframe 
   src="https://ghbtns.com/github-btn.html?user=getmaxun&repo=maxun&type=star&count=true&size=large" 
   frameBorder="0" 
   scrolling="0" 
   width="170" 
   height="30" 
-  title="GitHub"
+  title="GitHub Star Button for Maxun Repository"
+  loading="lazy"
 />

190-226: Consider moving styles to a separate file

The styles object is quite large and could be moved to a separate file for better maintainability.

Consider creating a new file NavBar.styles.ts:

// NavBar.styles.ts
export const styles = {
  socialButton: {...},
  userButton: (darkMode: boolean) => ({...}),
  discardButton: {...}
};

231-235: Consider using MUI's theme system for consistent styling

Instead of using styled-components with manual theme checks, consider leveraging MUI's theme system for better integration and consistency.

import { styled as muiStyled } from '@mui/material/styles';

const NavBarWrapper = muiStyled('div')(({ theme }) => ({
  gridArea: 'navbar',
  backgroundColor: theme.palette.background.paper,
  padding: theme.spacing(0.5),
  display: 'flex',
  justifyContent: 'space-between',
  borderBottom: `1px solid ${theme.palette.divider}`
}));

68-82: Consider component composition for better maintainability

The current approach of using render methods could be improved by breaking down into smaller components.

Consider creating separate components:

// components/NavBar/BrandSection.tsx
const BrandSection = () => {...}

// components/NavBar/SocialButtons.tsx
const SocialButtons = () => {...}

// components/NavBar/UserMenu.tsx
const UserMenu = () => {...}

// components/NavBar/ThemeToggle.tsx
const ThemeToggle = () => {...}

// components/NavBar/RecordingControls.tsx
const RecordingControls = () => {...}

This would improve:

  1. Code organization and maintainability
  2. Testing capabilities
  3. Potential for code reuse

Also applies to: 84-110, 112-139, 141-155, 157-168

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 587dacd and 655eadc.

📒 Files selected for processing (4)
  • src/components/molecules/NavBar.tsx (2 hunks)
  • src/pages/Login.tsx (3 hunks)
  • src/pages/PageWrappper.tsx (2 hunks)
  • src/pages/Register.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/pages/Login.tsx
  • src/pages/Register.tsx

const { state, dispatch } = useContext(AuthContext);
const { user } = state;
const navigate = useNavigate();

const { darkMode, toggleTheme } = useThemeMode();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider adding a theme persistence mechanism

The theme preference should persist across page reloads for better user experience.

Consider storing the theme preference in localStorage:

const { darkMode, toggleTheme } = useThemeMode();

useEffect(() => {
  localStorage.setItem('theme', darkMode ? 'dark' : 'light');
}, [darkMode]);

Comment on lines +218 to +224
background: 'red',
color: 'white',
marginRight: '10px',
'&:hover': {
color: 'white',
backgroundColor: '#ff0000'
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance error prevention UI

The discard button's styling suggests a destructive action. Consider adding a confirmation dialog before discarding.

const [showConfirmDialog, setShowConfirmDialog] = useState(false);

const handleDiscard = () => {
  setShowConfirmDialog(true);
};

// Add Dialog component
<Dialog
  open={showConfirmDialog}
  onClose={() => setShowConfirmDialog(false)}
>
  <DialogTitle>Confirm Discard</DialogTitle>
  <DialogContent>
    Are you sure you want to discard the current recording?
  </DialogContent>
  <DialogActions>
    <Button onClick={() => setShowConfirmDialog(false)}>Cancel</Button>
    <Button onClick={goToMainMenu} color="error">Discard</Button>
  </DialogActions>
</Dialog>

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (2)
src/components/molecules/NavBar.tsx (2)

101-108: Enhance GitHub button implementation

The GitHub iframe button might cause layout shifts and accessibility issues. Consider using the GitHub REST API to fetch the star count and implement a custom button component.

Example implementation:

const [starCount, setStarCount] = useState<number>(0);

useEffect(() => {
  fetch('https://api.github.com/repos/getmaxun/maxun')
    .then(res => res.json())
    .then(data => setStarCount(data.stargazers_count))
    .catch(console.error);
}, []);

// Replace iframe with custom button
<Button
  startIcon={<StarIcon />}
  href="https://github.com/getmaxun/maxun"
  target="_blank"
  rel="noopener noreferrer"
>
  Star ({starCount})
</Button>

141-155: Enhance theme toggle accessibility

The theme toggle button could benefit from additional accessibility features.

 const renderThemeToggle = () => (
   <Tooltip title="Toggle light/dark theme">
     <IconButton 
       onClick={toggleTheme} 
+      aria-label={`Switch to ${darkMode ? 'light' : 'dark'} theme`}
+      aria-pressed={darkMode}
       sx={{
         color: darkMode ? '#ffffff' : '#333333',
         '&:hover': {
           color: '#ff00c3'
         }
       }}
     >
       {darkMode ? <Brightness7 /> : <Brightness4 />}
     </IconButton>
   </Tooltip>
 );
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 655eadc and 9b667c9.

📒 Files selected for processing (4)
  • src/components/molecules/NavBar.tsx (2 hunks)
  • src/components/molecules/SaveRecording.tsx (1 hunks)
  • src/components/organisms/RightSidePanel.tsx (11 hunks)
  • src/pages/Register.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/components/organisms/RightSidePanel.tsx
  • src/pages/Register.tsx
  • src/components/molecules/SaveRecording.tsx
🔇 Additional comments (1)
src/components/molecules/NavBar.tsx (1)

40-40: Theme preference should persist across page reloads

The theme preference is not persisted across page reloads.

Comment on lines +193 to +229
// Styles
const styles = {
socialButton: {
display: 'flex',
alignItems: 'center',
borderRadius: '5px',
padding: '8px',
marginRight: '30px',
color: '#333333',
'&:hover': {
color: '#ff00c3'
}
},
userButton: (darkMode: boolean) => ({
display: 'flex',
alignItems: 'center',
borderRadius: '5px',
padding: '8px',
marginRight: '10px',
color: darkMode ? '#ffffff' : '#333333',
'&:hover': {
backgroundColor: darkMode ? '#333' : '#F5F5F5',
color: '#ff00c3'
}
}),
discardButton: {
borderRadius: '5px',
padding: '8px',
background: 'red',
color: 'white',
marginRight: '10px',
'&:hover': {
color: 'white',
backgroundColor: '#ff0000'
}
}
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Centralize theme configuration

Consider creating a central theme configuration to manage colors and other theme values. This will improve maintainability and consistency.

Example implementation:

// src/theme/constants.ts
export const themeColors = {
  light: {
    background: '#ffffff',
    text: '#333333',
    border: '#e0e0e0',
    hover: '#F5F5F5',
  },
  dark: {
    background: '#1e2124',
    text: '#ffffff',
    border: '#333',
    hover: '#333',
  },
  accent: {
    primary: '#ff00c3',
    error: '#ff0000',
  },
};

// Update styles to use theme constants
const styles = {
  userButton: (darkMode: boolean) => ({
    // ...other styles
    color: darkMode ? themeColors.dark.text : themeColors.light.text,
    '&:hover': { 
      backgroundColor: darkMode ? themeColors.dark.hover : themeColors.light.hover,
      color: themeColors.accent.primary
    }
  }),
};

import { AuthContext } from '../../context/auth';
import { SaveRecording } from '../molecules/SaveRecording';
import DiscordIcon from '../atoms/DiscordIcon';
import { apiUrl } from '../../apiConfig';
import MaxunLogo from "../../assets/maxunlogo.png";
import { useThemeMode } from '../../context/theme-provider';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Theme implementation needs improvement for consistent dark/light mode support

Several components have hardcoded color values that should be using theme tokens instead:

  • SaveRecording.tsx: Uses hardcoded #ff00c3 for button background
  • RunContent.tsx: Multiple instances of hardcoded #FF00C3 and background colors
  • BrowserTabs.tsx: Contains hardcoded background colors (#2A2A2A, #3A3A3A, etc.)
  • RecordingsTable.tsx: Uses hardcoded #ff00c3 for hover states
  • MainMenu.tsx: Contains hardcoded pink colors instead of theme values

While the theme provider is properly imported across components, the implementation is inconsistent. Some components correctly use the theme context with conditional dark/light mode values, while others use hardcoded colors that won't respond to theme changes.

🔗 Analysis chain

Verify theme consistency across components

Let's verify that the theme implementation is consistent across all components that import the theme provider.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for components using the theme provider
echo "Components using theme provider:"
rg -l "useThemeMode|ThemeModeProvider" "src/"

# Search for hardcoded color values that might need theme support
echo "\nPotential hardcoded colors that might need theme support:"
rg -n "'#[0-9a-fA-F]{3,6}'" "src/components/"

Length of output: 9261

@amhsirak amhsirak removed the Status: On Hold Work on this has been temporarily paused label Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: In Review This PR is being reviewed Type: Enhancement Improvements to existing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants