Add dark theme

This commit is contained in:
T'JAMPENS QUENTIN p2406187 committed 2025-12-07 01:39:46 +01:00
1 parent 10ac3cecc0
commit 0188ac43bf
2 files changed
+16 -9

No files matched your search

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