Finally fixed input
This commit is contained in:
parent
7e17e1c9e9
commit
0a1323da8a
@ -4,6 +4,7 @@ import React from 'react';
|
|||||||
import './chats.css'
|
import './chats.css'
|
||||||
import Chat from './Chat'
|
import Chat from './Chat'
|
||||||
import Contact from './Contact'
|
import Contact from './Contact'
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
class ChatWindow extends React.Component {
|
class ChatWindow extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
@ -11,15 +12,14 @@ class ChatWindow extends React.Component {
|
|||||||
<div class="chatcomponent">
|
<div class="chatcomponent">
|
||||||
<UserList />
|
<UserList />
|
||||||
<MessageList />
|
<MessageList />
|
||||||
|
<ChatInput />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
test() {
|
|
||||||
alert("test")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class UserList extends React.Component {
|
class UserList extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div class="contactlist">
|
<div class="contactlist">
|
||||||
@ -35,26 +35,10 @@ class MessageList extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div class="messagelist">
|
<div class="messagelist">
|
||||||
<div class="chatbubble-container">
|
<Chat message="Got time for tennis this week, Raiden?" side="right"/>
|
||||||
<div class="chatbubble right">
|
<Chat message="Foolish question. If I do not even have free time, How am I to pursue eternity and fulfill my promise to the people of Inazuma?" side="left" />
|
||||||
Got time for tennis this week, Raiden?
|
<Chat message="Aiight, see you at 4" side="right" />
|
||||||
</div>
|
<Chat message="As you wish." side="left" />
|
||||||
</div>
|
|
||||||
<div class="chatbubble-container">
|
|
||||||
<div class="chatbubble left">
|
|
||||||
Foolish question. If I do not even have free time, How am I to pursue eternity and fulfill my promise to the people of Inazuma?
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="chatbubble-container">
|
|
||||||
<div class="chatbubble right">
|
|
||||||
Aiight, see you at 4
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="chatbubble-container">
|
|
||||||
<div class="chatbubble left">
|
|
||||||
As you wish.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -69,9 +53,61 @@ class MessageList extends React.Component {
|
|||||||
// )
|
// )
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
class ChatInput extends React.Component {
|
const ChatInput = () => {
|
||||||
|
const [message, setMessage] = useState( '' );
|
||||||
|
|
||||||
|
// const onKeyPress = (e) => {
|
||||||
|
// // if(e.key === 'Enter'){
|
||||||
|
// // e.preventDefault(); // Ensure it is only this code that runs
|
||||||
|
// // setMessage("")
|
||||||
|
// // }
|
||||||
|
// }
|
||||||
|
|
||||||
|
const onKeyDown = (e) => {
|
||||||
|
const keyCode = e.which || e.keyCode;
|
||||||
|
|
||||||
|
// 13 represents the Enter key
|
||||||
|
if (keyCode === 13 && !e.shiftKey) {
|
||||||
|
e.preventDefault();
|
||||||
|
setMessage("")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
// onKeyPress={(e) => onKeyPress(e)}
|
||||||
|
<div>
|
||||||
|
<textarea
|
||||||
|
class="chatinput"
|
||||||
|
value={message}
|
||||||
|
placeholder="Press ENTER to send, SHIFT + ENTER for new line"
|
||||||
|
onChange={e => setMessage(e.target.value)}
|
||||||
|
|
||||||
|
onKeyDown={onKeyDown}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
class ChatInput2 extends React.Component {
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props)
|
||||||
|
this.setState({inputVal : ""})
|
||||||
|
}
|
||||||
|
|
||||||
|
handleUserInput(e) {
|
||||||
|
this.setState(this.setState({inputVal : e.target.value}));
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (<p>Placeholder</p>)
|
return (<textarea class="chatinput" placeholder="Press ENTER to send, Ctrl + ENTER for new line"
|
||||||
|
onKeyPress={(e)=>this.onKeyPress(e)} value="" onChange={(e) => this.handleUserInput(e)} />)
|
||||||
|
|
||||||
|
}
|
||||||
|
onKeyPress(e) {
|
||||||
|
if(e.key === 'Enter'){
|
||||||
|
e.preventDefault(); // Ensure it is only this code that runs
|
||||||
|
this.setState({inputVal : ""});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export default ChatWindow;
|
export default ChatWindow;
|
@ -11,13 +11,21 @@ class Contact extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
onClick() {
|
onClick() {
|
||||||
this.setState({selected : "true"})
|
// This toggling of the contact selection is for demo purposes only
|
||||||
|
// Once backend is implemented, only one contact can be selected
|
||||||
|
if (this.state.selected === "false") {
|
||||||
|
this.setState({selected : "true"})
|
||||||
|
} else {
|
||||||
|
this.setState({selected : "false"})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div class={this.state.selected === "true" ? "contact dark" : "contact"}>
|
<div class={this.state.selected === "true" ? "contact dark" : "contact"}>
|
||||||
<div class="profilepiccontainer">
|
<div class="profilepiccontainer">
|
||||||
<img src={this.props.pfpsrc} class="profilepic" onClick={() => this.onClick()} />
|
<img src={this.props.pfpsrc} class="profilepic" onClick={() => this.onClick()}
|
||||||
|
alt="profile" />
|
||||||
</div>
|
</div>
|
||||||
<div class="profilenamecontainer">
|
<div class="profilenamecontainer">
|
||||||
<div class="profilename" onClick={() => this.onClick()}>{this.props.name}</div>
|
<div class="profilename" onClick={() => this.onClick()}>{this.props.name}</div>
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* Please direct questions to Hansi Xu (Wallace LaWall on Discord) */
|
||||||
|
|
||||||
.chatcomponent > * {
|
.chatcomponent > * {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
@ -29,8 +31,12 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.messagelist {
|
.messagelist {
|
||||||
height: 500px;
|
height: 400px;
|
||||||
width: 800px;
|
width: 800px;
|
||||||
|
top: 0px;
|
||||||
|
left: 200px;
|
||||||
|
|
||||||
|
position: absolute;
|
||||||
background-color: rgb(80, 80, 80);
|
background-color: rgb(80, 80, 80);
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
@ -85,4 +91,18 @@
|
|||||||
width: 800px;
|
width: 800px;
|
||||||
height: auto;
|
height: auto;
|
||||||
float: left;
|
float: left;
|
||||||
|
}
|
||||||
|
.chatinput {
|
||||||
|
background-color: rgb(75, 75, 75);
|
||||||
|
top: 400px;
|
||||||
|
left: 200px;
|
||||||
|
position: absolute;
|
||||||
|
|
||||||
|
height: 92px;
|
||||||
|
width: 793px;
|
||||||
|
|
||||||
|
color: antiquewhite;
|
||||||
|
|
||||||
|
border-width: 2px;
|
||||||
|
border-color: rgb(48, 45, 45);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user