Skip to content

Commit 94c18a8

Browse files
committed
improve indentation settings and display
1 parent 97d9685 commit 94c18a8

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

src/components/Chat/ChatContent.tsx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Markdown, MarkdownProps } from "./../../cmem/markdown/Markdown";
77
import { DepictionProps } from "./../Depiction/Depiction";
88
import { FlexibleLayoutContainer, FlexibleLayoutItem } from "./../FlexibleLayout";
99
import { Spacing } from "./../Separation/Spacing";
10-
import { HtmlContentBlock, OverflowTextProps, WhiteSpaceContainer } from "./../Typography";
10+
import { HtmlContentBlock, OverflowTextProps } from "./../Typography";
1111

1212
export interface ChatContentProps extends React.HTMLAttributes<HTMLDivElement>, TestableComponent {
1313
/**
@@ -23,14 +23,14 @@ export interface ChatContentProps extends React.HTMLAttributes<HTMLDivElement>,
2323
*/
2424
avatar?: React.ReactElement<DepictionProps>;
2525
/**
26-
* If indented then the content box has some white space on one side.
26+
* If indented then the content box has some white space on the opposite side to the alignment
2727
*/
28-
indentation?: boolean;
28+
indentationSize?: "small" | "medium" | "large";
2929
/**
3030
* How the content box and avatar is aligned.
3131
* If `left` is set then the avatar is on the left side, and the indentation on the right side.
3232
*/
33-
alignment?: "left" | "right" | "block";
33+
alignment?: "left" | "right";
3434
/**
3535
* If set then the chat bubble only grows to a height of 50% of the viewport.
3636
* In case you need to set other maximum heights then use the `style` property directly.
@@ -52,7 +52,7 @@ export const ChatContent = ({
5252
statusLine,
5353
avatar,
5454
displayType = "bubble",
55-
indentation = true,
55+
indentationSize,
5656
alignment = "left",
5757
limitHeight,
5858
markdownProps,
@@ -83,10 +83,18 @@ export const ChatContent = ({
8383
</div>
8484
);
8585

86+
const indentationSizes = {
87+
small: "8%",
88+
medium: "21%",
89+
large: "34%",
90+
};
91+
8692
return (
87-
<WhiteSpaceContainer
88-
marginLeft={alignment === "right" && indentation ? "xlarge" : undefined}
89-
marginRight={alignment === "left" && indentation ? "xlarge" : undefined}
93+
<div
94+
style={{
95+
marginLeft: alignment === "right" && indentationSize ? indentationSizes[indentationSize] : undefined,
96+
marginRight: alignment === "left" && indentationSize ? indentationSizes[indentationSize] : undefined,
97+
}}
9098
>
9199
{avatar ? (
92100
<FlexibleLayoutContainer noEqualItemSpace gapSize="tiny">
@@ -102,7 +110,7 @@ export const ChatContent = ({
102110
) : (
103111
content
104112
)}
105-
</WhiteSpaceContainer>
113+
</div>
106114
);
107115
};
108116

0 commit comments

Comments
 (0)