This commit is contained in:
Mackie 2026-05-24 22:23:01 +08:00
parent a63ba979d4
commit 0aa214e3eb

View file

@ -1,6 +1,7 @@
"use client";
import { useEffect, useRef, useState } from "react";
import { useThemeMode } from '@/hooks/useThemeMode'
// REPLACE WITH:
import { useEffect, useRef } from "react";
const STAR_TONES = [255, 210, 160, 110, 65];
const WAVE_TONES = [55, 90, 125, 165, 205];
@ -125,15 +126,16 @@ export default function HeroBackground({
showToggle = true,
}: HeroBackgroundProps) {
const canvasRef = useRef<HTMLCanvasElement>(null);
const [internalDark, setInternalDark] = useState(true);
// REPLACE WITH:
const { isDark: hookDark, toggle } = useThemeMode();
// Use external control if provided, otherwise internal state
const isDark = externalIsDark !== undefined ? externalIsDark : internalDark;
// Use external control if provided, otherwise hook
const isDark = externalIsDark !== undefined ? externalIsDark : hookDark;
// REPLACE WITH:
function handleToggle() {
const next = !isDark;
setInternalDark(next);
onToggle?.(next);
toggle();
onToggle?.(!isDark);
}
useEffect(() => {