Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
chat-trans
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenway
chat-trans
Commits
10249bf7
Commit
10249bf7
authored
Aug 09, 2023
by
chenway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
db13cd15
Pipeline
#158737
failed with stage
in 42 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
160 deletions
+0
-160
Chatbox.js
src/Components/Chatbox.js
+0
-160
No files found.
src/Components/Chatbox.js
deleted
100644 → 0
View file @
db13cd15
import
React
from
"react"
;
// import ChatFeed from "react-chat-ui";/
import
{
ChatFeed
,
ChatBubble
,
BubbleGroup
,
Message
}
from
"react-chat-ui"
;
const
styles
=
{
button
:
{
backgroundColor
:
"#fff"
,
borderColor
:
"#1D2129"
,
borderStyle
:
"solid"
,
borderRadius
:
20
,
borderWidth
:
2
,
color
:
"#1D2129"
,
fontSize
:
18
,
fontWeight
:
"300"
,
paddingTop
:
8
,
paddingBottom
:
8
,
paddingLeft
:
16
,
paddingRight
:
16
,
outline
:
"none"
},
selected
:
{
color
:
"#fff"
,
backgroundColor
:
"#0084FF"
,
borderColor
:
"#0084FF"
}
};
const
users
=
{
0
:
"You"
,
Mark
:
"Mark"
,
2
:
"Evan"
};
const
customBubble
=
props
=>
(
<
div
>
<
p
>
{
`
${
props
.
message
.
senderName
}
${
props
.
message
.
id
?
"says"
:
"said"
}
:
${
props
.
message
.
message
}
`
}
<
/p
>
<
/div
>
);
class
Chat
extends
React
.
Component
{
constructor
()
{
super
();
this
.
state
=
{
messages
:
[
new
Message
({
id
:
"Mary"
,
message
:
"Hey guys!"
,
senderName
:
"Mary"
}),
new
Message
({
id
:
2
,
message
:
(
<
p
>
<
span
>
11
:
50
:
<
/span>Hey! Eve here. react-chat-ui is pretty dooope
.
<
/p
>
),
senderName
:
"Eve"
})
],
useCustomBubble
:
false
,
curr_user
:
0
};
}
onPress
(
user
)
{
this
.
setState
({
curr_user
:
user
});
}
onMessageSubmit
(
e
)
{
const
input
=
this
.
message
;
e
.
preventDefault
();
if
(
!
input
.
value
)
{
return
false
;
}
this
.
pushMessage
(
this
.
state
.
curr_user
,
input
.
value
);
input
.
value
=
""
;
return
true
;
}
pushMessage
(
recipient
,
message
)
{
const
prevState
=
this
.
state
;
const
newMessage
=
new
Message
({
id
:
recipient
,
message
,
senderName
:
users
[
recipient
]
});
prevState
.
messages
.
push
(
newMessage
);
this
.
setState
(
this
.
state
);
}
render
()
{
return
(
<
div
className
=
"container"
>
<
div
className
=
"chatfeed-wrapper"
>
<
ChatFeed
chatBubble
=
{
this
.
state
.
useCustomBubble
&&
customBubble
}
maxHeight
=
{
250
}
messages
=
{
this
.
state
.
messages
}
// Boolean: list of message objects
showSenderName
/>
<
form
onSubmit
=
{
e
=>
this
.
onMessageSubmit
(
e
)}
>
<
input
ref
=
{
m
=>
{
this
.
message
=
m
;
}}
placeholder
=
"Type a message..."
className
=
"message-input"
/>
<
/form
>
<
div
style
=
{{
display
:
"flex"
,
justifyContent
:
"space-around"
}}
>
<
button
style
=
{{
...
styles
.
button
,
...(
this
.
state
.
curr_user
===
0
?
styles
.
selected
:
{})
}}
onClick
=
{()
=>
this
.
onPress
(
0
)}
>
You
<
/button
>
<
button
style
=
{{
...
styles
.
button
,
...(
this
.
state
.
curr_user
===
"Mary"
?
styles
.
selected
:
{})
}}
onClick
=
{()
=>
this
.
onPress
(
"Mary"
)}
>
Mary
<
/button
>
<
button
style
=
{{
...
styles
.
button
,
...(
this
.
state
.
curr_user
===
2
?
styles
.
selected
:
{})
}}
onClick
=
{()
=>
this
.
onPress
(
2
)}
>
Eve
<
/button
>
<
/div
>
<
div
style
=
{{
display
:
"flex"
,
justifyContent
:
"center"
,
marginTop
:
10
}}
>
<
button
style
=
{{
...
styles
.
button
,
...(
this
.
state
.
useCustomBubble
?
styles
.
selected
:
{})
}}
onClick
=
{()
=>
this
.
setState
({
useCustomBubble
:
!
this
.
state
.
useCustomBubble
})
}
>
Custom
Bubbles
<
/button
>
<
/div
>
<
/div
>
<
/div
>
);
}
}
export
default
Chatbox
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment