From 71ab9d2b01456f4fa60c400425a41905fb1733d2 Mon Sep 17 00:00:00 2001 From: Little Dipper Date: Sat, 10 Jun 2023 22:30:06 +0200 Subject: [PATCH] ajout cote message --- .../src/components/Messages/AddSelectTag.jsx | 37 ++++++ .../react/src/components/Messages/Chats.jsx | 27 +++-- .../react/src/components/Messages/Modal.jsx | 107 ++++++++++++++++++ containers/react/src/styles/Messages.css | 51 ++++++++- 4 files changed, 213 insertions(+), 9 deletions(-) create mode 100644 containers/react/src/components/Messages/AddSelectTag.jsx create mode 100644 containers/react/src/components/Messages/Modal.jsx diff --git a/containers/react/src/components/Messages/AddSelectTag.jsx b/containers/react/src/components/Messages/AddSelectTag.jsx new file mode 100644 index 00000000..07f6c70e --- /dev/null +++ b/containers/react/src/components/Messages/AddSelectTag.jsx @@ -0,0 +1,37 @@ +import React, { useState } from "react"; +import { Rank } from "../../DataBase/DataRank"; + +const AddSelectTag = () => { + // const [selectCount, setSelectCount] = useState(0); + // const [selectValues, setSelectValues] = useState([]); + + // const handleAddSelect = () => { + // setSelectCount((selectCount) => selectCount + 1); + // setSelectCount((selectValues) =>[...selectValues, `select${selectCount + 1}`] ); + // }; + + return ( +
+ {/* +
+ {selectValues.map((selectName, index) => ( + + ))} +
*/} + */} + + ) + })} + +
+ ) +} + +export default AddSelectTag; \ No newline at end of file diff --git a/containers/react/src/components/Messages/Chats.jsx b/containers/react/src/components/Messages/Chats.jsx index f703df2e..10cf2e10 100644 --- a/containers/react/src/components/Messages/Chats.jsx +++ b/containers/react/src/components/Messages/Chats.jsx @@ -4,6 +4,8 @@ import '../../styles/Messages.css' import styled from "styled-components"; import DefaultPic from '../../assets/profile.jpg' import api from '../../script/axiosApi'; +import { motion } from "framer-motion"; +import Modal from "./Modal"; import Message from "./Message" // import Input from "./Input"; @@ -214,6 +216,10 @@ function Chats(){ } } + const [modalOpen, setModalOpen] = useState(false); + const close = () => setModalOpen(false); + const open = () => setModalOpen(true); + // console.log(`data user1= ${user.username}`) // while (user === null) @@ -265,13 +271,20 @@ function Chats(){
-
- - New Message -
+ (modalOpen ? close() : open())} + + > + + New Conversation + + {modalOpen && } +
- {conversations.map(c=> ( -
setCurrentChat(c)}> + {conversations.map((c, index ) => { + return ( +
setCurrentChat(c)}> User
@@ -281,7 +294,7 @@ function Chats(){
- ))} + )})}
{ diff --git a/containers/react/src/components/Messages/Modal.jsx b/containers/react/src/components/Messages/Modal.jsx new file mode 100644 index 00000000..02293aa9 --- /dev/null +++ b/containers/react/src/components/Messages/Modal.jsx @@ -0,0 +1,107 @@ +import { motion } from "framer-motion"; +import Backdrop from "../Sidebar/Backdrop"; +import { Rank } from "../../DataBase/DataRank" +import '../../styles/Messages.css' +import { useState } from "react"; +import { GrAdd } from "react-icons/gr"; +import { Link } from "react-router-dom"; +import AddSelectTag from "./AddSelectTag"; + +const dropIn = { + hidden:{y:"-100vh", + opacity: 0,}, + visible:{y: "0", + opacity: 0, + transotion:{ + duration:0.1, + type:"spring", + damping: 100, + stiffness: 500, + }}, + exit:{y: "100vh", + opacity: 0,}, + +}; + +const Modal = ({handleClose, text}) => { + const [multi, setMulti] = useState(false); + // const addButton = document.getElementById('addButton'); + // const selectContainer = document.getElementById('selectContainer'); + // let selectCount = 0; + // function addSelectTag(){ + // selectCount++; + // const select = document.createElement('select'); + // select.name = `select${selectCount}`; + + // const opt1 = document.createElement('option'); + // opt1.value = 'opt1'; + // opt1.text = 'opt1'; + + // const opt2 = document.createElement('option'); + // opt2.value = 'opt2'; + // opt2.text = 'opt2'; + + // select.appendChild(opt1); + // select.appendChild(opt2); + + // selectContainer.appendChild(select); + // } + function try_me() + { + + for (let i = 0; i < 2; i++) + { + AddSelectTag(); + } + } + return ( + + e.stopPropagation()} + className="modal" + variant={dropIn} + initial="hidden" + animate="visible" + exit="exit" + > +

New Convewrstion

+ +{/* First selection */} + + + +{/* Second selection */} + + */} + + ) + })} + + {/* */} + {/* addButton.addEventListener('click', addSelectTag); */} +
(try_me())}> + {multi === true ? : " "} +
+
+ Submit + + Cancel +
+ +
+
+ ) +} + +export default Modal \ No newline at end of file diff --git a/containers/react/src/styles/Messages.css b/containers/react/src/styles/Messages.css index f62c2860..ecc0bd30 100644 --- a/containers/react/src/styles/Messages.css +++ b/containers/react/src/styles/Messages.css @@ -1,12 +1,39 @@ .home{ background-color: black; - height: 10vh; + height: 90vh; display: flex; align-items: center; justify-content: center; } +select{ + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + background: black; + color: white; + box-shadow: none; + appearance: none; + outline: 0; + border: 0!important; + margin: 5px; + font-size: 18px; + border-radius: 6px; +} + +.modal{ + width: clamp(50%, 700px, 90%); + height: min(50%, 300px); + + margin: auto; + padding: 2rem; + border-radius: 12px; + display: flex; + flex-direction: column; + align-items: center; +} + .scroll{ overflow: scroll; } @@ -61,9 +88,11 @@ .navbar{ display: flex; align-items: center; - background-color: #000c66; + /* background-color: yellow; */ + background-image: linear-gradient(90deg, #5843e4, #5a0760); color: white; padding: 3px; + border-radius: 10px 10px 0px 0px; } .pic{ @@ -143,4 +172,22 @@ input{ flex-direction: row-reverse; padding: 20px; color: lightgrey; +} + +.submit{ + display: inline-block; + color: white; + background-color: #5843e4; + border-radius: 10px; + padding: 5px; + font-size: 1.2rem; + text-decoration: none; + font-weight:lighter; +} + +.div_submit { + flex-direction: row; + align-items: center; + /* margin-left: 4px; + margin-right: 4px; */ } \ No newline at end of file