Skip to content

Commit 12617c7

Browse files
committed
chore: design tweaks
1 parent 9c22726 commit 12617c7

File tree

5 files changed

+44
-47
lines changed

5 files changed

+44
-47
lines changed

examples/react-chatbot/components/ChatContainer/ChatContainer.tsx

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
'use client';
22

3-
import { Channel, MessageList, Window, MessageInput } from 'stream-chat-react';
3+
import { useEffect } from 'react';
4+
import type { DateSeparatorProps } from 'stream-chat-react';
5+
import { useChatContext } from 'stream-chat-react';
6+
import {
7+
Channel,
8+
MessageList,
9+
Window,
10+
MessageInput,
11+
DateSeparator,
12+
} from 'stream-chat-react';
13+
import { customAlphabet } from 'nanoid';
414
import { EmptyState } from '../EmptyState';
515
import { MessageBubble } from '../MessageBubble';
616
import { MessageInputBar } from '../MessageInputBar';
@@ -14,12 +24,33 @@ interface ChatContainerProps {
1424

1525
const NoOp = () => null;
1626

27+
const CustomDateSeparator = (props: DateSeparatorProps) => (
28+
<DateSeparator {...props} position="center" />
29+
);
30+
31+
const nanoId = customAlphabet('abcdefghijklmnopqrstuvwxyz0123456789', 10);
32+
1733
export const ChatContainer = ({ onToggleSidebar }: ChatContainerProps) => {
34+
const { channel, setActiveChannel, client } = useChatContext();
35+
useEffect(() => {
36+
if (!channel) {
37+
setActiveChannel(
38+
client.channel('messaging', `ai-${nanoId()}`, {
39+
members: [client.userID as string],
40+
// @ts-expect-error fix - this is a hack that allows a custom upload function to run
41+
own_capabilities: ['upload-file'],
42+
}),
43+
);
44+
}
45+
}, [channel, client, setActiveChannel]);
46+
1847
return (
1948
<div className="ai-demo-chat-container">
2049
<Channel
2150
initializeOnMount={false}
22-
EmptyPlaceholder={<EmptyState />}
51+
// EmptyPlaceholder={<EmptyState />}
52+
EmptyStateIndicator={EmptyState}
53+
DateSeparator={CustomDateSeparator}
2354
Message={MessageBubble}
2455
UnreadMessagesNotification={NoOp}
2556
UnreadMessagesSeparator={NoOp}

examples/react-chatbot/components/EmptyState/EmptyState.tsx

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,8 @@
11
'use client';
22

3-
import { useEffect } from 'react';
4-
import { useChatContext } from 'stream-chat-react';
5-
import { customAlphabet } from 'nanoid';
63
import './EmptyState.scss';
74

8-
const nanoId = customAlphabet('abcdefghijklmnopqrstuvwxyz0123456789', 10);
9-
105
export const EmptyState = () => {
11-
const { channel, setActiveChannel, client } = useChatContext();
12-
13-
useEffect(() => {
14-
if (!channel) {
15-
setActiveChannel(
16-
client.channel('messaging', `ai-${nanoId()}`, {
17-
members: [client.userID as string],
18-
// @ts-expect-error fix - this is a hack that allows custom upload funtion to run
19-
own_capabilities: ['upload-file'],
20-
}),
21-
);
22-
}
23-
}, [channel, client, setActiveChannel]);
24-
256
return (
267
<div className="ai-demo-empty-state">
278
<div className="ai-demo-empty-state__content">

examples/react-chatbot/components/MessageInputBar/MessageInputBar.scss

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -76,28 +76,6 @@
7676
}
7777
}
7878

79-
.aicr__ai-message-composer__form__submit-btn {
80-
background-color: var(--ai-demo-accent);
81-
color: white;
82-
border: none;
83-
border-radius: 8px;
84-
padding: 0.5rem;
85-
cursor: pointer;
86-
transition: background-color 0.2s ease;
87-
display: flex;
88-
align-items: center;
89-
justify-content: center;
90-
91-
&:hover:not(:disabled) {
92-
background-color: var(--ai-demo-accent-hover);
93-
}
94-
95-
&:disabled {
96-
opacity: 0.5;
97-
cursor: not-allowed;
98-
}
99-
}
100-
10179
/* Mobile responsiveness */
10280
@media (max-width: 768px) {
10381
padding: 1rem;

examples/react-chatbot/components/MessageInputBar/MessageInputBar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
useChannelStateContext,
1515
useChatContext,
1616
useMessageComposer,
17+
useStateStore,
1718
} from 'stream-chat-react';
1819
import { startAiAgent } from '@/components/api';
1920
import './MessageInputBar.scss';
@@ -133,7 +134,7 @@ export const MessageInputBar = () => {
133134
<AIMessageComposer.ModelSelect name="model" />
134135
</div>
135136

136-
<AIMessageComposer.SubmitButton />
137+
<AIMessageComposer.SubmitButton active={attachments.length > 0} />
137138
</div>
138139
</AIMessageComposer>
139140
</div>

packages/react-sdk/src/components/composer/ai-message-composer.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
useState,
99
} from 'react';
1010
import { customAlphabet } from 'nanoid';
11+
import clsx from 'clsx';
1112
import { StateStore } from '@stream-io/state-store';
1213
import { useStateStore } from '@stream-io/state-store/react-bindings';
1314

@@ -330,7 +331,7 @@ const TextInput = (props: ComponentPropsWithoutRef<'input'>) => {
330331

331332
const SpeechToTextButton = (
332333
props: ComponentPropsWithoutRef<'button'> & {
333-
options: UseSpeechToTextOptions;
334+
options?: UseSpeechToTextOptions;
334335
},
335336
) => {
336337
const { setText } = useText();
@@ -360,10 +361,15 @@ const SpeechToTextButton = (
360361
);
361362
};
362363

363-
const SubmitButton = (props: ComponentPropsWithoutRef<'button'>) => {
364+
const SubmitButton = (
365+
props: ComponentPropsWithoutRef<'button'> & { active?: boolean },
366+
) => {
364367
return (
365368
<button
366-
className="aicr__ai-message-composer__round-button"
369+
className={clsx(
370+
'aicr__ai-message-composer__round-button',
371+
props.active && 'aicr__ai-message-composer__round-button--active',
372+
)}
367373
type="submit"
368374
{...props}
369375
>

0 commit comments

Comments
 (0)