Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/module/src/MessageBar/AttachButton.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,5 @@
.pf-v6-c-button.pf-chatbot__button--attach.pf-m-compact {
width: 1.5rem;
height: 1.5rem;
padding: var(--pf-t--global--spacer--sm);
align-items: center;
}
13 changes: 11 additions & 2 deletions packages/module/src/MessageBar/MessageBar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,22 @@
.pf-chatbot__message-textarea {
font-size: var(--pf-t--global--font--size--sm) !important;
}
}

.pf-m-compact {
.pf-chatbot__message-bar-actions {
padding-block-start: var(--pf-t--global--spacer--md);
padding-block-end: var(--pf-t--global--spacer--md);
padding-block-start: var(--pf-t--global--spacer--sm);
padding-block-end: var(--pf-t--global--spacer--sm);
}
}

// ============================================================================
// Multiline textarea styles (2+ lines)
// ============================================================================
.pf-chatbot__message-bar.pf-m-multiline {
border-radius: calc(var(--pf-t--global--border--radius--small) * 2);
}

// ============================================================================
// High contrast styles
// ============================================================================
Expand Down
25 changes: 22 additions & 3 deletions packages/module/src/MessageBar/MessageBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export const MessageBarBase: FunctionComponent<MessageBarProps> = ({
const [isListeningMessage, setIsListeningMessage] = useState<boolean>(false);
const [hasSentMessage, setHasSentMessage] = useState(false);
const [isComposing, setIsComposing] = useState(false);
const [isMultiline, setIsMultiline] = useState(false);
const inputRef = useRef<HTMLTextAreaElement>(null);
const textareaRef = (innerRef as React.RefObject<HTMLTextAreaElement>) ?? inputRef;
const attachButtonRef = useRef<HTMLButtonElement>(null);
Expand Down Expand Up @@ -209,6 +210,19 @@ export const MessageBarBase: FunctionComponent<MessageBarProps> = ({
return lines > 2;
};

const checkIfMultiline = useCallback(
(field: HTMLTextAreaElement) => {
const parent = field.parentElement;
const grandparent = parent?.parentElement;
if (grandparent) {
const containerHeight = grandparent.offsetHeight;
const threshold = isCompact ? 56 : 70;
setIsMultiline(containerHeight > threshold);
}
},
[isCompact]
);

const setAutoWidth = useCallback((field: HTMLTextAreaElement) => {
const parent = field.parentElement;
if (parent) {
Expand Down Expand Up @@ -263,12 +277,14 @@ export const MessageBarBase: FunctionComponent<MessageBarProps> = ({
if (field) {
if (field.value === '') {
setInitialLineHeight(field);
setIsMultiline(false);
} else {
setAutoHeight(field);
setAutoWidth(field);
checkIfMultiline(field);
}
}
}, [displayMode, message, setAutoWidth]);
}, [displayMode, message, setAutoWidth, checkIfMultiline]);

useEffect(() => {
const field = textareaRef.current;
Expand All @@ -284,13 +300,15 @@ export const MessageBarBase: FunctionComponent<MessageBarProps> = ({
if (textareaRef.current) {
if (event.target.value === '') {
setInitialLineHeight(textareaRef.current);
setIsMultiline(false);
} else {
setAutoHeight(textareaRef.current);
checkIfMultiline(textareaRef.current);
}
}
setMessage(event.target.value);
},
[onChange]
[onChange, checkIfMultiline]
);

// Handle sending message
Expand Down Expand Up @@ -453,7 +471,7 @@ export const MessageBarBase: FunctionComponent<MessageBarProps> = ({
return (
<AttachMenu
toggle={(toggleRef) => (
<div ref={toggleRef} className={`pf-chatbot__message-bar ${className ?? ''}`}>
<div ref={toggleRef} className={css('pf-chatbot__message-bar', isMultiline && 'pf-m-multiline', className)}>
{messageBarContents}
</div>
)}
Expand Down Expand Up @@ -481,6 +499,7 @@ export const MessageBarBase: FunctionComponent<MessageBarProps> = ({
isPrimary && 'pf-m-primary',
hasAiIndicator && 'pf-v6-m-ai-indicator',
isThinking && 'pf-v6-m-thinking',
isMultiline && 'pf-m-multiline',
className
)}
>
Expand Down
1 change: 0 additions & 1 deletion packages/module/src/MessageBar/MicrophoneButton.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,5 @@
.pf-v6-c-button.pf-chatbot__button--microphone.pf-m-compact {
width: 1.5rem;
height: 1.5rem;
padding: var(--pf-t--global--spacer--sm);
align-items: center;
}
1 change: 0 additions & 1 deletion packages/module/src/MessageBar/SendButton.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,5 @@
.pf-v6-c-button.pf-chatbot__button--send.pf-m-compact {
width: 1.5rem;
height: 1.5rem;
padding: var(--pf-t--global--spacer--sm);
align-items: center;
}
1 change: 0 additions & 1 deletion packages/module/src/MessageBar/StopButton.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,5 @@
.pf-v6-c-button.pf-chatbot__button--stop.pf-m-compact {
width: 1.5rem;
height: 1.5rem;
padding: var(--pf-t--global--spacer--sm);
align-items: center;
}
Loading
Loading