Skip to content

Conversation

@vaishnaviparabkar90
Copy link

@vaishnaviparabkar90 vaishnaviparabkar90 commented Oct 18, 2025

Closes #119

Screenshots/Videos

Screenshot (160) Screenshot (161)

Summary by CodeRabbit

  • Style

    • Particle effects now adapt to your theme preference: white particles in dark mode and black particles in light mode.
    • Removed manual color overrides so theme-driven particle coloring is consistent across views.
  • Refactor

    • Minor layout/formatting cleanup with no behavioral changes.

@coderabbitai
Copy link

coderabbitai bot commented Oct 18, 2025

Walkthrough

Adds theme-aware particle coloring: particles now receive a color determined by the current theme (dark → white, light → black) via a hook in components/ui/particles.tsx, and the hardcoded inline color was removed from components/sections/hero/index.tsx.

Changes

Cohort / File(s) Change Summary
Theme-aware particles
components/ui/particles.tsx
Imported useTheme from next-themes; added particleColor state and useEffect that sets color to white in dark mode and black otherwise; merged particleColor into the particle style before render.
Hero section cleanup
components/sections/hero/index.tsx
Removed the inline style/color prop previously passed to Particles; retained variant="default" and interactive={true} props. Minor formatting/indentation adjustment.

Sequence Diagram(s)

sequenceDiagram
    participant Browser
    participant ThemeProvider as next-themes
    participant Hero as HeroSection
    participant Part as ParticlesComponent

    Browser->>ThemeProvider: user sets theme (light/dark)
    ThemeProvider-->>Browser: current theme value
    Browser->>Hero: render HeroSection
    Hero->>Part: mount Particles (no hardcoded color)
    Part->>ThemeProvider: read theme via useTheme
    ThemeProvider-->>Part: theme ("dark" or "light")
    Part->>Part: set particleColor (white if dark, black if light)
    Part->>Part: apply particleColor to finalStyle
    Part-->>Browser: render particles with computed color
    Note right of Part: particleColor updates on theme change
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰
I tuned the stars to match the night,
White when dark, black when bright.
A tiny glow for every theme,
Now particles dance in both extremes. ✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description is largely incomplete compared to the repository's template requirements. It only includes a reference to the closed issue (#119) and two screenshots, but is missing critical sections such as a summary explaining what the PR accomplishes, the type of changes, testing completed, development setup verification, code quality checks, and other standard documentation. While the screenshots are helpful for UI-related changes, the textual explanation of the implementation and testing approach is absent. The PR description should be expanded to include a clear summary section explaining that the changes add theme awareness to the particles component so particles are visible in both light and dark modes. Additionally, the author should complete sections on testing (verifying particles display correctly in both themes), the type of change (bug fix), and code quality verification to match the repository's PR template expectations.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title "particles colour fix in black and white mode" is clear, concise, and directly addresses the main objective of the pull request. It accurately summarizes the primary change—implementing theme-aware particle coloring so particles are visible in both dark and light modes. The title is specific enough for a developer reviewing history to understand the core purpose of the changeset.
Linked Issues Check ✅ Passed The code changes directly address the requirements of issue #119. The modifications add theme awareness to the particles component through the useTheme hook from next-themes, dynamically updating the particle color based on dark/light theme, which enables particles to remain visible in both modes. The removal of the inline style prop from the hero component and the implementation of theme-based color logic align with the objective to make both the particle effects and background glow visible in light mode as they are in dark mode.
Out of Scope Changes Check ✅ Passed All code changes in this pull request are directly related to the objective of fixing particle visibility in light and dark modes. The modifications to components/ui/particles.tsx add theme awareness and dynamic color adjustment, while changes to components/sections/hero/index.tsx remove conflicting inline styles. No unrelated changes such as refactoring, performance optimizations, or feature additions unrelated to this bug fix are present.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between df189cc and 27791a5.

📒 Files selected for processing (1)
  • components/ui/particles.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/ui/particles.tsx

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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: 1

🧹 Nitpick comments (1)
components/ui/particles.tsx (1)

153-153: No current code passes color via the style prop to Particles. The verification found two component usages (in components/ui/sparkles.tsx and components/sections/hero/index.tsx), neither of which attempts to pass a style prop. However, the underlying API design concern remains valid: the component silently overrides any color in the style prop with particleColor, which could confuse future developers. Consider documenting this constraint in the component's JSDoc or TypeScript interface to make the API contract explicit.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6c1d72b and df189cc.

📒 Files selected for processing (2)
  • components/sections/hero/index.tsx (1 hunks)
  • components/ui/particles.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
components/sections/hero/index.tsx (1)
components/ui/particles.tsx (1)
  • Particles (125-257)
🔇 Additional comments (2)
components/ui/particles.tsx (1)

9-9: LGTM!

The import of useTheme from next-themes is correct and enables theme-aware particle colors.

components/sections/hero/index.tsx (1)

106-109: LGTM! Simplified usage by removing inline color styling.

The removal of the inline style prop is appropriate, as particle color is now controlled centrally within the Particles component based on the active theme. This simplifies usage and ensures consistent theme-aware behavior.

Comment on lines 132 to 141
const [isInitialized, setIsInitialized] = useState(false);
const { theme } = useTheme();
const [particleColor, setParticleColor] = useState("#000000");
useEffect(() => {
if (theme === "dark") {
setParticleColor("#FFFFFF"); // white for dark mode
} else {
setParticleColor("#000000"); // black for light mode
}
}, [theme]);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Use resolvedTheme and check mounted to handle system theme and prevent hydration issues.

The current implementation has two issues:

  1. System theme not handled: When theme === "system", the code falls through to the else branch and sets particles to black, even if the user's OS is in dark mode. You should use resolvedTheme instead, which returns the actual active theme ("dark" or "light") regardless of whether the user selected "system".

  2. Hydration mismatch risk: The theme is not available during SSR, which can cause the initial server-rendered output to differ from the client-rendered output, triggering React hydration warnings. You should check the mounted flag before rendering theme-dependent content.

Based on learnings.

Apply this diff to fix both issues:

-  const [isInitialized, setIsInitialized] = useState(false);
-  const { theme } = useTheme();
-const [particleColor, setParticleColor] = useState("#000000");
-useEffect(() => {
-  if (theme === "dark") {
-    setParticleColor("#FFFFFF"); // white for dark mode
-  } else {
-    setParticleColor("#000000"); // black for light mode
-  }
-}, [theme]);
+  const [isInitialized, setIsInitialized] = useState(false);
+  const { resolvedTheme, theme } = useTheme();
+  const [particleColor, setParticleColor] = useState("#000000");
+  
+  useEffect(() => {
+    const activeTheme = resolvedTheme || theme;
+    if (activeTheme === "dark") {
+      setParticleColor("#FFFFFF"); // white for dark mode
+    } else {
+      setParticleColor("#000000"); // black for light mode
+    }
+  }, [resolvedTheme, theme]);
📝 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
const [isInitialized, setIsInitialized] = useState(false);
const { theme } = useTheme();
const [particleColor, setParticleColor] = useState("#000000");
useEffect(() => {
if (theme === "dark") {
setParticleColor("#FFFFFF"); // white for dark mode
} else {
setParticleColor("#000000"); // black for light mode
}
}, [theme]);
const [isInitialized, setIsInitialized] = useState(false);
const { resolvedTheme, theme } = useTheme();
const [particleColor, setParticleColor] = useState("#000000");
useEffect(() => {
const activeTheme = resolvedTheme || theme;
if (activeTheme === "dark") {
setParticleColor("#FFFFFF"); // white for dark mode
} else {
setParticleColor("#000000"); // black for light mode
}
}, [resolvedTheme, theme]);
🤖 Prompt for AI Agents
In components/ui/particles.tsx around lines 132 to 141, the theme-dependent
particle color uses theme and runs during SSR which causes both incorrect
behavior for "system" theme and potential hydration mismatches; change to read
resolvedTheme from useTheme (which returns "dark" or "light" for system) and
guard the effect/render with a mounted check (or use the mounted flag from
useTheme) so you only derive and set particleColor on the client after mounted
is true and use resolvedTheme === "dark" to set white otherwise black.

@jayanthjamin-web
Copy link
Contributor

@vaishnaviparabkar90 we will review it please wait

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: The particles in the background are not visible in the light mode as well as the background glow

2 participants