@@ -4,11 +4,11 @@ import { TestableComponent } from "../../components/interfaces";
44import { CLASSPREFIX as eccgui } from "../../configuration/constants" ;
55
66import { Markdown , MarkdownProps } from "./../../cmem/markdown/Markdown" ;
7+ import { ContextMenuProps } from "./../ContextOverlay/ContextMenu" ;
78import { DepictionProps } from "./../Depiction/Depiction" ;
89import { FlexibleLayoutContainer , FlexibleLayoutItem } from "./../FlexibleLayout" ;
9- import { IconButton } from "./../Icon/IconButton" ;
10+ import { IconButtonProps } from "./../Icon/IconButton" ;
1011import { Spacing } from "./../Separation/Spacing" ;
11- import { TextReducer } from "./../TextReducer/TextReducer" ;
1212import { HtmlContentBlock , OverflowTextProps } from "./../Typography" ;
1313
1414export interface ChatContentProps extends React . HTMLAttributes < HTMLDivElement > , TestableComponent {
@@ -44,27 +44,13 @@ export interface ChatContentProps extends React.HTMLAttributes<HTMLDivElement>,
4444 */
4545 markdownProps ?: Omit < MarkdownProps , "children" > ;
4646 /**
47- * Callback handler if content should be expanded.
48- * Button to shrink/expand is displayed, depending on `shrinked` value.
49- * If this handler is given then the component never will change the `shrinked` state automatically.
47+ * Could be used to add some type of toggle button or to include a context menu.
5048 */
51- onToggleSize ?: ( ) => void ;
52- /**
53- * Content should dislayed shrinked.
54- * Button to expand content is displayed.
55- * Component can reduce content automatically to one line if `autoShrink` is set to `true`.
56- * If `onToggleSize` handler is not given then `autoShrink=true` is inferred and size toggling is automatically provided.
57- */
58- shrinked ?: boolean ;
59- /**
60- * Children elements are automatically shrinked to one line.
61- * If `shrinked` are not given then `shrinked=true` is infered.
62- */
63- autoShrink ?: boolean ;
49+ actionButton ?: React . ReactElement < IconButtonProps > | React . ReactElement < ContextMenuProps > ;
6450}
6551
6652/**
67- * Component to display singe chat contents, including avatar and status line.
53+ * Component to display single chat contents, including avatar and status line.
6854 */
6955export const ChatContent = ( {
7056 className,
@@ -76,23 +62,9 @@ export const ChatContent = ({
7662 alignment = "left" ,
7763 limitHeight,
7864 markdownProps,
79- shrinked,
80- autoShrink,
81- onToggleSize,
65+ actionButton,
8266 ...otherDivProps
8367} : ChatContentProps ) => {
84- const [ displayShrinked , setDispayShrinked ] = React . useState < boolean > (
85- shrinked === true || ( autoShrink === true && typeof shrinked === "undefined" )
86- ) ;
87-
88- const toggleSize = ( ) => {
89- if ( onToggleSize ) {
90- onToggleSize ( ) ;
91- } else {
92- setDispayShrinked ( ! displayShrinked ) ;
93- }
94- } ;
95-
9668 const content =
9769 markdownProps && typeof children === "string" ? < Markdown { ...markdownProps } > { children } </ Markdown > : children ;
9870
@@ -113,7 +85,7 @@ export const ChatContent = ({
11385 < Spacing size = "tiny" />
11486 </ HtmlContentBlock >
11587 ) }
116- { displayShrinked && autoShrink ? < TextReducer useOverflowTextWrapper > { content } </ TextReducer > : content }
88+ { content }
11789 </ div >
11890 ) ;
11991
@@ -142,17 +114,14 @@ export const ChatContent = ({
142114 </ FlexibleLayoutItem >
143115 ) }
144116 < FlexibleLayoutItem className = { `${ eccgui } -chat__content-wrapper` } > { chatitem } </ FlexibleLayoutItem >
145- { ( displayShrinked || onToggleSize || autoShrink ) && (
117+ { actionButton && (
146118 < FlexibleLayoutItem
147119 className = { `${ eccgui } -chat__content-sizetoggle` }
148120 growFactor = { 0 }
149121 shrinkFactor = { 0 }
150122 style = { alignment === "right" ? { order : - 1 } : undefined }
151123 >
152- < IconButton
153- name = { displayShrinked ? "toggler-showmore" : "toggler-showless" }
154- onClick = { ( ) => toggleSize ( ) }
155- />
124+ { actionButton }
156125 </ FlexibleLayoutItem >
157126 ) }
158127 </ FlexibleLayoutContainer >
0 commit comments