Skip to content

Commit

Permalink
Improve chat avatar placement (#1741)
Browse files Browse the repository at this point in the history
resolves #1740

Co-authored-by: Fred Lefévère-Laoide <[email protected]>
  • Loading branch information
FredLL-Avaiga and Fred Lefévère-Laoide authored Sep 3, 2024
1 parent 6d81980 commit 3806a58
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions frontend/taipy-gui/src/components/Taipy/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Avatar from "@mui/material/Avatar";
import Box from "@mui/material/Box";
import Button from "@mui/material/Button";
import Chip from "@mui/material/Chip";
import Grid from "@mui/material/Grid";
import Grid from "@mui/material/Grid2";
import IconButton from "@mui/material/IconButton";
import InputAdornment from "@mui/material/InputAdornment";
import Paper from "@mui/material/Paper";
Expand Down Expand Up @@ -65,7 +65,7 @@ const senderMsgSx = {
const gridSx = { pb: "1em", mt: "unset", flex: 1, overflow: "auto" };
const loadMoreSx = { width: "fit-content", marginLeft: "auto", marginRight: "auto" };
const inputSx = { maxWidth: "unset" };
const nameSx = { fontSize: "0.6em", fontWeight: "bolder" };
const nameSx = { fontSize: "0.6em", fontWeight: "bolder", pl: `${indicWidth}em` };
const senderPaperSx = {
pr: `${indicWidth}em`,
pl: `${indicWidth}em`,
Expand Down Expand Up @@ -134,22 +134,21 @@ const ChatRow = (props: ChatRowProps) => {
const avatar = getAvatar(name, sender);
return (
<Grid
item
container
className={getSuffixedClassNames(className, sender ? "-sent" : "-received")}
xs={12}
size={12}
sx={noAnchorSx}
justifyContent={sender ? "flex-end" : undefined}
>
<Grid item sx={sender ? senderMsgSx : undefined}>
<Grid sx={sender ? senderMsgSx : undefined}>
{avatar ? (
<Stack>
<Stack direction="row" gap={1}>
<Box sx={avatarColSx}></Box>
<Box sx={avatarColSx}>{avatar}</Box>
<Box sx={nameSx}>{name}</Box>
</Stack>
<Stack direction="row" gap={1}>
<Box sx={avatarColSx}>{avatar}</Box>
<Box sx={avatarColSx}></Box>
<Paper sx={sender ? senderPaperSx : otherPaperSx} data-idx={index}>
{message}
</Paper>
Expand Down Expand Up @@ -352,7 +351,7 @@ const Chat = (props: ChatProps) => {
<Paper className={className} sx={boxSx} id={id}>
<Grid container rowSpacing={2} sx={gridSx} ref={scrollDivRef}>
{rows.length && !rows[0] ? (
<Grid item className={getSuffixedClassNames(className, "-load")} xs={12} sx={noAnchorSx}>
<Grid className={getSuffixedClassNames(className, "-load")} size={12} sx={noAnchorSx}>
<Box sx={loadMoreSx}>
<Button
endIcon={<ArrowUpward />}
Expand Down

0 comments on commit 3806a58

Please sign in to comment.