Skip to content

Commit

Permalink
Merge pull request #9 from aferd/RHCLOUD-31243
Browse files Browse the repository at this point in the history
RHCLOUD-31243 add system message entry
  • Loading branch information
epwinchell authored Apr 3, 2024
2 parents eebfbe3 + 109332b commit 5b67cbb
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ sourceLink: https://github.com/patternfly/virtual-assistant/blob/main/packages/m

import VirtualAssistant from '@patternfly/virtual-assistant/dist/dynamic/VirtualAssistant';
import VirtualAssistantAction from '@patternfly/virtual-assistant/dist/dynamic/VirtualAssistantAction';
import SystemMessageEntry from '@patternfly/virtual-assistant/dist/esm/SystemMessageEntry'
import LoadingMessage from '@patternfly/virtual-assistant/dist/dynamic/LoadingMessage';
import { GrinIcon } from '@patternfly/react-icons';
import { AngleDownIcon } from '@patternfly/react-icons';
Expand Down Expand Up @@ -64,6 +65,15 @@ Custom actions can be added to the assistant body using the `actions` property.

```

### System Message Entry

The `SystemMessageEntry` component provides a simple system message with an option for text links.


```js file="./VirtualAssistantSystemMessageEntry.tsx"

```

### Loading Messages

The `LoadingMessage` component shows a typing indicator for messages still being processed, introducing an intentional delay to simulate a smoother flow of conversation. Additionally, it allows for the use of a custom icon through the `icon` property.
Expand All @@ -72,3 +82,4 @@ The `LoadingMessage` component shows a typing indicator for messages still being
```js file="./VirtualAssistantLoadingMessage.tsx"

```

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import VirtualAssistant from '@patternfly/virtual-assistant/dist/dynamic/VirtualAssistant';
import SystemMessageEntry from '@patternfly/virtual-assistant/dist/esm/SystemMessageEntry'

export const BasicExample: React.FunctionComponent = () => (
<VirtualAssistant >
<SystemMessageEntry>End of conversation.</SystemMessageEntry>
</VirtualAssistant>
);
28 changes: 28 additions & 0 deletions packages/module/src/SystemMessageEntry/SystemMessageEntry.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import { Text, TextContent, TextVariants } from '@patternfly/react-core';
import { createUseStyles } from 'react-jss';

export interface SystemMessageEntryProps {
/** Message rendered within the system message entry */
children: React.ReactNode;
}

const useStyles = createUseStyles({
systemMessageText: {
paddingBottom: "var(--pf-v5-global--spacer--md)",
textAlign: "center",
}
})

export const SystemMessageEntry: React.FunctionComponent<SystemMessageEntryProps> = (props) => {
const classes = useStyles();
return (
<TextContent>
<Text component={TextVariants.small} className={classes.systemMessageText}>
{props.children}
</Text>
</TextContent>
);
};

export default SystemMessageEntry;
3 changes: 3 additions & 0 deletions packages/module/src/SystemMessageEntry/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { default } from './SystemMessageEntry';

export * from './SystemMessageEntry';

0 comments on commit 5b67cbb

Please sign in to comment.