-
-
Notifications
You must be signed in to change notification settings - Fork 59
Added toggle button #96
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,22 +1,40 @@ | ||||||||||||||||||||||||||||||||
// App.js | ||||||||||||||||||||||||||||||||
import { useState } from "react"; | ||||||||||||||||||||||||||||||||
import { BrowserRouter, Routes, Route } from "react-router-dom"; | ||||||||||||||||||||||||||||||||
import { ThemeProvider } from "@mui/material"; | ||||||||||||||||||||||||||||||||
import EditorComponent from "./pages/EditorComponent"; | ||||||||||||||||||||||||||||||||
import theme from "./theme"; | ||||||||||||||||||||||||||||||||
import { lightTheme, darkTheme } from "./theme"; | ||||||||||||||||||||||||||||||||
import SnackbarProvider from "./components/js/SnackbarProvider"; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
function App() { | ||||||||||||||||||||||||||||||||
const [darkMode, setDarkMode] = useState(false); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
const toggleTheme = () => { | ||||||||||||||||||||||||||||||||
setDarkMode((prevMode) => !prevMode); | ||||||||||||||||||||||||||||||||
Comment on lines
+10
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The theme preference should be persisted in localStorage to maintain user preference across sessions, as mentioned in the PR description. Consider initializing the state from localStorage and updating it when the theme changes.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||||||||
<ThemeProvider theme={theme}> | ||||||||||||||||||||||||||||||||
<ThemeProvider theme={darkMode ? darkTheme : lightTheme}> | ||||||||||||||||||||||||||||||||
<SnackbarProvider> | ||||||||||||||||||||||||||||||||
<BrowserRouter> | ||||||||||||||||||||||||||||||||
<Routes> | ||||||||||||||||||||||||||||||||
<Route path="/" element={<EditorComponent />} /> | ||||||||||||||||||||||||||||||||
<Route path="/editor" element={<EditorComponent />} /> | ||||||||||||||||||||||||||||||||
<Route | ||||||||||||||||||||||||||||||||
path="/" | ||||||||||||||||||||||||||||||||
element={ | ||||||||||||||||||||||||||||||||
<EditorComponent darkMode={darkMode} toggleTheme={toggleTheme} /> | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||
<Route | ||||||||||||||||||||||||||||||||
path="/editor" | ||||||||||||||||||||||||||||||||
element={ | ||||||||||||||||||||||||||||||||
<EditorComponent darkMode={darkMode} toggleTheme={toggleTheme} /> | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||
</Routes> | ||||||||||||||||||||||||||||||||
</BrowserRouter> | ||||||||||||||||||||||||||||||||
</SnackbarProvider> | ||||||||||||||||||||||||||||||||
</ThemeProvider> | ||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
export default App | ||||||||||||||||||||||||||||||||
export default App; |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -14,8 +14,8 @@ | |||||
margin-left: 0.5rem; | ||||||
margin-right: 0.5rem; | ||||||
padding: 0.5rem; | ||||||
border: 3px solid rgba(0, 0, 0, 0.096); | ||||||
border-radius: 1rem; | ||||||
transition: background-color 0.3s ease; | ||||||
} | ||||||
|
||||||
.sidebar { | ||||||
|
@@ -32,15 +32,15 @@ | |||||
} | ||||||
|
||||||
.output { | ||||||
background-color: #d8dbcc; | ||||||
height: 22.3vh; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] The magic number '22.3vh' should be replaced with a named constant or CSS variable to improve maintainability and make the layout intention clearer.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
overflow-y: auto; | ||||||
padding: 1rem; | ||||||
margin: 0.5rem; | ||||||
border: 3px solid rgba(0, 0, 0, 0.096); | ||||||
border-radius: 1rem; | ||||||
transition: background-color 0.3s ease; | ||||||
} | ||||||
|
||||||
/* Responsive layout */ | ||||||
@media (min-width: 768px) { | ||||||
.layout { | ||||||
flex-direction: row; | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,15 @@ body { | |
margin: 0; | ||
font-family: 'Poppins'; | ||
} | ||
|
||
/* Light Mode */ | ||
.light-mode { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The CSS classes 'light-mode' and 'dark-mode' are defined but never applied to any elements in the codebase. Consider removing these unused styles or implementing their usage. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
background-color: #f9f9f9; | ||
color: #333; | ||
} | ||
|
||
/* Dark Mode */ | ||
.dark-mode { | ||
background-color: #333; | ||
color: #f9f9f9; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,54 @@ | ||
// theme.js | ||
import { createTheme } from "@mui/material/styles"; | ||
|
||
const theme = createTheme({ | ||
export const lightTheme = createTheme({ | ||
palette: { | ||
mode: "light", | ||
primary: { | ||
main: "#1976d2", | ||
}, | ||
secondary: { | ||
main: "#dc004e", | ||
}, | ||
background: { | ||
default: "#fff", | ||
paper: "#f5f5f5", | ||
}, | ||
text: { | ||
primary: "#000", | ||
secondary: "#555", | ||
}, | ||
}, | ||
typography: { | ||
h1: { | ||
fontSize: "2rem", | ||
}, | ||
fontFamily: [ | ||
"Poppins", | ||
], | ||
fontFamily: ["Poppins"], | ||
}, | ||
}); | ||
|
||
export default theme; | ||
export const darkTheme = createTheme({ | ||
palette: { | ||
mode: "dark", | ||
primary: { | ||
main: "#90caf9", | ||
}, | ||
secondary: { | ||
main: "#f48fb1", | ||
}, | ||
background: { | ||
default: "#121212", | ||
paper: "#1e1e1e", | ||
}, | ||
text: { | ||
primary: "#fff", | ||
secondary: "#aaa", | ||
}, | ||
}, | ||
typography: { | ||
h1: { | ||
fontSize: "2rem", | ||
}, | ||
fontFamily: ["Poppins"], | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the linebreak-style from 'unix' to 'windows' affects the entire team's development environment. This change should be coordinated with the team and may not be appropriate for a theme toggle feature.
Copilot uses AI. Check for mistakes.