reachat 2.1.0-alpha.17 → 2.1.0-alpha.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,25 +1,26 @@
1
- import { Meta } from '@storybook/react';
1
+ import type { Meta } from '@storybook/react';
2
+ import { IconButton } from 'reablocks';
3
+ import { useState } from 'react';
4
+
5
+ import type { Session } from 'reachat';
2
6
  import {
7
+ AppBar,
3
8
  Chat,
4
- SessionMessages,
5
9
  ChatInput,
6
- SessionMessagePanel,
7
10
  SessionMessage,
8
- Session,
9
- AppBar
11
+ SessionMessagePanel,
12
+ SessionMessages
10
13
  } from 'reachat';
11
- import {
12
- fakeSessions,
13
- sessionWithSources,
14
- sessionsWithFiles
15
- } from './examples';
16
- import { useState } from 'react';
14
+ import IconClose from './assets/close-fill.svg?react';
15
+ import ReachatLogo from './assets/logo.svg?react';
17
16
  import Placeholder from './assets/placeholder.svg?react';
18
17
  import PlaceholderDark from './assets/placeholder-dark.svg?react';
19
- import ReachatLogo from './assets/logo.svg?react';
20
18
  import IconSearch from './assets/search.svg?react';
21
- import IconClose from './assets/close-fill.svg?react';
22
- import { IconButton } from 'reablocks';
19
+ import {
20
+ fakeSessions,
21
+ sessionsWithFiles,
22
+ sessionWithSources
23
+ } from './examples';
23
24
 
24
25
  export default {
25
26
  title: 'Demos/Chat',
@@ -235,8 +236,12 @@ export const WithAppBar = () => {
235
236
  content={
236
237
  <div className="flex items-center justify-between w-full">
237
238
  <div className="flex-shrink-0">
238
- <IconButton size="small" variant="outline" className='rounded-full p-3'>
239
- <IconSearch className='w-4 h-4' />
239
+ <IconButton
240
+ size="small"
241
+ variant="outline"
242
+ className="rounded-full p-3"
243
+ >
244
+ <IconSearch className="w-4 h-4" />
240
245
  </IconButton>
241
246
  </div>
242
247
  <div className="flex-grow flex justify-center items-center">
@@ -246,9 +251,9 @@ export const WithAppBar = () => {
246
251
  <IconButton
247
252
  variant="text"
248
253
  size="small"
249
- className='rounded-full p-3'
254
+ className="rounded-full p-3"
250
255
  >
251
- <IconClose className='w-4 h-4' />
256
+ <IconClose className="w-4 h-4" />
252
257
  </IconButton>
253
258
  </div>
254
259
  </div>
@@ -78,6 +78,177 @@ export const TableWithMarkdown: Story = {
78
78
  )
79
79
  };
80
80
 
81
+ export const InlineAndCodeBlocks: Story = {
82
+ render: args => (
83
+ <div className="p-8 bg-background-neutral-canvas-base max-w-4xl">
84
+ <Markdown {...args}>
85
+ {`
86
+ # Inline Code vs Code Blocks
87
+
88
+ ## Inline Code Examples
89
+
90
+ Use inline code when referencing code elements within sentences:
91
+
92
+ - Call the \`useState\` hook to manage component state
93
+ - Import the component with \`import { Button } from 'reablocks'\`
94
+ - Set the variable using \`const name = 'John'\`
95
+ - The function \`calculateTotal()\` returns a number
96
+ - Access the property with \`user.email\`
97
+ - Use the className \`bg-blue-500\` for styling
98
+
99
+ You can also use inline code for short commands like \`npm install\` or file paths like \`/src/components/App.tsx\`.
100
+
101
+ ## Code Block Examples
102
+
103
+ Use code blocks for multi-line code snippets:
104
+ \`\`\`
105
+ Hello, world!
106
+ \`\`\`
107
+
108
+ ### TypeScript/React Component
109
+
110
+ \`\`\`typescript
111
+ import { useState } from 'react';
112
+ import { Button } from 'reablocks';
113
+
114
+ interface UserProps {
115
+ name: string;
116
+ email: string;
117
+ }
118
+
119
+ export const UserProfile = ({ name, email }: UserProps) => {
120
+ const [isEditing, setIsEditing] = useState(false);
121
+
122
+ return (
123
+ <div className="p-4 border rounded">
124
+ <h2>{name}</h2>
125
+ <p>{email}</p>
126
+ <Button onClick={() => setIsEditing(!isEditing)}>
127
+ {isEditing ? 'Save' : 'Edit'}
128
+ </Button>
129
+ </div>
130
+ );
131
+ };
132
+ \`\`\`
133
+
134
+ ### JavaScript
135
+
136
+ \`\`\`javascript
137
+ function fetchUserData(userId) {
138
+ return fetch(\`/api/users/\${userId}\`)
139
+ .then(response => response.json())
140
+ .then(data => {
141
+ console.log('User data:', data);
142
+ return data;
143
+ })
144
+ .catch(error => {
145
+ console.error('Error fetching user:', error);
146
+ });
147
+ }
148
+ \`\`\`
149
+
150
+ ### Python
151
+
152
+ \`\`\`python
153
+ def calculate_total(items):
154
+ total = sum(item['price'] * item['quantity'] for item in items)
155
+ return round(total, 2)
156
+
157
+ items = [
158
+ {'name': 'Book', 'price': 12.99, 'quantity': 2},
159
+ {'name': 'Pen', 'price': 1.50, 'quantity': 5}
160
+ ]
161
+
162
+ print(f"Total: $\{calculate_total(items)}")
163
+ \`\`\`
164
+
165
+ ### JSON
166
+
167
+ \`\`\`json
168
+ {
169
+ "name": "reachat",
170
+ "version": "1.0.0",
171
+ "dependencies": {
172
+ "react": "^18.3.0",
173
+ "reablocks": "^8.0.0"
174
+ },
175
+ "devDependencies": {
176
+ "typescript": "^5.0.0",
177
+ "vite": "^5.0.0"
178
+ }
179
+ }
180
+ \`\`\`
181
+
182
+ ### CSS/Tailwind
183
+
184
+ \`\`\`css
185
+ .chat-bubble {
186
+ padding: 1rem;
187
+ border-radius: 0.5rem;
188
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
189
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
190
+ }
191
+
192
+ .chat-bubble:hover {
193
+ transform: translateY(-2px);
194
+ box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
195
+ }
196
+ \`\`\`
197
+
198
+ ### Bash/Shell
199
+
200
+ \`\`\`bash
201
+ # Install dependencies
202
+ npm install
203
+
204
+ # Run development server
205
+ npm run dev
206
+
207
+ # Build for production
208
+ npm run build
209
+
210
+ # Run tests
211
+ npm test
212
+ \`\`\`
213
+
214
+ ### SQL
215
+
216
+ \`\`\`sql
217
+ SELECT
218
+ u.id,
219
+ u.name,
220
+ u.email,
221
+ COUNT(o.id) as order_count
222
+ FROM users u
223
+ LEFT JOIN orders o ON u.id = o.user_id
224
+ WHERE u.created_at > '2024-01-01'
225
+ GROUP BY u.id, u.name, u.email
226
+ ORDER BY order_count DESC
227
+ LIMIT 10;
228
+ \`\`\`
229
+
230
+ ## Mixed Usage
231
+
232
+ You can combine inline code and code blocks in the same content:
233
+
234
+ To create a new React component, first import \`React\` and \`useState\`:
235
+
236
+ \`\`\`tsx
237
+ import React, { useState } from 'react';
238
+
239
+ export const Counter = () => {
240
+ const [count, setCount] = useState(0);
241
+ return <button onClick={() => setCount(count + 1)}>{count}</button>;
242
+ };
243
+ \`\`\`
244
+
245
+ Then use it in your app by importing it with \`import { Counter } from './Counter'\` and rendering \`<Counter />\` in your JSX.
246
+ `}
247
+ </Markdown>
248
+ </div>
249
+ )
250
+ };
251
+
81
252
  export const AllMarkdownFeatures: Story = {
82
253
  render: args => (
83
254
  <div className="p-8 bg-background-neutral-canvas-base max-w-4xl">
package/dist/theme.d.ts CHANGED
@@ -59,6 +59,7 @@ export interface ChatTheme {
59
59
  th: string;
60
60
  td: string;
61
61
  code: string;
62
+ inlineCode: string;
62
63
  toolbar: string;
63
64
  li: string;
64
65
  ul: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reachat",
3
- "version": "2.1.0-alpha.17",
3
+ "version": "2.1.0-alpha.19",
4
4
  "description": "Chat UI for Building LLMs",
5
5
  "scripts": {
6
6
  "build-storybook": "storybook build",