diff --git a/src/components/background/background.jsx b/src/components/background/background.jsx index b77ce82..05ba976 100644 --- a/src/components/background/background.jsx +++ b/src/components/background/background.jsx @@ -1,8 +1,10 @@ import styles from "./background.module.css"; -import { useEffect, useRef } from "react"; +import { useEffect, useRef, useState } from "react"; const Background = ({ children, className }) => { - const circlesRef = useRef([]); + + const circlesRef = useRef([]); + const [theme, setTheme] = useState("light"); const getRandomTranslation = () => { const randomX = Math.floor(Math.random() * 100) - 30; @@ -11,6 +13,9 @@ const Background = ({ children, className }) => { }; useEffect(() => { + + setTheme(localStorage.getItem("theme") ? localStorage.getItem("theme") : "light"); + circlesRef.current.forEach((circle) => { if (circle) { const { x, y } = getRandomTranslation(); @@ -21,7 +26,7 @@ const Background = ({ children, className }) => { }, []); return ( -
+
(circlesRef.current[0] = el)} className={`${styles["circle"]} ${styles["circle-1"]}`} diff --git a/src/components/background/background.module.css b/src/components/background/background.module.css index e5cca18..c0e7211 100644 --- a/src/components/background/background.module.css +++ b/src/components/background/background.module.css @@ -1,10 +1,9 @@ /* BACKGROUND ////////////////////////////////////////////////////////*/ -.background-container { +.backgroundContainer { z-index: 0; margin: 0; padding: 0; min-height: 100vh; - background: #00F0FF; overflow: hidden; position: relative; width: 100vw; @@ -13,6 +12,14 @@ align-items: center; } +.backgroundLight { + background: #00F0FF; +} + +.backgroundDark { + background: #001C83; +} + .circle { position: absolute; border-radius: 50%; @@ -82,7 +89,6 @@ .circle-1 { width: 300px; height: 300px; - background-color: #019AFF; top: -5%; left: -5%; } @@ -90,7 +96,6 @@ .circle-2 { width: 175px; height: 175px; - background-color: #91FCFF; top: 58%; left: 10%; } @@ -98,7 +103,6 @@ .circle-3 { width: 140px; height: 140px; - background-color: #91FCFF; top: 29%; right: 9%; } @@ -106,7 +110,6 @@ .circle-4 { width: 250px; height: 250px; - background-color: #019AFF; bottom: 0; right: 0; } @@ -114,7 +117,6 @@ .circle-5 { width: 240px; height: 240px; - background-color: #015AFF; top: 2%; right: 10%; }