Skip to content

Commit

Permalink
Storybook: added new story for chat demostrating typingUsers (#28324)
Browse files Browse the repository at this point in the history
  • Loading branch information
Strider2342 authored Nov 8, 2024
1 parent 6b3e959 commit a2451d8
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
44 changes: 43 additions & 1 deletion apps/react-storybook/stories/chat/Chat.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Chat, ChatTypes} from 'devextreme-react/chat'
import type {Meta, StoryObj} from '@storybook/react';
import DataSource from 'devextreme/data/data_source';
import CustomStore from 'devextreme/data/custom_store';
import { firstAuthor, secondAuthor, initialMessages, longError } from './data';
import { firstAuthor, secondAuthor, thirdAuthor, fourthAuthor, initialMessages, longError } from './data';
import { Popup } from 'devextreme-react/popup';

import './styles.css';
Expand Down Expand Up @@ -390,3 +390,45 @@ export const Customization: Story = {
);
}
}

export const TypingUsers: Story = {
args: {
typingUsers: 'One user typing',
},
argTypes: {
typingUsers: {
control: 'select',
defaultValue: 'One user typing',
options: [
'No one is typing',
'One user typing',
'Two users typing',
'Three users typing',
'Multiple users typing',
],
mapping: {
['No one is typing']: [],
['One user typing']: [ firstAuthor ],
['Two users typing']: [ firstAuthor, secondAuthor ],
['Three users typing']: [ firstAuthor, secondAuthor, thirdAuthor ],
['Multiple users typing']: [ firstAuthor, secondAuthor, thirdAuthor, fourthAuthor ],
},
},
},
render: ({
typingUsers,
}) => {
return (
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
<Chat
width={400}
height={500}
items={initialMessages}
user={secondAuthor}
typingUsers={typingUsers}
>
</Chat>
</div>
);
}
}
10 changes: 10 additions & 0 deletions apps/react-storybook/stories/chat/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ export const secondAuthor: ChatTypes.User = {
name: "Jane Smith"
};

export const thirdAuthor: ChatTypes.User = {
id: "b02d90c5-ca37-4cc6-9b62-56e2ce573893",
name: "Gordon Freeman"
};

export const fourthAuthor: ChatTypes.User = {
id: "8adef6b1-ff40-42df-8456-f7c080e132b8",
name: "Crash Bandicoot"
};

const todayDate = new Date();

const date = new Date();
Expand Down

0 comments on commit a2451d8

Please sign in to comment.