Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

making chat component and fix style issues relate to issue #7 #29

Merged
merged 6 commits into from
Aug 5, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions frontend/src/AppRoutes.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.AppRoutes {
text-align: center;
position: relative;
min-height: 667px;

}

#root {
font-family: arial;
/* margin: 0 auto; */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please delete unnecessary comments

max-width: 375px;
min-height: 600px;
background-color:#EEEEEE;

/* padding-bottom: 0px; */
}
52 changes: 35 additions & 17 deletions frontend/src/AppRoutes.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,45 @@
/* eslint-disable react/jsx-filename-extension */
import React from 'react';
import { BrowserRouter, Route, Switch } from 'react-router-dom';
import {BrowserRouter, Route, Switch} from 'react-router-dom'

import './AppRoutes.css';
import './style/style.css';

import Login from './components/Login/Login';
import Header from './components/Header';
import Chats from './components/Chats/Chats';
import Carers from './components/Carers/Carers';
import signUp from './components/singup/singup';
import Profile from './components/Profile/Profile';
import Diaries from './components/MyDiary/MyDiary';
import Discussion from './components/Discussions/Discussions';
import Connection from './components/Connections/Connections';
import './style/style.css';

import MyBook from './components/MyCarePlan/MyCarePlan';
import signUp from './components/singup/singup';
import Error from "./components/Error";
import NavElements from './components/Navbar/NavElement'

const AppRoutes = () => (

<div className="AppRoutes">
<BrowserRouter>

<Switch>
<Route path="/" component={Carers} exact />
<Route path="/login" component={Login} />
<Route path="/carers" component={Carers} />
<Route path="/signUp" component={signUp} />
<Route path="/MyFriends" component={Connection} />
</Switch>

</BrowserRouter>
<div>
<Header connectReq={['adsfa','sdfg']}/>
<Switch>
<Route path="/" component={Carers} exact />
<Route path="/login" component={Login} />
<Route path="/carers" component={Carers} />
<Route path="/profile" component={Profile} />
<Route path="/diaries" component={Diaries} />
<Route path="/discussion" component={Discussion} />
<Route path="/connection" component={Connection} />
<Route path="/mybook" component={MyBook} />
<Route path="/chats" component={Chats} />
<Route path="/signUp" component={signUp} />
<Route path="/MyFriends" component={Connection} />
<Route component={Error} />
</Switch>
<NavElements />
</div>
</BrowserRouter>
</div>
);


export default AppRoutes;
75 changes: 75 additions & 0 deletions frontend/src/components/Chats/Chats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import React, { Component } from 'react';
import FontAwesome from 'react-fontawesome';

import './styles.css';

class Chats extends React.PureComponent {

state = {
chat: ['hello', 'hi!', 'do you want to chat?']
}

saveMsg = (msg) => this.setState({
chat: [
...this.state.chat,
msg
]
})

render() {
return (
<section className="chat">
<div>
<header className="is-link is-bold">
<h1> Chat Page </h1>
</header>
</div>
<section className="chat section">
<div className="chats-body">
<Messages chat={this.state.chat} />
</div>
</section>
<div>
<footer className="is-small">
<Chat saveMsg={this.saveMsg} />
</footer>
</div>
</section>
)
}
}

const Chat = ({ saveMsg }) => (
<form className="messageFiled" onSubmit={(e) => {
e.preventDefault();
saveMsg(e.target.elements.userInput.value);
e.target.reset();
}}>
<div className="field has-addons">
<div className="control is-expanded">
<input className="input" name="userInput" type="text" placeholder="Type your message" />
</div>
<div className="control">
<button className="button is-info">
<FontAwesome name='send' /> Send
</button>
</div>
</div>
</form>

);

const Messages = ({ chat }) => (
<div style={{ heigth: '100%', width: '100%' }}>
{chat.map((m, i) => {
const msgClass = i === 0 || i % 2 === 0 // for demo purposes, format every other msg
return (
<p style={{ padding: '.25em', textAlign: msgClass ? 'left' : 'right', overflowWrap: 'normal' }}>
<span key={i} className={`tag is-medium ${msgClass ? 'is-success' : 'is-info'}`}>{m}</span>
</p>
)}
)}
</div>
);

export default Chats;
195 changes: 195 additions & 0 deletions frontend/src/components/Chats/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
.chat{
padding: 3rem 1.5rem;
box-sizing: inherit;
font-family: BlinkMacSystemFont, -apple-system, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", "Helvetica",
"Arial", sans-serif;
width: 302px;
text-align: center;
padding-left: 10px;
}

.chat h1{
color: #48a1af;
margin-left: 60px;
}

.chat p{
padding: 0.25em;
text-align: left;
overflow-wrap: normal;
}

.tag:not(body).is-medium {
font-size: 16px;
}

.tag:not(body).is-success {
background-color: #23d160;
color: #fff;
}

.tag:not(body) {
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
background-color: whitesmoke;
border-radius: 3px;
color: #4a4a4a;
display: -webkit-inline-box;
display: -ms-inline-flexbox;
display: inline-flex;
font-size: 0.75rem;
height: 2em;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
line-height: 1.5;
padding-left: 0.75em;
padding-right: 0.75em;
white-space: nowrap;
}

.chat span {
font-style: inherit;
font-weight: inherit;
}

.tag:not(body).is-info {
background-color: #209cee;
color: #fff;
}

.field.has-addons .control:first-child .input, .field.has-addons .control:first-child .select select {
border-bottom-right-radius: 0;
border-top-right-radius: 0;
}

.input, .textarea {
-moz-appearance: none;
-webkit-appearance: none;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
border: 1px solid transparent;
border-radius: 3px;
-webkit-box-shadow: none;
box-shadow: none;
display: -webkit-inline-box;
display: -ms-inline-flexbox;
display: inline-flex;
font-size: 1rem;
height: 2.25em;
-webkit-box-pack: start;
-ms-flex-pack: start;
justify-content: flex-start;
line-height: 1.5;
padding-bottom: calc(0.375em - 1px);
padding-left: calc(0.625em - 1px);
padding-right: calc(0.625em - 1px);
padding-top: calc(0.375em - 1px);
position: relative;
vertical-align: top;
background-color: white;
border-color: #dbdbdb;
color: #363636;
-webkit-box-shadow: inset 0 1px 2px rgba(10, 10, 10, 0.1);
box-shadow: inset 0 1px 2px rgba(10, 10, 10, 0.1);
max-width: 100%;
width: 100%;
}

.chat input, select, textarea {
font-family: BlinkMacSystemFont, -apple-system, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
margin: 0;
margin-left: 23px;
}

.button.is-info {
background-color: #209cee;
border-color: transparent;
color: #fff;
height: 45px;
width: 72px;
font-size: 17px;
}

.button {
-moz-appearance: none;
-webkit-appearance: none;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
border: 1px solid transparent;
border-radius: 3px;
-webkit-box-shadow: none;
box-shadow: none;
display: -webkit-inline-box;
display: -ms-inline-flexbox;
display: inline-flex;
font-size: 1rem;
height: 2.25em;
-webkit-box-pack: start;
-ms-flex-pack: start;
justify-content: flex-start;
line-height: 1.5;
padding-bottom: calc(0.375em - 1px);
padding-left: calc(0.625em - 1px);
padding-right: calc(0.625em - 1px);
padding-top: calc(0.375em - 1px);
position: relative;
vertical-align: top;
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-color: white;
border-color: #dbdbdb;
color: #363636;
cursor: pointer;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
padding-left: 0.75em;
padding-right: 0.75em;
text-align: center;
white-space: nowrap;
}

.chat button{
font-family: BlinkMacSystemFont, -apple-system, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
}

.chat footer{
display: block;
}

.chat input{
height: 45px;
font-size: 17px;
}

.field {
width: 328px;
display: flex;
flex-direction: row;
justify-content:center;
}

.messageFiled{
position: absolute;
bottom: 70px;
}

.is-expanded{
width: 100%;
}

.section{
overflow-y: scroll;
height: 340px;
margin-top: 20px;
margin-left: 25px;
background-color: #FAFAFA;
}
32 changes: 32 additions & 0 deletions frontend/src/components/Navbar/NavElement/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.navStyle{
/* padding-top: 545px; */
position: absolute;
bottom: 0;
width: 375px;
height: 55px;

}

.navStyle button{
cursor: pointer;
width: 62px;
height: 55px;
border: none;
background-color: #48A1AF;
padding: 5px;
}

.navStyle button img{
margin-top: 4px;
width: 60%;
height: 51%;
}

.navStyle button p{
margin-top: 4px;
font-size: 10px;
}

.active button {
background-color: #335e65;
}