-
Notifications
You must be signed in to change notification settings - Fork 83
CodeRabbit exercise task 2 #21
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: help-center-base
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
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,75 @@ | ||||||||||
| # CodeRabbit Configuration | ||||||||||
| language: en-US # Language for reviews | ||||||||||
|
|
||||||||||
| # Review settings | ||||||||||
| reviews: | ||||||||||
| profile: chill # Options: chill, assertive | ||||||||||
| high_level_summary: true | ||||||||||
| high_level_summary_placeholder: '@coderabbitai summary' | ||||||||||
| auto_title_placeholder: '@coderabbitai' | ||||||||||
| changed_files_summary: true | ||||||||||
| sequence_diagrams: true | ||||||||||
| assess_linked_issues: true | ||||||||||
| related_issues: true | ||||||||||
| related_prs: true | ||||||||||
| suggested_labels: true | ||||||||||
| suggested_reviewers: true | ||||||||||
| poem: true | ||||||||||
|
|
||||||||||
| # Path filters and instructions | ||||||||||
| path_filters: [] # Add glob patterns to include/exclude files | ||||||||||
| path_instructions: [] # Add path-specific review instructions | ||||||||||
|
|
||||||||||
| # Auto review settings | ||||||||||
| auto_review: | ||||||||||
| enabled: true | ||||||||||
| auto_incremental_review: true | ||||||||||
| drafts: false | ||||||||||
| base_branches: | ||||||||||
| - main | ||||||||||
| - help-center-base | ||||||||||
|
|
||||||||||
|
|
||||||||||
|
|
||||||||||
| # Tool integrations | ||||||||||
| tools: | ||||||||||
| # Common tools (all enabled by default) | ||||||||||
| ast-grep: | ||||||||||
| essential_rules: true | ||||||||||
| shellcheck: | ||||||||||
| enabled: true | ||||||||||
| ruff: | ||||||||||
| enabled: true | ||||||||||
| markdownlint: | ||||||||||
| enabled: true | ||||||||||
| biome: | ||||||||||
| enabled: true | ||||||||||
| eslint: | ||||||||||
| enabled: true | ||||||||||
| gitleaks: | ||||||||||
| enabled: true | ||||||||||
|
|
||||||||||
| # Chat settings | ||||||||||
| chat: | ||||||||||
| auto_reply: true | ||||||||||
| create_issues: true | ||||||||||
|
Comment on lines
+54
to
+55
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. Remove unsupported
chat:
auto_reply: true
- create_issues: true📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
| # Knowledge base settings | ||||||||||
| knowledge_base: | ||||||||||
| web_search: | ||||||||||
| enabled: true | ||||||||||
| learnings: | ||||||||||
| scope: auto | ||||||||||
| issues: | ||||||||||
| scope: auto | ||||||||||
| pull_requests: | ||||||||||
| scope: auto | ||||||||||
|
|
||||||||||
| # Code generation settings | ||||||||||
| code_generation: | ||||||||||
| docstrings: | ||||||||||
| path_instructions: | ||||||||||
| - path: "**/*.js" | ||||||||||
| instructions: | | ||||||||||
| End all docstrings with a notice that says "Auto-generated by CodeRabbit.". | ||||||||||
| Do not omit the closing tags; the docstring must be valid. | ||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,35 @@ | ||||||||||||||||||||||||||||||||||||||||||
| import React, { createContext, useState, useEffect, useContext } from 'react'; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const ThemeContext = createContext(); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| export const useTheme = () => useContext(ThemeContext); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| export const ThemeProvider = ({ children }) => { | ||||||||||||||||||||||||||||||||||||||||||
| const [theme, setTheme] = useState('light'); // Default theme | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||
| const storedTheme = localStorage.getItem('theme'); | ||||||||||||||||||||||||||||||||||||||||||
| if (storedTheme) { | ||||||||||||||||||||||||||||||||||||||||||
| setTheme(storedTheme); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| }, []); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||
| if (theme === 'dark') { | ||||||||||||||||||||||||||||||||||||||||||
| document.body.classList.add('dark-mode'); | ||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||
| document.body.classList.remove('dark-mode'); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| localStorage.setItem('theme', theme); | ||||||||||||||||||||||||||||||||||||||||||
| }, [theme]); | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+17
to
+24
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. 🛠️ Refactor suggestion Add error handling for localStorage operations. localStorage operations can fail (e.g., in private browsing mode) and should be wrapped in try-catch blocks. useEffect(() => {
if (theme === 'dark') {
document.body.classList.add('dark-mode');
} else {
document.body.classList.remove('dark-mode');
}
- localStorage.setItem('theme', theme);
+ try {
+ localStorage.setItem('theme', theme);
+ } catch (error) {
+ console.warn('Failed to save theme preference:', error);
+ }
}, [theme]);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const toggleTheme = () => { | ||||||||||||||||||||||||||||||||||||||||||
| setTheme((prevTheme) => (prevTheme === 'light' ? 'dark' : 'light')); | ||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||
| <ThemeContext.Provider value={{ theme, toggleTheme }}> | ||||||||||||||||||||||||||||||||||||||||||
| {children} | ||||||||||||||||||||||||||||||||||||||||||
| </ThemeContext.Provider> | ||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,17 @@ | ||
| import '../styles/globals.css'; | ||
| import { config } from '@fortawesome/fontawesome-svg-core'; | ||
| import '@fortawesome/fontawesome-svg-core/styles.css'; | ||
| import { ThemeProvider } from '../context/ThemeContext'; | ||
|
|
||
| // Prevent Font Awesome from adding its CSS since we did it manually above | ||
| config.autoAddCss = false; | ||
|
|
||
| function MyApp({ Component, pageProps }) { | ||
| return <Component {...pageProps} />; | ||
| return ( | ||
| <ThemeProvider> | ||
| <Component {...pageProps} /> | ||
| </ThemeProvider> | ||
| ); | ||
| } | ||
|
|
||
| export default MyApp; |
Uh oh!
There was an error while loading. Please reload this page.