-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a71b967
commit 55e6900
Showing
11 changed files
with
1,810 additions
and
112 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...-docs/content/extensions/virtual-assistant/examples/VirtualAssistant/AssistantMessage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import VirtualAssistant from '@patternfly/virtual-assistant/dist/dynamic/VirtualAssistant'; | ||
import AssistantMessageEntry from '@patternfly/virtual-assistant/dist/dynamic/AssistantMessageEntry'; | ||
import GrinIcon from '@patternfly/react-icons/dist/js/icons/bacon-icon'; | ||
|
||
export const AssistantMessage: React.FunctionComponent = () => ( | ||
<VirtualAssistant> | ||
<AssistantMessageEntry> | ||
How may I help you today? Do you have some question for me? | ||
</AssistantMessageEntry> | ||
<AssistantMessageEntry icon={GrinIcon}> | ||
Assistant message example with custom icon | ||
</AssistantMessageEntry> | ||
</VirtualAssistant> | ||
); |
14 changes: 14 additions & 0 deletions
14
...t/extensions/virtual-assistant/examples/VirtualAssistant/AssistantMessageWithFollowup.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
import VirtualAssistant from '@patternfly/virtual-assistant/dist/dynamic/VirtualAssistant'; | ||
import AssistantMessageEntry from '@patternfly/virtual-assistant/dist/dynamic/AssistantMessageEntry'; | ||
|
||
export const AssistantMessage: React.FunctionComponent = () => ( | ||
<VirtualAssistant> | ||
<AssistantMessageEntry | ||
// eslint-disable-next-line no-console | ||
options={[ { title: "Option #1", props: { onClick: () => {console.log('This is an example of onClick event')} } }, { title: "Option #2" }, { title: "Option #3" } ]} | ||
> | ||
How may I help you today? Do you have some question for me? | ||
</AssistantMessageEntry> | ||
</VirtualAssistant> | ||
); |
11 changes: 11 additions & 0 deletions
11
...rnfly-docs/content/extensions/virtual-assistant/examples/VirtualAssistant/UserMessage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
import VirtualAssistant from '@patternfly/virtual-assistant/dist/dynamic/VirtualAssistant'; | ||
import UserMessageEntry from '@patternfly/virtual-assistant/dist/dynamic/UserMessageEntry'; | ||
import GrinIcon from '@patternfly/react-icons/dist/js/icons/bacon-icon'; | ||
|
||
export const UserMessage: React.FunctionComponent = () => ( | ||
<VirtualAssistant> | ||
<UserMessageEntry>Hello, can you help me?</UserMessageEntry> | ||
<UserMessageEntry icon={GrinIcon}>User message example with custom icon</UserMessageEntry> | ||
</VirtualAssistant> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
packages/module/src/AssistantMessageEntry/AssistantMessageEntry.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React, { PropsWithChildren } from 'react'; | ||
import { Icon, Label, Split, SplitItem, TextContent, LabelProps } from '@patternfly/react-core'; | ||
import { createUseStyles } from 'react-jss'; | ||
import classnames from "clsx"; | ||
|
||
import RobotIcon from '@patternfly/react-icons/dist/js/icons/robot-icon'; | ||
|
||
const useStyles = createUseStyles({ | ||
chatbot: { | ||
marginRight: "40px", | ||
}, | ||
bubble: { | ||
border: "1px solid var(--pf-v5-global--BackgroundColor--dark-400)", | ||
borderRadius: "14px", | ||
padding: "var(--pf-v5-global--spacer--sm) var(--pf-v5-global--spacer--md) var(--pf-v5-global--spacer--sm) var(--pf-v5-global--spacer--md)", | ||
maxWidth: "100%", | ||
wordWrap: "break-word", | ||
} | ||
}) | ||
|
||
interface AssistantMessageEntryProps { | ||
options?: { | ||
title: string; | ||
props?: LabelProps | ||
}[], | ||
icon?: React.ComponentClass; | ||
} | ||
|
||
export const AssistantMessageEntry = ({ children, options, icon: IconComponent = RobotIcon }: PropsWithChildren<AssistantMessageEntryProps>) => { | ||
const classes = useStyles(); | ||
return ( | ||
<div className="pf-v5-u-mb-md"> | ||
<Split className={classes.chatbot}> | ||
<SplitItem> | ||
<Icon size="lg" className="pf-v5-u-mr-sm pf-v5-u-pt-md"> | ||
<IconComponent /> | ||
</Icon> | ||
</SplitItem> | ||
<SplitItem className={classnames(classes.bubble," pf-v5-u-background-color-200")}> | ||
<TextContent className="pf-v5-u-font-size-sm"> | ||
{children} | ||
</TextContent> | ||
</SplitItem> | ||
</Split> | ||
{options ? ( | ||
<Split> | ||
<SplitItem className={classnames(classes.chatbot,"pf-v5-u-ml-xl pf-v5-u-mt-md")}> | ||
{options.map((option, index) => ( | ||
<Label key={index} className="pf-v5-u-m-xs" {...option.props}> | ||
{option.title} | ||
</Label> | ||
))} | ||
</SplitItem> | ||
</Split> | ||
) : null | ||
} | ||
</div> | ||
); | ||
}; | ||
|
||
export default AssistantMessageEntry; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default } from './AssistantMessageEntry'; | ||
export * from './AssistantMessageEntry'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React, { PropsWithChildren } from 'react'; | ||
import { Icon, Split, SplitItem, TextContent } from '@patternfly/react-core'; | ||
import OutlinedUserIcon from '@patternfly/react-icons/dist/js/icons/outlined-user-icon'; | ||
import { createUseStyles } from 'react-jss'; | ||
import classnames from "clsx"; | ||
|
||
const useStyles = createUseStyles({ | ||
user: { | ||
margin: "0 0 12px 40px", | ||
}, | ||
bubbleUser: { | ||
border: "1px solid var(--pf-v5-global--BackgroundColor--dark-400)", | ||
borderRadius: "14px", | ||
padding: "var(--pf-v5-global--spacer--sm) var(--pf-v5-global--spacer--md) var(--pf-v5-global--spacer--sm) var(--pf-v5-global--spacer--md)", | ||
maxWidth: "100%", | ||
wordWrap: "break-word", | ||
} | ||
}) | ||
|
||
interface UserMessageEntryProps { | ||
icon?: React.ComponentClass; | ||
} | ||
|
||
const UserMessageEntry = ({ children, icon: IconComponent = OutlinedUserIcon }: PropsWithChildren<UserMessageEntryProps>) => { | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<> | ||
<Split className={classnames(classes.user,"pf-v5-u-mb-md pf-v5-u-align-items-flex-start pf-v5-u-justify-content-flex-end")}> | ||
<SplitItem className={classes.bubbleUser}> | ||
<TextContent className="pf-v5-u-color-300 pf-v5-u-font-size-sm"> | ||
{children} | ||
</TextContent> | ||
</SplitItem> | ||
<SplitItem> | ||
<Icon size="lg" className="pf-v5-u-ml-sm pf-v5-u-pt-xs"> | ||
<IconComponent /> | ||
</Icon> | ||
</SplitItem> | ||
</Split> | ||
</> | ||
); | ||
}; | ||
|
||
export default UserMessageEntry; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default } from './UserMessageEntry'; | ||
export * from './UserMessageEntry'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters