Merge branch 'features/darkTheme' into 'dev'
Features/darktheme See merge request sae-but2/2025-26/gestion-benevoles-association/Frontend!28
This commit is contained in:
commit
e1f6663382
4 files changed
+54
-13
No files matched your search
@@ -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;
|
||||||
@@ -20,8 +22,23 @@ const Background = ({ children, className }) => {
|
|||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
useEffect(() => {
|
||||||
<div className={`${styles["background-container"]} ${className || ''}`}>
|
const updateTheme = () => {
|
||||||
|
setTheme(localStorage.getItem("theme") || "light");
|
||||||
|
};
|
||||||
|
|
||||||
|
updateTheme(); // Initial load
|
||||||
|
|
||||||
|
window.addEventListener("theme-changed", updateTheme);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("theme-changed", updateTheme);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<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%;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,19 @@ function ProfilePage() {
|
|||||||
logout();
|
logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const switchTheme = () => {
|
||||||
|
|
||||||
|
const currentTheme = localStorage.getItem("theme");
|
||||||
|
let newTheme = currentTheme === "light" ? "dark" : "light";
|
||||||
|
|
||||||
|
if(currentTheme === null) newTheme = "dark";
|
||||||
|
|
||||||
|
localStorage.setItem("theme", newTheme);
|
||||||
|
|
||||||
|
window.dispatchEvent(new Event("theme-changed"));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
<div className={`${styles.profileboard} glassCard`}>
|
<div className={`${styles.profileboard} glassCard`}>
|
||||||
@@ -29,7 +42,10 @@ function ProfilePage() {
|
|||||||
<div className={styles.description}>
|
<div className={styles.description}>
|
||||||
<div className={styles.headerProfile}>
|
<div className={styles.headerProfile}>
|
||||||
<h2> {user.name} {user.lastname} </h2>
|
<h2> {user.name} {user.lastname} </h2>
|
||||||
<Button variant={"danger"} onClick={handleLogout}> Déconnexion </Button>
|
<div className={styles.settingsBtns}>
|
||||||
|
<Button variant={"default"} onClick={switchTheme}> Changer de thème </Button>
|
||||||
|
<Button variant={"danger"} onClick={handleLogout}> Déconnexion </Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.topDescription}>
|
<div className={styles.topDescription}>
|
||||||
<div className={styles.infoBlock}>
|
<div className={styles.infoBlock}>
|
||||||
|
|||||||
@@ -70,7 +70,13 @@
|
|||||||
}
|
}
|
||||||
.profilePicture{
|
.profilePicture{
|
||||||
width:90%;
|
width:90%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.settingsBtns {
|
||||||
|
display: flex;
|
||||||
|
gap: 5px;
|
||||||
|
justify-content: right;
|
||||||
|
}
|
||||||
|
|
||||||
@media screen and (min-width: 768px) {
|
@media screen and (min-width: 768px) {
|
||||||
.contentWrapper {
|
.contentWrapper {
|
||||||
|
|||||||
Reference in new issue
Block a user