Skip to content

Commit

Permalink
chore(ai-chat-log): typedocs
Browse files Browse the repository at this point in the history
  • Loading branch information
krisantrobus committed Jan 14, 2025
1 parent 21ff802 commit 869544f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
SidePanelHeader,
SidePanelPushContentWrapper,
} from "@twilio-paste/side-panel";

import * as React from "react";

import {
Expand Down Expand Up @@ -169,7 +168,7 @@ export const SidePanelScroll: StoryFn = () => {
<AIChatMessageAuthor aria-label="AI said">Good Bot</AIChatMessageAuthor>
<AIChatMessageBody>
This is an indicator that the message was filtered (blocked) by Twilio or by the carrier. This may be done
by Twilio for violating Twilio's{" "}
by Twilio for violating Twilio&aposs{" "}
<Anchor href="https://www.twilio.com/en-us/legal/messaging-policy" showExternal>
Messaging Policy
</Anchor>{" "}
Expand Down Expand Up @@ -203,7 +202,7 @@ export const SidePanelScroll: StoryFn = () => {
setMounted(true);
}, []);

const scrollToChatEnd = () => {
const scrollToChatEnd = (): void => {
const scrollPosition: any = scrollerRef.current;
const scrollHeight: any = loggerRef.current;
scrollPosition?.scrollTo({ top: scrollHeight.scrollHeight, behavior: "smooth" });
Expand All @@ -221,12 +220,12 @@ export const SidePanelScroll: StoryFn = () => {
});
};

const onAnimationEnd = () => {
const onAnimationEnd = (): void => {
setIsAnimating(false);
scrollToChatEnd();
};

const onAnimationStart = () => {
const onAnimationStart = (): void => {
setIsAnimating(true);
};

Expand All @@ -239,20 +238,20 @@ export const SidePanelScroll: StoryFn = () => {
}, [isAnimating]);

// eslint-disable-next-line storybook/prefer-pascal-case
const createNewMessage = (message: any, forceBot?: boolean): Omit<AIChat, "id"> => {
const messageDirection = forceBot ? "bot" : getRandomInt(2) === 1 ? "user" : "bot";
const createNewMessage = (newMessage: any, forceBot?: boolean): Omit<AIChat, "id"> => {
const messageDirection = getRandomInt(2) === 1 && !forceBot ? "user" : "bot";

return {
variant: messageDirection,
content:
messageDirection === "user" ? (
<AIChatMessage variant="user">
<AIChatMessageAuthor aria-label="You said at 2:39pm">Gibby Radki</AIChatMessageAuthor>
<AIChatMessageBody>{message}</AIChatMessageBody>
<AIChatMessageBody>{newMessage}</AIChatMessageBody>
</AIChatMessage>
) : (
<AIChatMessage variant="bot">
<BotMessage message={message} onAnimationEnd={onAnimationEnd} onAnimationStart={onAnimationStart} />
<BotMessage message={newMessage} onAnimationEnd={onAnimationEnd} onAnimationStart={onAnimationStart} />
</AIChatMessage>
),
};
Expand All @@ -263,7 +262,7 @@ export const SidePanelScroll: StoryFn = () => {
push(createNewMessage(message));
};

const pushLargeBotMessage = () => {
const pushLargeBotMessage = (): void => {
push(
createNewMessage(
<>
Expand Down
14 changes: 8 additions & 6 deletions packages/paste-core/components/ai-chat-log/type-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3695,10 +3695,11 @@
"externalProp": true
},
"onAnimationEnd": {
"type": "AnimationEventHandler<HTMLDivElement>",
"defaultValue": null,
"type": "() => void",
"defaultValue": false,
"required": false,
"externalProp": true
"externalProp": false,
"description": "A callback when the animation is complete"
},
"onAnimationEndCapture": {
"type": "AnimationEventHandler<HTMLDivElement>",
Expand All @@ -3719,10 +3720,11 @@
"externalProp": true
},
"onAnimationStart": {
"type": "AnimationEventHandler<HTMLDivElement>",
"defaultValue": null,
"type": "() => void",
"defaultValue": false,
"required": false,
"externalProp": true
"externalProp": false,
"description": "A callback when the animation is started"
},
"onAnimationStartCapture": {
"type": "AnimationEventHandler<HTMLDivElement>",
Expand Down

0 comments on commit 869544f

Please sign in to comment.