From e35559ea20623b03402c5f2e1d62dc614340053e Mon Sep 17 00:00:00 2001 From: Simon Huang Date: Wed, 19 Aug 2020 21:48:37 -0400 Subject: [PATCH] add react player, ui styling (stacked to horizontal) --- package.json | 1 + src/components/Chat.css | 35 +++++++++++++++++++++++++++++------ src/components/Chat.tsx | 20 ++++++++++++-------- src/pages/Home.css | 8 ++++---- src/pages/Room.css | 14 ++++++++++++++ src/pages/Room.tsx | 20 ++++++++++++++++++-- 6 files changed, 78 insertions(+), 20 deletions(-) create mode 100644 src/pages/Room.css diff --git a/package.json b/package.json index 8b77245..27a4145 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "ionicons": "^5.0.0", "react": "^16.13.0", "react-dom": "^16.13.0", + "react-player": "^2.6.0", "react-router": "^5.1.2", "react-router-dom": "^5.1.2", "react-scripts": "3.4.1", diff --git a/src/components/Chat.css b/src/components/Chat.css index 2427fdf..b687c7a 100644 --- a/src/components/Chat.css +++ b/src/components/Chat.css @@ -1,28 +1,47 @@ ion-col { - padding: 10px; - border-radius: 10px; + padding: 6px; + border-radius: 5px; margin-bottom: 4px; white-space: pre-wrap; - max-width: 75%; + max-width: 70%; } ion-textarea { border: solid 1px #999; } +.chat-card { + height: 100%; + width: 100%; + float: right; + margin: 0; +} + .right-align { justify-content: flex-end; } +.message-card { + overflow-y: auto; + height: calc(100% - 125px); + padding: 0; +} + +.input-card { + position: absolute; + bottom: 0px; + width: 100%; + padding: 0; +} + .message-grid { - padding-left: calc(100vw - 100%); margin-right: 0; height: 100%; } .message-input { - margin-right: 0; - border: solid 1px #bbb; + margin: 0; + border-top: solid 1px #bbb; } .my-msg { @@ -45,3 +64,7 @@ ion-textarea { .send-button { width: 100%; } + +.text-area { + height: 100%; +} diff --git a/src/components/Chat.tsx b/src/components/Chat.tsx index c7f5d3b..2d23dd3 100644 --- a/src/components/Chat.tsx +++ b/src/components/Chat.tsx @@ -1,4 +1,4 @@ -import { IonButton, IonCol, IonContent, IonFooter, IonGrid, IonRow, IonTextarea } from '@ionic/react'; +import { IonButton, IonCard, IonCardContent, IonCol, IonGrid, IonRow, IonTextarea } from '@ionic/react'; import React, { useEffect, useState } from 'react'; import { currTime, db, timestamp } from '../services/firebase'; import './Chat.css'; @@ -80,8 +80,8 @@ const Chat: React.FC = ({ roomId, userId }) => { }; return ( - <> - + + {!loading ? ( chats.map((chat) => { @@ -98,12 +98,16 @@ const Chat: React.FC = ({ roomId, userId }) => { <> )} - - + + - setMessage(e.detail.value!)} value={message}> + setMessage(e.detail.value!)} + value={message} + class="textarea" + > @@ -112,8 +116,8 @@ const Chat: React.FC = ({ roomId, userId }) => { - - + + ); }; diff --git a/src/pages/Home.css b/src/pages/Home.css index 9b63eb1..0015ab1 100644 --- a/src/pages/Home.css +++ b/src/pages/Home.css @@ -5,10 +5,10 @@ width: 100%; } -ion-toolbar { - text-align: center; +.home-grid { + max-width: 500px; } -ion-grid { - max-width: 500px; +ion-toolbar { + text-align: center; } diff --git a/src/pages/Room.css b/src/pages/Room.css new file mode 100644 index 0000000..b7f8c37 --- /dev/null +++ b/src/pages/Room.css @@ -0,0 +1,14 @@ +.room-grid { + margin-inline-start: 0; + margin-inline-end: 0; + height: 100%; + padding: 0; +} + +.room-row { + height: 100%; +} + +.player-col { + height: 70%; +} diff --git a/src/pages/Room.tsx b/src/pages/Room.tsx index d1ee778..99e63df 100644 --- a/src/pages/Room.tsx +++ b/src/pages/Room.tsx @@ -1,9 +1,11 @@ -import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/react'; +import { IonCol, IonContent, IonGrid, IonHeader, IonPage, IonRow, IonTitle, IonToolbar } from '@ionic/react'; import React, { useEffect, useState } from 'react'; +import ReactPlayer from 'react-player'; import { RouteComponentProps, useHistory } from 'react-router'; import Chat from '../components/Chat'; import { auth, db, decrement, increment, rtdb } from '../services/firebase'; import { generateAnonName } from '../services/random'; +import './Room.css'; const Room: React.FC> = ({ match }) => { const history = useHistory(); @@ -132,7 +134,21 @@ const Room: React.FC> = ({ match }) => { {loading ? ( Loading... ) : ( - + + + + + + + + + + )} );