Skip to content

Commit

Permalink
update companion story with basic state
Browse files Browse the repository at this point in the history
  • Loading branch information
steppy452 committed Jul 31, 2024
1 parent 96c32f9 commit 85008fc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 31 additions & 7 deletions stories/Companion.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,28 @@ import {
ChatInput,
SessionMessagePanel,
SessionMessagesHeader,
SessionMessage
SessionMessage,
Session
} from '../src';
import { fakeSessions, sessionWithSources, sessionsWithFiles } from './examples';
import {
fakeSessions,
sessionWithSources,
sessionsWithFiles
} from './examples';
import { useState } from 'react';

export default {
title: 'Demos/Companion',
component: Chat
} as Meta;

export const Basic = () => {
const [activeId, setActiveId] = useState<string | null>(null);
const [sessions, setSessions] = useState<Session[]>([
...fakeSessions,
...sessionsWithFiles,
...sessionWithSources
]);
return (
<div
style={{
Expand All @@ -31,12 +43,24 @@ export const Basic = () => {
}}
>
<Chat
sessions={[
...fakeSessions,
...sessionsWithFiles,
...sessionWithSources
]}
viewType="companion"
sessions={sessions}
activeSessionId={activeId}
onNewSession={() => {
const newId = (sessions.length + 1).toLocaleString();
setSessions([
...sessions,
{
id: newId,
title: `New Session #${newId}`,
createdAt: new Date(),
updatedAt: new Date(),
conversations: []
}
]);
setActiveId(newId);
}}
onSelectSession={setActiveId}
onDeleteSession={() => alert('delete!')}
>
<SessionsList>
Expand Down

0 comments on commit 85008fc

Please sign in to comment.