Skip to content

Commit 9035a23

Browse files
ChatPanel: add support for footer (#61)
J=CLIP-879 TEST=manual added footer to test-site and verified that it appears as expected
1 parent 1ab379a commit 9035a23

File tree

8 files changed

+52
-2
lines changed

8 files changed

+52
-2
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@yext/chat-ui-react](./chat-ui-react.md) &gt; [ChatPanelCssClasses](./chat-ui-react.chatpanelcssclasses.md) &gt; [footerCssClasses](./chat-ui-react.chatpanelcssclasses.footercssclasses.md)
4+
5+
## ChatPanelCssClasses.footerCssClasses property
6+
7+
**Signature:**
8+
9+
```typescript
10+
footerCssClasses?: string;
11+
```

docs/chat-ui-react.chatpanelcssclasses.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface ChatPanelCssClasses
1717
| Property | Modifiers | Type | Description |
1818
| --- | --- | --- | --- |
1919
| [container?](./chat-ui-react.chatpanelcssclasses.container.md) | | string | _(Optional)_ |
20+
| [footerCssClasses?](./chat-ui-react.chatpanelcssclasses.footercssclasses.md) | | string | _(Optional)_ |
2021
| [inputContainer?](./chat-ui-react.chatpanelcssclasses.inputcontainer.md) | | string | _(Optional)_ |
2122
| [inputCssClasses?](./chat-ui-react.chatpanelcssclasses.inputcssclasses.md) | | [ChatInputCssClasses](./chat-ui-react.chatinputcssclasses.md) | _(Optional)_ |
2223
| [messageBubbleCssClasses?](./chat-ui-react.chatpanelcssclasses.messagebubblecssclasses.md) | | [MessageBubbleCssClasses](./chat-ui-react.messagebubblecssclasses.md) | _(Optional)_ |
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@yext/chat-ui-react](./chat-ui-react.md) &gt; [ChatPanelProps](./chat-ui-react.chatpanelprops.md) &gt; [footer](./chat-ui-react.chatpanelprops.footer.md)
4+
5+
## ChatPanelProps.footer property
6+
7+
A footer markdown string to render at the bottom of the panel.
8+
9+
**Signature:**
10+
11+
```typescript
12+
footer?: string;
13+
```

docs/chat-ui-react.chatpanelprops.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface ChatPanelProps extends Omit<MessageBubbleProps, "customCssClass
1818
| Property | Modifiers | Type | Description |
1919
| --- | --- | --- | --- |
2020
| [customCssClasses?](./chat-ui-react.chatpanelprops.customcssclasses.md) | | [ChatPanelCssClasses](./chat-ui-react.chatpanelcssclasses.md) | _(Optional)_ CSS classes for customizing the component styling. |
21+
| [footer?](./chat-ui-react.chatpanelprops.footer.md) | | string | _(Optional)_ A footer markdown string to render at the bottom of the panel. |
2122
| [header?](./chat-ui-react.chatpanelprops.header.md) | | ReactNode | _(Optional)_ A header to render at the top of the panel. |
2223
| [messageSuggestions?](./chat-ui-react.chatpanelprops.messagesuggestions.md) | | string\[\] | _(Optional)_ A set of pre-written initial messages that the user can click on instead of typing their own. |
2324

etc/chat-ui-react.api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ export interface ChatPanelCssClasses {
7070
// (undocumented)
7171
container?: string;
7272
// (undocumented)
73+
footerCssClasses?: string;
74+
// (undocumented)
7375
inputContainer?: string;
7476
// (undocumented)
7577
inputCssClasses?: ChatInputCssClasses;
@@ -86,6 +88,7 @@ export interface ChatPanelCssClasses {
8688
// @public
8789
export interface ChatPanelProps extends Omit<MessageBubbleProps, "customCssClasses" | "message">, Omit<ChatInputProps, "customCssClasses"> {
8890
customCssClasses?: ChatPanelCssClasses;
91+
footer?: string;
8992
header?: ReactNode;
9093
messageSuggestions?: string[];
9194
}

src/components/ChatPanel.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
MessageSuggestionCssClasses,
2222
MessageSuggestions,
2323
} from "./MessageSuggestions";
24+
import ReactMarkdown from "react-markdown";
2425

2526
/**
2627
* The CSS class interface for the {@link ChatPanel} component.
@@ -35,6 +36,7 @@ export interface ChatPanelCssClasses {
3536
inputCssClasses?: ChatInputCssClasses;
3637
messageBubbleCssClasses?: MessageBubbleCssClasses;
3738
messageSuggestionClasses?: MessageSuggestionCssClasses;
39+
footerCssClasses?: string;
3840
}
3941

4042
const builtInCssClasses: ChatPanelCssClasses = withStylelessCssClasses(
@@ -47,6 +49,8 @@ const builtInCssClasses: ChatPanelCssClasses = withStylelessCssClasses(
4749
messageBubbleCssClasses: {
4850
topContainer: "first:mt-4",
4951
},
52+
footerCssClasses:
53+
"text-center text-slate-400 rounded-b-3xl px-4 pb-4 text-[12px] [&>*>a]:text-blue-600",
5054
}
5155
);
5256

@@ -60,6 +64,8 @@ export interface ChatPanelProps
6064
Omit<ChatInputProps, "customCssClasses"> {
6165
/** A header to render at the top of the panel. */
6266
header?: ReactNode;
67+
/** A footer markdown string to render at the bottom of the panel. */
68+
footer?: string;
6369
/**
6470
* CSS classes for customizing the component styling.
6571
*/
@@ -81,8 +87,14 @@ export interface ChatPanelProps
8187
* @param props - {@link ChatPanelProps}
8288
*/
8389
export function ChatPanel(props: ChatPanelProps) {
84-
const { header, customCssClasses, stream, handleError, messageSuggestions } =
85-
props;
90+
const {
91+
header,
92+
footer,
93+
customCssClasses,
94+
stream,
95+
handleError,
96+
messageSuggestions,
97+
} = props;
8698
const messages = useChatState((state) => state.conversation.messages);
8799
const loading = useChatState((state) => state.conversation.isLoading);
88100
const suggestedReplies = useChatState(
@@ -163,6 +175,12 @@ export function ChatPanel(props: ChatPanelProps) {
163175
)}
164176
<ChatInput {...props} customCssClasses={cssClasses.inputCssClasses} />
165177
</div>
178+
{footer && (
179+
<ReactMarkdown
180+
children={footer}
181+
className={cssClasses.footerCssClasses}
182+
/>
183+
)}
166184
</div>
167185
</div>
168186
);

src/components/ChatPopUp.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export function ChatPopUp(props: ChatPopUpProps) {
133133
showUnreadNotification = false,
134134
ctaLabel,
135135
title,
136+
footer,
136137
} = props;
137138

138139
const reportAnalyticsEvent = useReportAnalyticsEvent();
@@ -224,6 +225,7 @@ export function ChatPopUp(props: ChatPopUpProps) {
224225
customCssClasses={cssClasses.headerCssClasses}
225226
/>
226227
}
228+
footer={footer}
227229
/>
228230
)}
229231
</div>

test-site/src/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function App() {
3131
"What locations are nearby?",
3232
"I'd like to learn more about a location in Arlington",
3333
]}
34+
footer="This is a test footer with [link](https://yext.com) and [another link](https://yext.com)"
3435
/>
3536
</div>
3637
</ChatHeadlessProvider>

0 commit comments

Comments
 (0)