Skip to content

Commit 51f9a9f

Browse files
authored
Update footer implementation (#62)
1 parent 9035a23 commit 51f9a9f

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

src/components/ChatPanel.tsx

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

2626
/**
2727
* The CSS class interface for the {@link ChatPanel} component.
@@ -50,7 +50,7 @@ const builtInCssClasses: ChatPanelCssClasses = withStylelessCssClasses(
5050
topContainer: "first:mt-4",
5151
},
5252
footerCssClasses:
53-
"text-center text-slate-400 rounded-b-3xl px-4 pb-4 text-[12px] [&>*>a]:text-blue-600",
53+
"text-center text-slate-400 rounded-b-3xl px-4 pb-4 text-[12px]",
5454
}
5555
);
5656

@@ -176,12 +176,42 @@ export function ChatPanel(props: ChatPanelProps) {
176176
<ChatInput {...props} customCssClasses={cssClasses.inputCssClasses} />
177177
</div>
178178
{footer && (
179-
<ReactMarkdown
180-
children={footer}
181-
className={cssClasses.footerCssClasses}
182-
/>
179+
<Footer footer={footer} className={cssClasses.footerCssClasses} />
183180
)}
184181
</div>
185182
</div>
186183
);
187184
}
185+
186+
const Footer = ({
187+
footer,
188+
className,
189+
}: {
190+
footer: string;
191+
className?: string;
192+
}) => {
193+
const components: ReactMarkdownOptions["components"] = useMemo(() => {
194+
return {
195+
a: ({ node: _, children, ...props }) => {
196+
return (
197+
<a
198+
{...props}
199+
target="_blank"
200+
rel="noopener noreferrer"
201+
className="cursor-pointer hover:underline text-blue-600"
202+
>
203+
{children}
204+
</a>
205+
);
206+
},
207+
};
208+
}, []);
209+
210+
return (
211+
<ReactMarkdown
212+
children={footer}
213+
className={className}
214+
components={components}
215+
/>
216+
);
217+
};

0 commit comments

Comments
 (0)