Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose chat container (DX-000) #352

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"@vanilla-extract/css": "1.15.5",
"@vanilla-extract/recipes": "0.5.5",
"@voiceflow/base-types": "2.113.1",
"@voiceflow/dtos-interact": "1.1.0",
"@voiceflow/dtos-interact": "1.9.0",
"@voiceflow/sdk-runtime": "workspace:*",
"@voiceflow/slate-serializer": "1.5.5",
"@voiceflow/voiceflow-types": "3.32.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { assignInlineVars } from '@vanilla-extract/dynamic';
import type { WidgetSettingsColorPalette } from '@voiceflow/dtos-interact';

import { PALETTE } from '@/styles/colors.css';

import { chatWindowStyle } from './ChatContainer.css';

export interface IChatContainer {
palette: WidgetSettingsColorPalette;
children?: React.ReactNode;
isMobile?: boolean;
}

export const ChatContainer: React.FC<IChatContainer> = ({ palette, children, isMobile = false }) => {
return (
<div style={assignInlineVars(PALETTE, { colors: palette })} className={chatWindowStyle({ mobile: isMobile })}>
{children}
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { recipe } from '@vanilla-extract/recipes';

export const chatWindow = recipe({
export const chatWindowStyle = recipe({
base: {
height: '100%',
maxHeight: '800px',
Expand Down
7 changes: 6 additions & 1 deletion packages/chat/src/components/NewChat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { type INewFooter, NewFooter } from '../NewFooter';
import { Prompt } from '../Prompt';
import { Separator } from '../Separator';
import { type IWelcomeMessage, WelcomeMessage } from '../WelcomeMessage';
import { ChatContainer } from './ChatContainer/ChatContainer.component';
import { bottomSpacer, chatContainer, chatContentWrapper, chatEndedContainer, dialogContainer } from './NewChat.css';

export interface INewChat
Expand Down Expand Up @@ -56,7 +57,7 @@ export interface INewChat
onStart?: (() => Promise<void>) | undefined;
}

export const NewChat: React.FC<INewChat> = ({
const Chat: React.FC<INewChat> = ({
buttons,
showPoweredBy,
messageInputProps,
Expand Down Expand Up @@ -142,3 +143,7 @@ export const NewChat: React.FC<INewChat> = ({
</div>
);
};

export const NewChat = Object.assign(Chat, {
Container: ChatContainer,
});
8 changes: 2 additions & 6 deletions packages/chat/src/views/ChatWindow/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import '../../styles.css';

import { assignInlineVars } from '@vanilla-extract/dynamic';
import React, { useCallback, useContext } from 'react';
import * as R from 'remeda';
import { match } from 'ts-pattern';
Expand All @@ -12,12 +11,9 @@ import { UserResponse } from '@/components/UserResponse';
import { RuntimeStateAPIContext, RuntimeStateContext } from '@/contexts/RuntimeContext';
import type { FeedbackName } from '@/contexts/RuntimeContext/useRuntimeAPI';
import { usePalette } from '@/hooks/usePalette';
import { PALETTE } from '@/styles/colors.css';
import type { UserTurnProps } from '@/types';
import { SessionStatus, TurnType } from '@/types';

import { chatWindow } from './styles.css';

export interface ChatWindowProps {
className?: string;
isMobile?: boolean;
Expand Down Expand Up @@ -46,7 +42,7 @@ export const ChatWindow: React.FC<ChatWindowProps> = ({ isMobile }) => {
if (!palette) return null;

return (
<div style={assignInlineVars(PALETTE, { colors: palette })} className={chatWindow({ mobile: isMobile })}>
<NewChat.Container isMobile={isMobile} palette={palette}>
<NewChat
title={assistant.title}
description={assistant.description}
Expand Down Expand Up @@ -99,6 +95,6 @@ export const ChatWindow: React.FC<ChatWindowProps> = ({ isMobile }) => {
</div>
)}
</NewChat>
</div>
</NewChat.Container>
);
};
11 changes: 10 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7480,6 +7480,15 @@ __metadata:
languageName: node
linkType: hard

"@voiceflow/dtos-interact@npm:1.9.0":
version: 1.9.0
resolution: "@voiceflow/dtos-interact@npm:1.9.0"
peerDependencies:
zod: ^3
checksum: 676a4d808f5f1191703fdc4b27f0d059774141bf9a4c2294bac16c25786fd2efd0e5a15c9637ae807ee2764db3be6a14c259e686b03beac04df341aee2795694
languageName: node
linkType: hard

"@voiceflow/eslint-config@npm:7.5.0":
version: 7.5.0
resolution: "@voiceflow/eslint-config@npm:7.5.0"
Expand Down Expand Up @@ -7651,7 +7660,7 @@ __metadata:
"@vanilla-extract/vite-plugin": 4.0.15
"@vitejs/plugin-react": 4.2.1
"@voiceflow/base-types": 2.113.1
"@voiceflow/dtos-interact": 1.1.0
"@voiceflow/dtos-interact": 1.9.0
"@voiceflow/sdk-runtime": "workspace:*"
"@voiceflow/slate-serializer": 1.5.5
"@voiceflow/test-common": 1.10.3
Expand Down
Loading