Skip to content

Commit e15e279

Browse files
authored
feat(MessageBar): pulled in compass styles
feat(MessageBar): pulled in compass styles
2 parents 5990ef8 + 37066d6 commit e15e279

File tree

8 files changed

+80
-93
lines changed

8 files changed

+80
-93
lines changed

package-lock.json

Lines changed: 14 additions & 82 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"@babel/preset-react": "^7.23.3",
4040
"@babel/preset-typescript": "^7.23.3",
4141
"@octokit/rest": "^18.0.0",
42-
"@patternfly/documentation-framework": "6.28.6",
42+
"@patternfly/documentation-framework": "6.28.9",
4343
"@patternfly/patternfly": "^6.1.0",
4444
"@patternfly/react-icons": "^6.1.0",
4545
"@patternfly/react-table": "^6.1.0",

packages/module/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@patternfly/react-core": "^6.1.0",
3838
"@patternfly/react-icons": "^6.1.0",
3939
"@patternfly/react-table": "^6.1.0",
40+
"@patternfly/react-styles": "^6.1.0",
4041
"@segment/analytics-next": "^1.76.0",
4142
"clsx": "^2.1.0",
4243
"monaco-editor": "^0.54.0",
@@ -56,7 +57,7 @@
5657
},
5758
"devDependencies": {
5859
"@octokit/rest": "^18.0.0",
59-
"@patternfly/documentation-framework": "6.28.6",
60+
"@patternfly/documentation-framework": "6.28.9",
6061
"@patternfly/patternfly": "^6.1.0",
6162
"@patternfly/patternfly-a11y": "^5.0.0",
6263
"@types/dom-speech-recognition": "^0.0.4",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { FunctionComponent, useState } from 'react';
2+
import { MessageBar } from '@patternfly/chatbot/dist/dynamic/MessageBar';
3+
4+
export const ChatbotMessageBarIndicatorThinking: FunctionComponent = () => {
5+
const [isThinking, setIsThinking] = useState(false);
6+
const handleSend = (_message: string | number) => {
7+
setIsThinking(true);
8+
9+
setTimeout(() => {
10+
setIsThinking(false);
11+
}, 10000);
12+
};
13+
14+
return <MessageBar onSendMessage={handleSend} hasAiIndicator isThinking={isThinking} />;
15+
};

packages/module/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,16 @@ To enable the stop button, set `hasStopButton` to `true` and pass in a `handleSt
314314

315315
```
316316

317+
### Message bar with AI indicator styles
318+
319+
To add a more pronounced AI indicator style to the message bar, pass `hasAiIndicator` to the `<MessageBar>` component. You can also enable a "thinking" animation by passing in `isThinking`.
320+
321+
This example shows a simplified method of handling the "thinking" animation: after a user sends a message, the `isThinking` property is set to `true` to trigger the animation, then returns to `false` after 10 seconds to halt the animation.
322+
323+
```ts file="./ChatbotMessageBarIndicatorThinking.tsx" isBeta
324+
325+
```
326+
317327
## Navigation
318328

319329
### Side nav in a drawer

packages/module/src/MessageBar/MessageBar.scss

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,18 @@
2626

2727
overflow: hidden;
2828

29-
&.pf-m-primary {
30-
box-shadow: inset 0 0 0 1px var(--pf-t--global--border--color--default);
31-
}
29+
&:not(.pf-v6-m-thinking) {
30+
&.pf-m-primary {
31+
box-shadow: inset 0 0 0 1px var(--pf-t--global--border--color--default);
32+
}
3233

33-
&:hover {
34-
box-shadow: inset 0 0 0 1px var(--pf-t--global--border--color--default);
35-
}
34+
&:hover {
35+
box-shadow: inset 0 0 0 1px var(--pf-t--global--border--color--default);
36+
}
3637

37-
&:focus-within {
38-
box-shadow: inset 0 0 0 2px var(--pf-t--global--color--brand--default);
38+
&:focus-within {
39+
box-shadow: inset 0 0 0 2px var(--pf-t--global--color--brand--default);
40+
}
3941
}
4042

4143
&-actions {

packages/module/src/MessageBar/MessageBar.test.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,4 +476,16 @@ describe('Message bar', () => {
476476
const { container } = render(<MessageBar isPrimary onSendMessage={jest.fn} />);
477477
expect(container.querySelector('.pf-m-primary')).toBeTruthy();
478478
});
479+
480+
it('Renders with class pf-v6-m-ai-indicator when hasAiIndicator is true', () => {
481+
render(<MessageBar onSendMessage={jest.fn} hasAiIndicator />);
482+
483+
expect(screen.getByRole('textbox').closest('.pf-chatbot__message-bar')).toHaveClass('pf-v6-m-ai-indicator');
484+
});
485+
486+
it('Renders with class pf-v6-m-thinking when isThinking is true', () => {
487+
render(<MessageBar onSendMessage={jest.fn} isThinking />);
488+
489+
expect(screen.getByRole('textbox').closest('.pf-chatbot__message-bar')).toHaveClass('pf-v6-m-thinking');
490+
});
479491
});

packages/module/src/MessageBar/MessageBar.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
TextAreaProps,
1111
TooltipProps
1212
} from '@patternfly/react-core';
13+
import { css } from '@patternfly/react-styles';
1314

1415
// Import Chatbot components
1516
import SendButton from './SendButton';
@@ -115,6 +116,10 @@ export interface MessageBarProps extends Omit<TextAreaProps, 'innerRef'> {
115116
innerRef?: React.Ref<HTMLTextAreaElement>;
116117
/** Sets background color to primary */
117118
isPrimary?: boolean;
119+
/** @beta Flag indicating whether the message bar has an AI indicator border. */
120+
hasAiIndicator?: boolean;
121+
/** @beta Flag indicating whether the chatbot is thinking in response to a query, adding an animation to the message bar. */
122+
isThinking?: boolean;
118123
}
119124

120125
export const MessageBarBase: FunctionComponent<MessageBarProps> = ({
@@ -146,6 +151,8 @@ export const MessageBarBase: FunctionComponent<MessageBarProps> = ({
146151
dropzoneProps,
147152
innerRef,
148153
isPrimary,
154+
hasAiIndicator,
155+
isThinking,
149156
...props
150157
}: MessageBarProps) => {
151158
// Text Input
@@ -468,7 +475,15 @@ export const MessageBarBase: FunctionComponent<MessageBarProps> = ({
468475
}
469476

470477
return (
471-
<div className={`pf-chatbot__message-bar ${isPrimary ? 'pf-m-primary' : ''} ${className ?? ''}`}>
478+
<div
479+
className={css(
480+
'pf-chatbot__message-bar',
481+
isPrimary && 'pf-m-primary',
482+
hasAiIndicator && 'pf-v6-m-ai-indicator',
483+
isThinking && 'pf-v6-m-thinking',
484+
className
485+
)}
486+
>
472487
{messageBarContents}
473488
</div>
474489
);

0 commit comments

Comments
 (0)