Skip to content

Commit f284910

Browse files
committed
fix(SendButton): Adjust disabled state
Adjusted disabled state and also added a demo for always-shown send button, with an explanation on how to use it.
1 parent 57da18a commit f284910

File tree

5 files changed

+57
-4
lines changed

5 files changed

+57
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react';
2+
import { MessageBar } from '@patternfly/chatbot/dist/dynamic/MessageBar';
3+
import { Checkbox } from '@patternfly/react-core';
4+
5+
export const ChatbotMessageBarDisabledExample: React.FunctionComponent = () => {
6+
const [isDisabled, setIsDisabled] = React.useState(false);
7+
const handleSend = (message) => alert(message);
8+
9+
return (
10+
<>
11+
<Checkbox
12+
label="Disable send button"
13+
isChecked={isDisabled}
14+
onChange={() => setIsDisabled(!isDisabled)}
15+
id="disabled"
16+
name="disabled"
17+
/>
18+
<MessageBar
19+
onSendMessage={handleSend}
20+
isSendButtonDisabled={isDisabled}
21+
alwayShowSendButton
22+
hasAttachButton={false}
23+
/>
24+
</>
25+
);
26+
};

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

+8
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,14 @@ In this example, the locale is set to to ja-JP. You can try it out by saying "ha
257257

258258
```
259259

260+
### Message bar with always-shown send button
261+
262+
You can use the `alwaysShowSendButton` prop if you want to always show the send button. You may also wish to apply the `isSendButtonDisabled` prop. Sending via the enter key will be disabled when this is passed in, demonstrated in the example below. You may want to enable or disable the send button based on whether there is text in the message bar. Whether text is present in the input can be detected via the `onChange` prop for `<MessageBar>`.
263+
264+
```js file="./ChatbotMessageBarDisabled.tsx"
265+
266+
```
267+
260268
### Message bar with attach menu appended to attach button
261269

262270
You can change the behavior of the attach button to open a menu, rather than the default file viewer for your operating system. This menu can display different actions related to attachments.

packages/module/src/MessageBar/SendButton.scss

+19
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,35 @@
77
width: 3rem;
88
height: 3rem;
99

10+
.pf-v6-c-button__icon {
11+
--pf-v6-c-button__icon--Color: var(--pf-t--global--color--brand--default);
12+
}
13+
1014
&:hover,
1115
&:focus {
1216
background-color: var(--pf-t--chatbot--blue-icon--background--color--hover);
17+
color: var(--pf-t--global--color--brand--hover);
1318

1419
.pf-v6-c-button__icon {
1520
color: var(--pf-t--chatbot--blue-icon--fill--hover);
1621
}
1722
}
1823
}
1924

25+
.pf-v6-theme-dark {
26+
.pf-v6-c-button.pf-chatbot__button--send {
27+
background-color: var(--pf-t--global--color--brand--default);
28+
.pf-v6-c-button__icon {
29+
--pf-v6-c-button__icon--Color: var(--pf-t--global--icon--color--inverse);
30+
}
31+
}
32+
33+
.pf-v6-c-button.pf-chatbot__button--send:hover,
34+
.pf-v6-c-button.pf-chatbot__button--send:focus {
35+
background-color: var(--pf-t--chatbot--blue-icon--background--color--hover);
36+
}
37+
}
38+
2039
@keyframes motionSendButton {
2140
0% {
2241
opacity: 0;

packages/module/src/MessageBar/SendButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ export const SendButton: React.FunctionComponent<SendButtonProps> = ({
3737
{...tooltipProps}
3838
>
3939
<Button
40+
variant="plain"
4041
className={`pf-chatbot__button--send ${className ?? ''}`}
41-
variant="link"
4242
aria-label={props['aria-label'] || 'Send button'}
4343
onClick={onClick}
4444
icon={

packages/module/src/main.scss

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
--pf-t--chatbot--timing-function: cubic-bezier(0.77, 0, 0.175, 1);
4848

4949
--pf-t--chatbot--blue-icon--background--color--hover: rgba(
50-
185,
51-
218,
52-
252,
50+
146,
51+
197,
52+
249,
5353
0.25
5454
); // --pf-t--global--color--nonstatus--blue--default @ 25%
5555
--pf-t--chatbot--blue-icon--fill--hover: var(--pf-t--global--color--brand--hover);

0 commit comments

Comments
 (0)