@patternfly/chatbot 2.2.0-prerelease.14 → 2.2.0-prerelease.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Message/Message.js +13 -3
- package/dist/cjs/Message/Message.test.js +38 -3
- package/dist/cjs/Message/TextMessage/TextMessage.d.ts +2 -1
- package/dist/cjs/Message/TextMessage/TextMessage.js +2 -2
- package/dist/css/main.css +72 -68
- package/dist/css/main.css.map +1 -1
- package/dist/esm/Message/Message.js +14 -4
- package/dist/esm/Message/Message.test.js +38 -3
- package/dist/esm/Message/TextMessage/TextMessage.d.ts +2 -1
- package/dist/esm/Message/TextMessage/TextMessage.js +3 -3
- package/package.json +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/BotMessage.tsx +142 -13
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessage.tsx +182 -12
- package/src/ChatbotHeader/ChatbotHeader.scss +2 -2
- package/src/Message/CodeBlockMessage/CodeBlockMessage.scss +3 -3
- package/src/Message/ListMessage/ListMessage.scss +5 -5
- package/src/Message/Message.scss +3 -11
- package/src/Message/Message.test.tsx +40 -3
- package/src/Message/Message.tsx +23 -4
- package/src/Message/MessageLoading.scss +2 -2
- package/src/Message/TextMessage/TextMessage.scss +8 -11
- package/src/Message/TextMessage/TextMessage.tsx +3 -3
- package/src/MessageBar/AttachButton.scss +19 -3
- package/src/MessageBar/MessageBar.scss +3 -2
- package/src/MessageBar/MicrophoneButton.scss +8 -8
- package/src/MessageBar/StopButton.scss +17 -3
- package/src/MessageBox/JumpButton.scss +6 -6
- package/src/SourcesCard/SourcesCard.scss +2 -2
- package/src/main.scss +0 -4
@@ -13,10 +13,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
13
13
|
return t;
|
14
14
|
};
|
15
15
|
import React from 'react';
|
16
|
-
import { Content
|
16
|
+
import { Content } from '@patternfly/react-core';
|
17
17
|
const TextMessage = (_a) => {
|
18
|
-
var { children } = _a, props = __rest(_a, ["children"]);
|
18
|
+
var { component, children } = _a, props = __rest(_a, ["component", "children"]);
|
19
19
|
return (React.createElement("span", { className: "pf-chatbot__message-text" },
|
20
|
-
React.createElement(Content, Object.assign({ component:
|
20
|
+
React.createElement(Content, Object.assign({ component: component }, props), children)));
|
21
21
|
};
|
22
22
|
export default TextMessage;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@patternfly/chatbot",
|
3
|
-
"version": "2.2.0-prerelease.
|
3
|
+
"version": "2.2.0-prerelease.16",
|
4
4
|
"description": "This library provides React components based on PatternFly 6 that can be used to build chatbots.",
|
5
5
|
"main": "dist/cjs/index.js",
|
6
6
|
"module": "dist/esm/index.js",
|
@@ -2,9 +2,39 @@ import React from 'react';
|
|
2
2
|
import Message from '@patternfly/chatbot/dist/dynamic/Message';
|
3
3
|
import patternflyAvatar from './patternfly_avatar.jpg';
|
4
4
|
import squareImg from './PF-social-color-square.svg';
|
5
|
+
import { Form, FormGroup, Radio } from '@patternfly/react-core';
|
5
6
|
|
6
7
|
export const BotMessageExample: React.FunctionComponent = () => {
|
7
|
-
const
|
8
|
+
const [variant, setVariant] = React.useState('code');
|
9
|
+
|
10
|
+
/* eslint-disable indent */
|
11
|
+
const renderContent = () => {
|
12
|
+
switch (variant) {
|
13
|
+
case 'code':
|
14
|
+
return code;
|
15
|
+
case 'heading':
|
16
|
+
return heading;
|
17
|
+
case 'emphasis':
|
18
|
+
return emphasis;
|
19
|
+
case 'blockQuotes':
|
20
|
+
return blockQuotes;
|
21
|
+
case 'orderedList':
|
22
|
+
return orderedList;
|
23
|
+
case 'unorderedList':
|
24
|
+
return unorderedList;
|
25
|
+
case 'moreComplexList':
|
26
|
+
return moreComplexList;
|
27
|
+
case 'inlineCode':
|
28
|
+
return inlineCode;
|
29
|
+
case 'link':
|
30
|
+
return link;
|
31
|
+
default:
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
};
|
35
|
+
/* eslint-enable indent */
|
36
|
+
|
37
|
+
const code = `
|
8
38
|
Here is some YAML code:
|
9
39
|
|
10
40
|
~~~yaml
|
@@ -35,6 +65,36 @@ export default MessageLoading;
|
|
35
65
|
~~~
|
36
66
|
`;
|
37
67
|
|
68
|
+
const heading = `
|
69
|
+
# h1 Heading
|
70
|
+
|
71
|
+
## h2 Heading
|
72
|
+
|
73
|
+
### h3 Heading
|
74
|
+
|
75
|
+
#### h4 Heading
|
76
|
+
|
77
|
+
##### h5 Heading
|
78
|
+
|
79
|
+
###### h6 Heading
|
80
|
+
`;
|
81
|
+
|
82
|
+
const emphasis = `
|
83
|
+
**Bold text, formatted with double asterisks**
|
84
|
+
|
85
|
+
__Bold text, formatted with double underscores__
|
86
|
+
|
87
|
+
*Italic text, formatted with single asterisks*
|
88
|
+
|
89
|
+
_Italic text, formatted with single underscores_
|
90
|
+
|
91
|
+
~~Strikethrough~~
|
92
|
+
`;
|
93
|
+
|
94
|
+
const blockQuotes = `> Blockquotes can also be nested...
|
95
|
+
>> ...by using additional greater-than signs (>) right next to each other...
|
96
|
+
> > > ...or with spaces between each sign.`;
|
97
|
+
|
38
98
|
const orderedList = `
|
39
99
|
Here is an ordered list:
|
40
100
|
|
@@ -61,21 +121,13 @@ export default MessageLoading;
|
|
61
121
|
Acquire 1 tablespoon of room temperature \`butter\`. Use \`knife\` to spread butter on \`toast\`. Bon appétit!
|
62
122
|
`;
|
63
123
|
|
124
|
+
const link = `A paragraph with a URL: https://reactjs.org.`;
|
125
|
+
|
126
|
+
const inlineCode = `Here is an inline code - \`() => void\``;
|
127
|
+
|
64
128
|
return (
|
65
129
|
<>
|
66
130
|
<Message name="Bot" role="bot" avatar={patternflyAvatar} content={`Text-based message from a bot named "Bot"`} />
|
67
|
-
<Message
|
68
|
-
name="Bot"
|
69
|
-
role="bot"
|
70
|
-
avatar={patternflyAvatar}
|
71
|
-
content={`Text-based message from a bot named "Bot," with updated timestamp`}
|
72
|
-
timestamp="1 hour ago"
|
73
|
-
/>
|
74
|
-
<Message name="Bot" role="bot" avatar={patternflyAvatar} content={markdown} />
|
75
|
-
<Message name="Bot" role="bot" avatar={patternflyAvatar} content={orderedList} />
|
76
|
-
<Message name="Bot" role="bot" avatar={patternflyAvatar} content={unorderedList} />
|
77
|
-
<Message name="Bot" role="bot" avatar={patternflyAvatar} content={moreComplexList} />
|
78
|
-
<Message name="Bot" role="bot" avatar={patternflyAvatar} content="Example content" isLoading />
|
79
131
|
<Message role="bot" avatar={patternflyAvatar} content="Text-based message from a nameless bot" />
|
80
132
|
<Message
|
81
133
|
name="Default Openshift Container Platform Assistant That Can Help With Any Query You Might Need Help With"
|
@@ -90,6 +142,83 @@ export default MessageLoading;
|
|
90
142
|
content="Text-based message from a bot with a square avatar. You can further customize the avatar by applying an additional class or passing [PatternFly avatar props](/components/avatar) to the `<Message>` component via `avatarProps`."
|
91
143
|
hasRoundAvatar={false}
|
92
144
|
/>
|
145
|
+
<Message
|
146
|
+
name="Bot"
|
147
|
+
role="bot"
|
148
|
+
avatar={patternflyAvatar}
|
149
|
+
content={`Text-based message from a bot named "Bot," with updated timestamp`}
|
150
|
+
timestamp="1 hour ago"
|
151
|
+
/>
|
152
|
+
<Message name="Bot" role="bot" avatar={patternflyAvatar} content="Example content" isLoading />
|
153
|
+
|
154
|
+
<Form>
|
155
|
+
<FormGroup role="radiogroup" isInline fieldId="bot-message-type" label="Message content type">
|
156
|
+
<Radio
|
157
|
+
isChecked={variant === 'code'}
|
158
|
+
onChange={() => setVariant('code')}
|
159
|
+
name="bot-message-type"
|
160
|
+
label="Code"
|
161
|
+
id="code"
|
162
|
+
/>
|
163
|
+
<Radio
|
164
|
+
isChecked={variant === 'inlineCode'}
|
165
|
+
onChange={() => setVariant('inlineCode')}
|
166
|
+
name="bot-message-type"
|
167
|
+
label="Inline code"
|
168
|
+
id="inline-code"
|
169
|
+
/>
|
170
|
+
<Radio
|
171
|
+
isChecked={variant === 'heading'}
|
172
|
+
onChange={() => setVariant('heading')}
|
173
|
+
name="bot-message-type"
|
174
|
+
label="Heading"
|
175
|
+
id="heading"
|
176
|
+
/>
|
177
|
+
<Radio
|
178
|
+
isChecked={variant === 'blockQuotes'}
|
179
|
+
onChange={() => setVariant('blockQuotes')}
|
180
|
+
name="bot-message-type"
|
181
|
+
label="Block quote"
|
182
|
+
id="block-quotes"
|
183
|
+
/>
|
184
|
+
<Radio
|
185
|
+
isChecked={variant === 'emphasis'}
|
186
|
+
onChange={() => setVariant('emphasis')}
|
187
|
+
name="bot-message-type"
|
188
|
+
label="Emphasis"
|
189
|
+
id="emphasis"
|
190
|
+
/>
|
191
|
+
<Radio
|
192
|
+
isChecked={variant === 'link'}
|
193
|
+
onChange={() => setVariant('link')}
|
194
|
+
name="bot-message-type"
|
195
|
+
label="Link"
|
196
|
+
id="link"
|
197
|
+
/>
|
198
|
+
<Radio
|
199
|
+
isChecked={variant === 'unorderedList'}
|
200
|
+
onChange={() => setVariant('unorderedList')}
|
201
|
+
name="bot-message-type"
|
202
|
+
label="Unordered list"
|
203
|
+
id="unordered-list"
|
204
|
+
/>
|
205
|
+
<Radio
|
206
|
+
isChecked={variant === 'orderedList'}
|
207
|
+
onChange={() => setVariant('orderedList')}
|
208
|
+
name="bot-message-type"
|
209
|
+
label="Ordered list"
|
210
|
+
id="ordered-list"
|
211
|
+
/>
|
212
|
+
<Radio
|
213
|
+
isChecked={variant === 'moreComplexList'}
|
214
|
+
onChange={() => setVariant('moreComplexList')}
|
215
|
+
name="bot-message-type"
|
216
|
+
label="More complex list"
|
217
|
+
id="more-complex-list"
|
218
|
+
/>
|
219
|
+
</FormGroup>
|
220
|
+
</Form>
|
221
|
+
<Message name="Bot" role="bot" avatar={patternflyAvatar} content={renderContent()} />
|
93
222
|
</>
|
94
223
|
);
|
95
224
|
};
|
@@ -2,25 +2,128 @@ import React from 'react';
|
|
2
2
|
|
3
3
|
import Message from '@patternfly/chatbot/dist/dynamic/Message';
|
4
4
|
import userAvatar from './user_avatar.svg';
|
5
|
+
import { Form, FormGroup, Radio } from '@patternfly/react-core';
|
5
6
|
|
6
7
|
export const UserMessageExample: React.FunctionComponent = () => {
|
7
|
-
const
|
8
|
+
const [variant, setVariant] = React.useState('code');
|
8
9
|
|
9
|
-
|
10
|
+
/* eslint-disable indent */
|
11
|
+
const renderContent = () => {
|
12
|
+
switch (variant) {
|
13
|
+
case 'code':
|
14
|
+
return code;
|
15
|
+
case 'inlineCode':
|
16
|
+
return inlineCode;
|
17
|
+
case 'heading':
|
18
|
+
return heading;
|
19
|
+
case 'emphasis':
|
20
|
+
return emphasis;
|
21
|
+
case 'blockQuotes':
|
22
|
+
return blockQuotes;
|
23
|
+
case 'orderedList':
|
24
|
+
return orderedList;
|
25
|
+
case 'unorderedList':
|
26
|
+
return unorderedList;
|
27
|
+
case 'moreComplexList':
|
28
|
+
return moreComplexList;
|
29
|
+
case 'link':
|
30
|
+
return link;
|
31
|
+
default:
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
};
|
35
|
+
/* eslint-enable indent */
|
10
36
|
|
11
|
-
|
37
|
+
const code = `
|
38
|
+
Here is some YAML code:
|
12
39
|
|
13
|
-
|
40
|
+
~~~yaml
|
41
|
+
apiVersion: helm.openshift.io/v1beta1/
|
42
|
+
kind: HelmChartRepository
|
43
|
+
metadata:
|
44
|
+
name: azure-sample-repo0oooo00ooo
|
45
|
+
spec:
|
46
|
+
connectionConfig:
|
47
|
+
url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs
|
48
|
+
~~~
|
14
49
|
|
15
|
-
|
16
|
-
2. Item 3
|
17
|
-
3. Item 4
|
50
|
+
Here is some JavaScript code:
|
18
51
|
|
19
|
-
|
52
|
+
~~~js
|
53
|
+
import React from 'react';
|
54
|
+
|
55
|
+
const MessageLoading = () => (
|
56
|
+
<div className="pf-chatbot__message-loading">
|
57
|
+
<span className="pf-chatbot__message-loading-dots">
|
58
|
+
<span className="pf-v6-screen-reader">Loading message</span>
|
59
|
+
</span>
|
60
|
+
</div>
|
61
|
+
);
|
62
|
+
|
63
|
+
export default MessageLoading;
|
64
|
+
|
65
|
+
~~~
|
66
|
+
`;
|
67
|
+
|
68
|
+
const heading = `
|
69
|
+
# h1 Heading
|
70
|
+
|
71
|
+
## h2 Heading
|
72
|
+
|
73
|
+
### h3 Heading
|
74
|
+
|
75
|
+
#### h4 Heading
|
76
|
+
|
77
|
+
##### h5 Heading
|
78
|
+
|
79
|
+
###### h6 Heading
|
80
|
+
`;
|
81
|
+
|
82
|
+
const emphasis = `
|
83
|
+
**Bold text, formatted with double asterisks**
|
84
|
+
|
85
|
+
__Bold text, formatted with double underscores__
|
86
|
+
|
87
|
+
*Italic text, formatted with single asterisks*
|
88
|
+
|
89
|
+
_Italic text, formatted with single underscores_
|
90
|
+
|
91
|
+
~~Strikethrough~~
|
92
|
+
`;
|
93
|
+
|
94
|
+
const blockQuotes = `> Blockquotes can also be nested...
|
95
|
+
>> ...by using additional greater-than signs (>) right next to each other...
|
96
|
+
> > > ...or with spaces between each sign.`;
|
97
|
+
|
98
|
+
const orderedList = `
|
99
|
+
Here is an ordered list:
|
100
|
+
|
101
|
+
1. Item 1
|
102
|
+
2. Item 2
|
103
|
+
3. Item 3`;
|
104
|
+
|
105
|
+
const unorderedList = `
|
106
|
+
Here is an unordered list:
|
107
|
+
|
108
|
+
* Item 1
|
109
|
+
* Item 2
|
110
|
+
* Item 3`;
|
111
|
+
|
112
|
+
const moreComplexList = `You may be wondering whether you can display more complex lists with formatting. In response to your question, I will explain how to spread butter on toast.
|
113
|
+
|
114
|
+
1. **Using a \`toaster\`:**
|
115
|
+
|
116
|
+
- Place \`bread\` in a \`toaster\`
|
117
|
+
- Once \`bread\` is lightly browned, remove from \`toaster\`
|
118
|
+
|
119
|
+
2. **Using a \`knife\`:**
|
120
|
+
|
121
|
+
Acquire 1 tablespoon of room temperature \`butter\`. Use \`knife\` to spread butter on \`toast\`. Bon appétit!
|
122
|
+
`;
|
123
|
+
|
124
|
+
const link = `A paragraph with a URL: https://reactjs.org.`;
|
20
125
|
|
21
|
-
|
22
|
-
* Item 2
|
23
|
-
* Item 3`;
|
126
|
+
const inlineCode = `Here is an inline code - \`() => void\``;
|
24
127
|
|
25
128
|
return (
|
26
129
|
<>
|
@@ -31,7 +134,6 @@ Here is an unordered list:
|
|
31
134
|
timestamp="1 hour ago"
|
32
135
|
avatar={userAvatar}
|
33
136
|
/>
|
34
|
-
<Message name="User" role="user" content={markdown} avatar={userAvatar} />
|
35
137
|
<Message
|
36
138
|
name="User"
|
37
139
|
role="user"
|
@@ -39,6 +141,74 @@ Here is an unordered list:
|
|
39
141
|
avatar={userAvatar}
|
40
142
|
avatarProps={{ isBordered: true }}
|
41
143
|
/>
|
144
|
+
<Form>
|
145
|
+
<FormGroup role="radiogroup" isInline fieldId="user-message-type" label="Message content type">
|
146
|
+
<Radio
|
147
|
+
isChecked={variant === 'code'}
|
148
|
+
onChange={() => setVariant('code')}
|
149
|
+
name="user-message-type"
|
150
|
+
label="Code"
|
151
|
+
id="user-code"
|
152
|
+
/>
|
153
|
+
<Radio
|
154
|
+
isChecked={variant === 'inlineCode'}
|
155
|
+
onChange={() => setVariant('inlineCode')}
|
156
|
+
name="user-message-type"
|
157
|
+
label="Inline code"
|
158
|
+
id="user-inline-code"
|
159
|
+
/>
|
160
|
+
<Radio
|
161
|
+
isChecked={variant === 'heading'}
|
162
|
+
onChange={() => setVariant('heading')}
|
163
|
+
name="user-message-type"
|
164
|
+
label="Heading"
|
165
|
+
id="user-heading"
|
166
|
+
/>
|
167
|
+
<Radio
|
168
|
+
isChecked={variant === 'blockQuotes'}
|
169
|
+
onChange={() => setVariant('blockQuotes')}
|
170
|
+
name="user-message-type"
|
171
|
+
label="Block quote"
|
172
|
+
id="user-block-quotes"
|
173
|
+
/>
|
174
|
+
<Radio
|
175
|
+
isChecked={variant === 'emphasis'}
|
176
|
+
onChange={() => setVariant('emphasis')}
|
177
|
+
name="user-message-type"
|
178
|
+
label="Emphasis"
|
179
|
+
id="user-emphasis"
|
180
|
+
/>
|
181
|
+
<Radio
|
182
|
+
isChecked={variant === 'link'}
|
183
|
+
onChange={() => setVariant('link')}
|
184
|
+
name="user-message-type"
|
185
|
+
label="Link"
|
186
|
+
id="user-link"
|
187
|
+
/>
|
188
|
+
<Radio
|
189
|
+
isChecked={variant === 'unorderedList'}
|
190
|
+
onChange={() => setVariant('unorderedList')}
|
191
|
+
name="user-message-type"
|
192
|
+
label="Unordered list"
|
193
|
+
id="user-unordered-list"
|
194
|
+
/>
|
195
|
+
<Radio
|
196
|
+
isChecked={variant === 'orderedList'}
|
197
|
+
onChange={() => setVariant('orderedList')}
|
198
|
+
name="user-message-type"
|
199
|
+
label="Ordered list"
|
200
|
+
id="user-ordered-list"
|
201
|
+
/>
|
202
|
+
<Radio
|
203
|
+
isChecked={variant === 'moreComplexList'}
|
204
|
+
onChange={() => setVariant('moreComplexList')}
|
205
|
+
name="user-message-type"
|
206
|
+
label="More complex list"
|
207
|
+
id="user-more-complex-list"
|
208
|
+
/>
|
209
|
+
</FormGroup>
|
210
|
+
</Form>
|
211
|
+
<Message name="User" role="user" content={renderContent()} avatar={userAvatar} />
|
42
212
|
</>
|
43
213
|
);
|
44
214
|
};
|
@@ -92,7 +92,7 @@
|
|
92
92
|
.pf-v6-c-button__icon,
|
93
93
|
.pf-v6-c-menu-toggle__icon,
|
94
94
|
.pf-v6-c-icon__content {
|
95
|
-
color: var(--pf-t--
|
95
|
+
color: var(--pf-t--global--icon--color--subtle);
|
96
96
|
}
|
97
97
|
|
98
98
|
.pf-v6-c-button__icon,
|
@@ -108,7 +108,7 @@
|
|
108
108
|
.pf-v6-c-button__icon,
|
109
109
|
.pf-v6-c-menu-toggle__icon,
|
110
110
|
.pf-v6-c-icon__content {
|
111
|
-
color: var(--pf-t--
|
111
|
+
color: var(--pf-t--global--icon--color--regular);
|
112
112
|
}
|
113
113
|
}
|
114
114
|
}
|
@@ -40,11 +40,11 @@
|
|
40
40
|
}
|
41
41
|
|
42
42
|
.pf-chatbot__button--copy.pf-v6-c-button {
|
43
|
-
color: var(--pf-t--color--white);
|
43
|
+
color: var(--pf-t--color--white); // same in light + dark theme
|
44
44
|
|
45
45
|
&:hover,
|
46
46
|
&:focus {
|
47
|
-
color: var(--pf-t--color--white);
|
47
|
+
color: var(--pf-t--color--white); // same in light + dark theme
|
48
48
|
}
|
49
49
|
}
|
50
50
|
}
|
@@ -77,6 +77,6 @@
|
|
77
77
|
}
|
78
78
|
|
79
79
|
.pf-chatbot__message-inline-code {
|
80
|
-
background-color: var(--pf-t--
|
80
|
+
background-color: var(--pf-t--global--background--color--tertiary--default);
|
81
81
|
font-size: var(--pf-t--global--font--size--body--default);
|
82
82
|
}
|
@@ -5,8 +5,8 @@
|
|
5
5
|
.pf-chatbot__message-ordered-list,
|
6
6
|
.pf-chatbot__message-unordered-list {
|
7
7
|
width: fit-content;
|
8
|
-
padding: var(--pf-t--
|
9
|
-
border-radius: var(--pf-t--
|
8
|
+
padding: var(--pf-t--global--spacer--sm) 0 var(--pf-t--global--spacer--sm) 0;
|
9
|
+
border-radius: var(--pf-t--global--border--radius--small);
|
10
10
|
|
11
11
|
.pf-v6-c-list,
|
12
12
|
ul,
|
@@ -18,8 +18,8 @@
|
|
18
18
|
.pf-chatbot__message--user {
|
19
19
|
.pf-chatbot__message-ordered-list,
|
20
20
|
.pf-chatbot__message-unordered-list {
|
21
|
-
background-color: var(--pf-t--
|
22
|
-
color: var(--pf-t--
|
23
|
-
padding: var(--pf-t--
|
21
|
+
background-color: var(--pf-t--global--color--brand--default);
|
22
|
+
color: var(--pf-t--global--text--color--on-brand--default);
|
23
|
+
padding: var(--pf-t--global--spacer--sm);
|
24
24
|
}
|
25
25
|
}
|
package/src/Message/Message.scss
CHANGED
@@ -2,14 +2,6 @@
|
|
2
2
|
// Chatbot Message
|
3
3
|
// ============================================================================
|
4
4
|
.pf-chatbot__message {
|
5
|
-
--pf-t--chatbot-message--type--background--color--default: var(--pf-t--global--background--color--tertiary--default);
|
6
|
-
--pf-t--chatbot-message--type--background--color--primary: var(--pf-t--global--color--brand--default);
|
7
|
-
--pf-t--chatbot-message--type--padding: var(--pf-t--global--spacer--sm);
|
8
|
-
--pf-t--chatbot-message--type--text--color--default: var(--pf-t--global--text--color--regular);
|
9
|
-
--pf-t--chatbot-message--type--text--color--primary: var(--pf-t--global--text--color--inverse);
|
10
|
-
--pf-t--chatbot-message--type--border--radius: var(--pf-t--global--border--radius--small);
|
11
|
-
--pf-t--chatbot-message--meta--label--color: var(--pf-t--global--border--color--on-secondary);
|
12
|
-
|
13
5
|
display: flex;
|
14
6
|
align-items: flex-start;
|
15
7
|
gap: var(--pf-t--global--spacer--lg);
|
@@ -63,12 +55,12 @@
|
|
63
55
|
|
64
56
|
// Badge
|
65
57
|
.pf-v6-c-label {
|
66
|
-
--pf-v6-c-label--m-outline--BorderColor: var(--pf-t--
|
58
|
+
--pf-v6-c-label--m-outline--BorderColor: var(--pf-t--global--border--color--on-secondary);
|
67
59
|
--pf-v6-c-label--FontSize: var(--pf-t--global--font--size--xs);
|
68
60
|
font-weight: var(--pf-t--global--font--weight--body--bold);
|
69
61
|
|
70
62
|
.pf-v6-c-label__content {
|
71
|
-
--pf-v6-c-label--Color: var(--pf-t--
|
63
|
+
--pf-v6-c-label--Color: var(--pf-t--global--border--color--on-secondary);
|
72
64
|
}
|
73
65
|
}
|
74
66
|
|
@@ -88,7 +80,7 @@
|
|
88
80
|
flex-direction: column;
|
89
81
|
align-items: flex-start;
|
90
82
|
gap: var(--pf-t--global--font--size--sm);
|
91
|
-
color: var(--pf-t--
|
83
|
+
color: var(--pf-t--global--text--color--regular);
|
92
84
|
}
|
93
85
|
|
94
86
|
&-and-actions {
|
@@ -71,6 +71,24 @@ const ORDERED_LIST_WITH_CODE = `
|
|
71
71
|
3. Item 3
|
72
72
|
`;
|
73
73
|
|
74
|
+
const HEADING = `
|
75
|
+
# h1 Heading
|
76
|
+
|
77
|
+
## h2 Heading
|
78
|
+
|
79
|
+
### h3 Heading
|
80
|
+
|
81
|
+
#### h4 Heading
|
82
|
+
|
83
|
+
##### h5 Heading
|
84
|
+
|
85
|
+
###### h6 Heading
|
86
|
+
`;
|
87
|
+
|
88
|
+
const BLOCK_QUOTES = `> Blockquotes can also be nested...
|
89
|
+
>> ...by using additional greater-than signs (>) right next to each other...
|
90
|
+
> > > ...or with spaces between each sign.`;
|
91
|
+
|
74
92
|
const checkListItemsRendered = () => {
|
75
93
|
const items = ['Item 1', 'Item 2', 'Item 3'];
|
76
94
|
expect(screen.getAllByRole('listitem')).toHaveLength(3);
|
@@ -377,13 +395,17 @@ describe('Message', () => {
|
|
377
395
|
render(<Message avatar="./img" role="user" name="User" content={CODE_MESSAGE} />);
|
378
396
|
expect(screen.getByText('Here is some YAML code:')).toBeTruthy();
|
379
397
|
expect(screen.getByRole('button', { name: 'Copy code button' })).toBeTruthy();
|
380
|
-
expect(screen.getByText(/
|
398
|
+
expect(screen.getByText(/yaml/)).toBeTruthy();
|
399
|
+
expect(screen.getByText(/apiVersion:/i)).toBeTruthy();
|
400
|
+
expect(screen.getByText(/helm.openshift.io\/v1beta1/i)).toBeTruthy();
|
381
401
|
expect(screen.getByText(/metadata:/i)).toBeTruthy();
|
382
|
-
expect(screen.getByText(/name
|
402
|
+
expect(screen.getByText(/name:/i)).toBeTruthy();
|
403
|
+
expect(screen.getByText(/azure-sample-repo0oooo00ooo/i)).toBeTruthy();
|
383
404
|
expect(screen.getByText(/spec/i)).toBeTruthy();
|
384
405
|
expect(screen.getByText(/connectionConfig:/i)).toBeTruthy();
|
406
|
+
expect(screen.getByText(/url:/i)).toBeTruthy();
|
385
407
|
expect(
|
386
|
-
screen.getByText(/
|
408
|
+
screen.getByText(/https:\/\/raw.githubusercontent.com\/Azure-Samples\/helm-charts\/master\/docs/i)
|
387
409
|
).toBeTruthy();
|
388
410
|
});
|
389
411
|
it('can click copy code button', async () => {
|
@@ -491,4 +513,19 @@ describe('Message', () => {
|
|
491
513
|
);
|
492
514
|
expect(screen.getAllByRole('img')[1]).toHaveAttribute('src', 'test.png');
|
493
515
|
});
|
516
|
+
it('should handle block quote correctly', () => {
|
517
|
+
render(<Message avatar="./img" role="user" name="User" content={BLOCK_QUOTES} />);
|
518
|
+
expect(screen.getByText(/Blockquotes can also be nested.../)).toBeTruthy();
|
519
|
+
expect(screen.getByText('...by using additional greater-than signs (>) right next to each other...')).toBeTruthy();
|
520
|
+
expect(screen.getByText(/...or with spaces between each sign./)).toBeTruthy();
|
521
|
+
});
|
522
|
+
it('should handle heading correctly', () => {
|
523
|
+
render(<Message avatar="./img" role="user" name="User" content={HEADING} />);
|
524
|
+
expect(screen.getByRole('heading', { name: /h1 Heading/i })).toBeTruthy();
|
525
|
+
expect(screen.getByRole('heading', { name: /h2 Heading/i })).toBeTruthy();
|
526
|
+
expect(screen.getByRole('heading', { name: /h3 Heading/i })).toBeTruthy();
|
527
|
+
expect(screen.getByRole('heading', { name: /h4 Heading/i })).toBeTruthy();
|
528
|
+
expect(screen.getByRole('heading', { name: /h5 Heading/i })).toBeTruthy();
|
529
|
+
expect(screen.getByRole('heading', { name: /h6 Heading/i })).toBeTruthy();
|
530
|
+
});
|
494
531
|
});
|
package/src/Message/Message.tsx
CHANGED
@@ -6,7 +6,15 @@ import React from 'react';
|
|
6
6
|
|
7
7
|
import Markdown from 'react-markdown';
|
8
8
|
import remarkGfm from 'remark-gfm';
|
9
|
-
import {
|
9
|
+
import {
|
10
|
+
Avatar,
|
11
|
+
AvatarProps,
|
12
|
+
ContentVariants,
|
13
|
+
Label,
|
14
|
+
LabelGroupProps,
|
15
|
+
Timestamp,
|
16
|
+
Truncate
|
17
|
+
} from '@patternfly/react-core';
|
10
18
|
import MessageLoading from './MessageLoading';
|
11
19
|
import CodeBlockMessage from './CodeBlockMessage/CodeBlockMessage';
|
12
20
|
import TextMessage from './TextMessage/TextMessage';
|
@@ -173,11 +181,22 @@ export const MessageBase: React.FunctionComponent<MessageProps> = ({
|
|
173
181
|
) : (
|
174
182
|
<Markdown
|
175
183
|
components={{
|
176
|
-
p: TextMessage
|
177
|
-
code: ({ children }) =>
|
184
|
+
p: (props) => <TextMessage component={ContentVariants.p} {...props} />,
|
185
|
+
code: ({ children, ...props }) => (
|
186
|
+
<CodeBlockMessage {...props} {...codeBlockProps}>
|
187
|
+
{children}
|
188
|
+
</CodeBlockMessage>
|
189
|
+
),
|
178
190
|
ul: UnorderedListMessage,
|
179
191
|
ol: (props) => <OrderedListMessage {...props} />,
|
180
|
-
li: ListItemMessage
|
192
|
+
li: ListItemMessage,
|
193
|
+
h1: (props) => <TextMessage component={ContentVariants.h1} {...props} />,
|
194
|
+
h2: (props) => <TextMessage component={ContentVariants.h2} {...props} />,
|
195
|
+
h3: (props) => <TextMessage component={ContentVariants.h3} {...props} />,
|
196
|
+
h4: (props) => <TextMessage component={ContentVariants.h4} {...props} />,
|
197
|
+
h5: (props) => <TextMessage component={ContentVariants.h5} {...props} />,
|
198
|
+
h6: (props) => <TextMessage component={ContentVariants.h6} {...props} />,
|
199
|
+
blockquote: (props) => <TextMessage component={ContentVariants.blockquote} {...props} />
|
181
200
|
}}
|
182
201
|
remarkPlugins={[remarkGfm]}
|
183
202
|
>
|
@@ -3,9 +3,9 @@
|
|
3
3
|
// ============================================================================
|
4
4
|
.pf-chatbot__message-loading {
|
5
5
|
width: 36px;
|
6
|
-
padding: var(--pf-t--
|
6
|
+
padding: var(--pf-t--global--spacer--sm);
|
7
7
|
background-color: var(--pf-t--global--background--color--tertiary--default);
|
8
|
-
border-radius: var(--pf-t--
|
8
|
+
border-radius: var(--pf-t--global--border--radius--small);
|
9
9
|
|
10
10
|
&-dots {
|
11
11
|
position: relative;
|