ajout pop up pour changer de nom change de nom mais ne ferme pas apres le changement et changement de l'historique

This commit is contained in:
PrStein 2023-05-17 23:13:37 +02:00
parent 2f9f840b0c
commit 952ad35781
7 changed files with 120 additions and 29 deletions

View File

@ -1,10 +1,8 @@
import DefaultPic from '../assets/profile.jpg'; import DefaultPic from '../assets/profile.jpg';
export const UserProfile = [ export const UserProfile = {
{
Pic: DefaultPic, Pic: DefaultPic,
UserName: 'Dipper Ratman', UserName: 'Dipper Ratman',
}, }
]
// export default UserProfile // export default UserProfile

View File

@ -0,0 +1,52 @@
import {motion} from "framer-motion"
// import Backdrop from "./Sidebar/Backdrop"
import {Link} from 'react-router-dom';
import { UserProfile } from "../DataBase/DataUserProfile";
import {useState} from 'react';
import "../styles/Profile.css"
const dropIn = {
hidden: {
opacity: '0',
},
visible: {
opacity: "1",
},
exit: {
opacity: "0",
},
}
// const changeName = ({handleClose, name}) => {
// return (
// UserProfile.UserName = name
// )
// }
const ModalEdit = ({ handleClose }) => {
// let new_name = "";
const [username, setUserName] = useState("");
const handler = e =>
{
setUserName (e.target.value);
}
return (
// <Backdrop onClick={handleClose}>
<motion.div
className="modal"
variants={dropIn}
initial="hidden"
animate="visible"
exit="exit">
<h2>Type your new name</h2>
<input className="text" type="text" value={username} onChange={handler} handleClose/>
<div onClick={() => {UserProfile.UserName = username;}}>
<Link className="button">change</Link>
</div>
</motion.div>
// </Backdrop>
)
}
export default ModalEdit

View File

@ -4,11 +4,12 @@ import * as AiIcons from 'react-icons/ai';
import * as IoIcons from 'react-icons/io'; import * as IoIcons from 'react-icons/io';
import {BiLogOutCircle} from 'react-icons/bi'; import {BiLogOutCircle} from 'react-icons/bi';
import {IoSettingsSharp} from 'react-icons/io5' import {IoSettingsSharp} from 'react-icons/io5'
import {UserProfile} from '../../DataBase/DataUserProfile'
export const SidebarData = [ export const SidebarData = [
{ {
title: 'Dipper Ratman', title: UserProfile.UserName,
path: '/', path: '/',
icon: <AiIcons.AiFillHome />, icon: <AiIcons.AiFillHome />,
cName: 'nav-text' cName: 'nav-text'

View File

@ -6,10 +6,10 @@ import WinLoss from "../components/Win_Loss";
import { motion, AnimatePresence } from 'framer-motion' import { motion, AnimatePresence } from 'framer-motion'
import { AiFillEdit } from 'react-icons/ai' import { AiFillEdit } from 'react-icons/ai'
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import Modal from "../components/Sidebar/Modal"; import ModalEdit from "../components/EditName";
// import {AiOutlineHistory} from 'react-icons/ai' // import {AiOutlineHistory} from 'react-icons/ai'
// import { Link } from "react-router-dom"; // import { Link } from "react-router-dom";
// import UserProfile from "../DataBase/DataProfileUser"; import {UserProfile} from "../DataBase/DataUserProfile";
@ -20,17 +20,16 @@ function Profile () {
return ( return (
<div className="profile"> <div className="profile">
<img className="profile-pic" src={DefaultPicture} alt="Profile pic" /> <img className="profile-pic" src={DefaultPicture} alt="Profile pic" />
<h1>Dipper Ratman</h1> <h1>{UserProfile.UserName}</h1>
{/* <motion.div <motion.div onClick={() => (modalOpen ? close() : open())}>
> */} <Link to="#" className="edit_name">
<motion.button to="#" className="edit_name" onClick={() => (modalOpen ? close() : open())}>
<AiFillEdit/> <AiFillEdit/>
</motion.button> </Link>
{/* </motion.div> */} </motion.div>
<AnimatePresence <AnimatePresence
initial={false} initial={false}
onExitComplete={() => null}> onExitComplete={() => null}>
{modalOpen && <Modal modalOpen={modalOpen} handleClose={close}/>} {modalOpen && <ModalEdit modalOpen={modalOpen} handleClose={close}/>}
</AnimatePresence> </AnimatePresence>
</div> </div>
) )
@ -52,10 +51,12 @@ function Home () {
<WinLoss/> <WinLoss/>
</motion.div> </motion.div>
</div> </div>
<div> <motion.div
<button className="history" // {/* <button className="history" */}
onClick={ () => setmove(!move)}>Match History</button> // className="history"
</div> onClick={ () => setmove(!move)}>
<Link to="#" className="history">Match History</Link>
</motion.div>
</motion.div> </motion.div>
) )
} }

View File

@ -1,6 +1,7 @@
.App { .App {
text-align: center; text-align: center;
/* height: 100vh; */ height: 100%;
width: 100%;
background-color: black; background-color: black;
} }

View File

@ -41,6 +41,7 @@
/* justify-content: start; */ /* justify-content: start; */
align-items: center; align-items: center;
padding: 8px 0px 8px 16px; padding: 8px 0px 8px 16px;
list-style: none; list-style: none;
height: 60px; height: 60px;
} }
@ -53,8 +54,10 @@
height: 100%; height: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
padding: 0 16px; /* padding: 0 16px; */
border-radius: 4px; padding: 8px 8px 8px 8px;
border-radius: 20px;
} }
.nav-text a:hover { .nav-text a:hover {

View File

@ -18,6 +18,7 @@
/* margin-top: -100px; */ /* margin-top: -100px; */
/* display:inline-block; */ /* display:inline-block; */
/* flex-direction: column; */ /* flex-direction: column; */
/* position: absolute; */
background-color: black; background-color: black;
text-align: center; text-align: center;
@ -27,20 +28,54 @@
display: inline-block; display: inline-block;
color: white; color: white;
background-color: #5843e4; background-color: #5843e4;
border-radius: 4px; border-radius: 20px;
margin: 10px; padding: 16px;
/* padding: 8px 8px 8px 8px; */
font-size: 30px; font-size: 30px;
text-decoration: none; text-decoration: none;
margin-top: -400px; margin-top: -400px;
font-weight: bold;
} }
.edit_name { .edit_name {
margin-left: 2rem; margin-left: 2rem;
font-size: 2rem; font-size: 1.7rem;
background: none; background: #5843e4;
color:#f5f5f5 color:#f5f5f5;
margin: 0 16px;
text-decoration: none;
padding: 10px 16px;
border-radius: 20px;
}
.modal {
position:initial;
width: 400px;
height: 150px;
margin: auto;
padding: 0 2rem;
border-radius: 12px;
display: flex;
flex-direction: column;
align-items: center;
background-color: rgb(42, 41, 41);
}
.text {
background-color: black;
color: grey;
margin-bottom: 10px;
}
.button{
display: inline-block;
color: white;
background-color: #5843e4;
border-radius: 15px;
padding: 8px;
font-size: 20px;
text-decoration: none;
font-weight: bold;
} }
/* canvas { /* canvas {
margin-top: 20px; margin-top: 20px;