From e2d1677a2e3208109f4e9a168462d4ce00f63094 Mon Sep 17 00:00:00 2001 From: data Date: Sun, 14 Jul 2019 21:47:27 +0200 Subject: [PATCH 1/2] don't send empty messages --- src/components/Chat.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/Chat.js b/src/components/Chat.js index cd0add3..aefee80 100644 --- a/src/components/Chat.js +++ b/src/components/Chat.js @@ -52,6 +52,9 @@ class Chat extends React.Component { handleSubmit(e) { e.preventDefault() + if (this.state.text === '') { + return + } const message = { socketId: socket.id, id: uuid(), text: this.state.text } const messages = this.state.messages.concat(message) this.setState({ messages, text: '' }) From 37272986e024eadc5be5fe409e352fbd51bf1fab Mon Sep 17 00:00:00 2001 From: data Date: Sun, 14 Jul 2019 22:47:08 +0200 Subject: [PATCH 2/2] add times and display author on hover times --- public/css/custom.css | 9 +++++++++ public/index.html | 1 + src/components/SingleMessage.js | 27 +++++++++++++++++++-------- 3 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 public/css/custom.css diff --git a/public/css/custom.css b/public/css/custom.css new file mode 100644 index 0000000..713a6f6 --- /dev/null +++ b/public/css/custom.css @@ -0,0 +1,9 @@ +.avatar .username { + display: none; +} +.avatar:hover .username { + display: block; + position: absolute; + z-index: 1; + float: left; +} diff --git a/public/index.html b/public/index.html index 29939c5..0d5c4d5 100644 --- a/public/index.html +++ b/public/index.html @@ -7,6 +7,7 @@ + app diff --git a/src/components/SingleMessage.js b/src/components/SingleMessage.js index 4585cec..eef2304 100644 --- a/src/components/SingleMessage.js +++ b/src/components/SingleMessage.js @@ -5,18 +5,29 @@ const SingleMessage = props => { if (user.socketId === socketId) return ( - -
{text}
+ +
+ {text} +
00:00 AM | July 14
+
) return ( - - {user.socketId}: {text} +
+ + + {user.socketId} + +
+
+ {text} +
00:00 AM | July 14
+
) }