Skip to content

Commit

Permalink
show chat description
Browse files Browse the repository at this point in the history
  • Loading branch information
znamenskii-ilia committed Oct 10, 2024
1 parent 9041c48 commit 8490251
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Button, Text, TextArea } from "@appsmith/wds";
import type { FormEvent, ForwardedRef, KeyboardEvent } from "react";
import React, { forwardRef, useCallback } from "react";
import { ChatDescriptionModal } from "./ChatDescriptionModal";
import { ChatTitle } from "./ChatTitle";
import styles from "./styles.module.css";
import { ThreadMessage } from "./ThreadMessage";
Expand All @@ -12,6 +13,7 @@ const MIN_PROMPT_LENGTH = 3;
const _AIChat = (props: AIChatProps, ref: ForwardedRef<HTMLDivElement>) => {
const {
// assistantName,
chatDescription,
chatTitle,
isWaitingForResponse = false,
onPromptChange,
Expand All @@ -22,6 +24,8 @@ const _AIChat = (props: AIChatProps, ref: ForwardedRef<HTMLDivElement>) => {
username,
...rest
} = props;
const [isChatDescriptionModalOpen, setIsChatDescriptionModalOpen] =
React.useState(false);

const handleFormSubmit = useCallback(
(event: FormEvent<HTMLFormElement>) => {
Expand All @@ -43,8 +47,24 @@ const _AIChat = (props: AIChatProps, ref: ForwardedRef<HTMLDivElement>) => {

return (
<div className={styles.root} ref={ref} {...rest}>
<ChatDescriptionModal
isOpen={isChatDescriptionModalOpen}
setOpen={() =>
setIsChatDescriptionModalOpen(!isChatDescriptionModalOpen)
}
>
{chatDescription}
</ChatDescriptionModal>

<div className={styles.header}>
<ChatTitle title={chatTitle} />
<div className={styles.chatInfo}>
<ChatTitle title={chatTitle} />
<Button
icon="info-square-rounded"
onPress={() => setIsChatDescriptionModalOpen(true)}
variant="ghost"
/>
</div>

<div className={styles.username}>
<UserAvatar username={username} />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Modal, ModalBody, ModalContent, ModalHeader } from "@appsmith/wds";
import React from "react";
import type { ChatDescriptionModalProps } from "./types";

export const ChatDescriptionModal = ({
children,
...rest
}: ChatDescriptionModalProps) => {
return (
<Modal {...rest}>
<ModalContent>
<ModalHeader title="Information about the bot" />
<ModalBody>{children}</ModalBody>
</ModalContent>
</Modal>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./ChatDescriptionModal";
export * from "./types";
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.root {
display: flex;
gap: 12px;
align-items: center;
/* TODO: --type-title doesn't exists. Define it */
font-size: var(--type-title, 22.499px);
font-style: normal;
font-weight: 500;
/* TODO: --type-title-lineheight doesn't exists. Define it */
line-height: var(--type-title-lineheight, 31.7px);
}

.logo {
display: inline-block;
width: 48px;
min-width: 48px;
height: 48px;
border-radius: 8px;
/* TODO: --bd-neutral doesn't exists. Define it */
border: 1px solid var(--bd-neutral, #81858b);
background: #f8f8f8;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { ModalProps } from "@appsmith/wds";

export interface ChatDescriptionModalProps extends ModalProps {}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
}
}

.chatInfo {
display: flex;
align-items: center;
gap: 8px;
}

.username {
display: flex;
align-items: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from "./ModalHeader";
export * from "./ModalFooter";
export * from "./ModalBody";
export * from "./ModalContent";
export * from "./types";
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ class WDSAIChatWidget extends BaseWidget<WDSAIChatWidgetProps, State> {
return (
<AIChat
assistantName={this.props.assistantName}
chatDescription={this.props.chatDescription}
chatTitle={this.props.chatTitle}
isWaitingForResponse={this.state.isWaitingForResponse}
onPromptChange={this.handlePromptChange}
Expand Down

0 comments on commit 8490251

Please sign in to comment.