Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FoodWhizz
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Avanish Singh
FoodWhizz
Commits
69703a54
Unverified
Commit
69703a54
authored
1 year ago
by
Avanish Singh
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Add files via upload
parent
5398b5c8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend-react/src/components/MessageSection.js
+41
-35
41 additions, 35 deletions
frontend-react/src/components/MessageSection.js
frontend-react/src/components/TextMessage.js
+20
-0
20 additions, 0 deletions
frontend-react/src/components/TextMessage.js
with
61 additions
and
35 deletions
frontend-react/src/components/MessageSection.js
+
41
−
35
View file @
69703a54
import
React
,
{
useEffect
,
useRef
}
from
'
react
'
;
import
LeftMessage
from
"
./LeftMessage
"
;
import
RightMessage
from
"
./RightMessage
"
;
import
'
../styles/style.css
'
;
const
MessageArea
=
(
props
)
=>
{
const
End
=
useRef
(
null
)
useEffect
(()
=>
{
if
(
props
.
messages
.
length
>
0
)
{
scrollToBottom
();
}
})
function
scrollToBottom
()
{
End
.
current
.
scrollIntoView
({
behavior
:
"
smooth
"
})
}
return
(
<
div
className
=
{
props
.
area
}
>
{
props
.
messages
.
map
(
mes
=>
{
switch
(
mes
.
type
)
{
case
"
right
"
:
return
<
RightMessage
right_message
=
{
mes
}
/>
;
case
"
left
"
:
return
<
LeftMessage
left_message
=
{
mes
}
/>
;
}
})}
<
div
ref
=
{
End
}
><
/div
>
<
/div
>
);
};
export
default
MessageArea
;
\ No newline at end of file
import
React
,
{
useEffect
,
useRef
}
from
'
react
'
;
import
PropTypes
from
'
prop-types
'
;
import
TextMessage
from
"
./TextMessage
"
;
import
'
../styles/style.css
'
;
const
MessageSection
=
(
props
)
=>
{
const
{
area
,
messages
}
=
props
;
const
End
=
useRef
(
null
);
useEffect
(()
=>
{
if
(
messages
.
length
>
0
)
{
scrollToBottom
();
}
},
[
messages
]);
function
scrollToBottom
()
{
End
.
current
.
scrollIntoView
({
behavior
:
"
smooth
"
});
}
return
(
<
div
className
=
{
area
}
>
{
messages
.
map
((
mes
)
=>
(
<
TextMessage
key
=
{
mes
.
id
}
message
=
{
mes
}
side
=
{
mes
.
type
}
/>
))}
<
div
ref
=
{
End
}
><
/div>
<
/div>
);
};
MessageSection
.
propTypes
=
{
area
:
PropTypes
.
string
.
isRequired
,
messages
:
PropTypes
.
arrayOf
(
PropTypes
.
shape
({
id
:
PropTypes
.
number
.
isRequired
,
type
:
PropTypes
.
oneOf
([
'
left
'
,
'
right
'
]).
isRequired
,
// Add other message properties here
})
).
isRequired
,
};
export
default
MessageSection
;
This diff is collapsed.
Click to expand it.
frontend-react/src/components/TextMessage.js
0 → 100644
+
20
−
0
View file @
69703a54
import
React
from
'
react
'
;
import
'
../styles/style.css
'
;
import
Message
from
"
./Message
"
;
const
TextMessage
=
(
props
)
=>
{
const
{
message
,
side
}
=
props
;
const
messageClass
=
side
===
'
right
'
?
'
right_message
'
:
'
left_message
'
;
return
(
<
div
className
=
{
messageClass
}
>
<
div
className
=
{
`icon
${
side
}
`
}
><
/div>
<
div
className
=
{
`msg
${
side
}
`
}
>
<
Message
message
=
{
message
}
/>
<
/div>
<
/div>
);
};
export
default
TextMessage
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment