@salesforcedevs/docs-components 0.0.9-edit → 0.0.11-chat

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,179 +0,0 @@
1
- # Sliding Chat Component (doc-chat)
2
-
3
- A self-contained sliding chat component with a floating trigger button that can be embedded in any layout, perfect for customer support, documentation help, or any conversational interface.
4
-
5
- ## Features
6
-
7
- - 🎯 **Sliding Component**: Slides in/out with smooth animations
8
- - 🔘 **Floating Trigger**: Built-in floating button to open chat (bottom-right corner)
9
- - 💬 **Real-time Chat**: Interactive messaging with typing indicators
10
- - 🎨 **Modern Design**: Clean, responsive interface with subtle animations
11
- - ⚙️ **Configurable**: Customizable title, placeholder, and assistant name
12
- - 📱 **Mobile Friendly**: Full-width on mobile devices
13
- - ♿ **Accessible**: ARIA labels and keyboard navigation
14
- - 🎭 **Storybook Ready**: Multiple story variations for testing
15
-
16
- ## Basic Usage
17
-
18
- The component is completely self-contained with a built-in floating trigger button:
19
-
20
- ```html
21
- <doc-chat
22
- title="Customer Support"
23
- placeholder="How can we help you today?"
24
- assistant-name="Support Bot"
25
- is-open="false"
26
- show-timestamp="true"
27
- ></doc-chat>
28
- ```
29
-
30
- That's it! The component will automatically show a floating chat button in the bottom-right corner when closed, and slide in the chat interface when opened.
31
-
32
- ## Properties
33
-
34
- | Property | Type | Default | Description |
35
- |----------|------|---------|-------------|
36
- | `title` | String | `"Chat"` | Title displayed in the chat header |
37
- | `placeholder` | String | `"Type your message..."` | Placeholder text for input field |
38
- | `assistant-name` | String | `"Assistant"` | Name of the assistant/bot |
39
- | `disabled` | Boolean | `false` | Disables the chat functionality |
40
- | `show-timestamp` | Boolean | `false` | Shows timestamps on messages |
41
- | `is-open` | Boolean | `false` | Controls sidebar visibility |
42
-
43
- ## Methods
44
-
45
- | Method | Description |
46
- |--------|-------------|
47
- | `openChat()` | Opens the chat sidebar |
48
- | `closeChat()` | Closes the chat sidebar |
49
-
50
- ## Events
51
-
52
- | Event | Description | Detail |
53
- |-------|-------------|--------|
54
- | `chatopened` | Fired when chat is opened | `{ opened: true }` |
55
- | `chatclosed` | Fired when chat is closed | `{ closed: true }` |
56
-
57
- ## Integration Example
58
-
59
- ### Simple Integration (Self-Contained)
60
- ```html
61
- <!-- The component includes its own trigger button -->
62
- <doc-chat
63
- title="Customer Support"
64
- placeholder="How can we help you today?"
65
- assistant-name="Support Bot"
66
- show-timestamp="true"
67
- is-open="false"
68
- ></doc-chat>
69
- ```
70
-
71
- ### Advanced Integration (With Custom Triggers)
72
- ```html
73
- <!-- Optional: Custom trigger button -->
74
- <button id="chat-trigger" onclick="openSupportChat()">
75
- 💬 Need Help?
76
- </button>
77
-
78
- <!-- Chat component -->
79
- <doc-chat
80
- id="support-chat"
81
- title="Customer Support"
82
- placeholder="How can we help you today?"
83
- assistant-name="Support Bot"
84
- show-timestamp="true"
85
- is-open="false"
86
- ></doc-chat>
87
- ```
88
-
89
- ### JavaScript
90
- ```javascript
91
- // Optional: Custom trigger function
92
- function openSupportChat() {
93
- const chat = document.getElementById('support-chat');
94
- chat.openChat();
95
- }
96
-
97
- // Listen for chat events
98
- document.getElementById('support-chat').addEventListener('chatclosed', (event) => {
99
- console.log('Chat was closed');
100
- });
101
-
102
- document.getElementById('support-chat').addEventListener('chatopened', (event) => {
103
- console.log('Chat was opened');
104
- });
105
- ```
106
-
107
- ## Styling
108
-
109
- The component uses CSS custom properties for easy theming:
110
-
111
- ```css
112
- doc-chat {
113
- --chat-width: 400px;
114
- --chat-z-index: 1000;
115
- --chat-transition-duration: 0.3s;
116
- --chat-header-bg: #f8f9fa;
117
- --chat-primary-color: #0066cc;
118
- --chat-border-color: #e0e0e0;
119
- }
120
- ```
121
-
122
- ## Responsive Behavior
123
-
124
- - **Desktop**: Fixed width component (400px)
125
- - **Tablet**: Full width component
126
- - **Mobile**: Full width component
127
-
128
- ## Accessibility
129
-
130
- - ARIA labels for screen readers
131
- - Keyboard navigation support
132
- - High contrast mode support
133
- - Reduced motion preferences respected
134
-
135
- ## Assistant Response Simulation
136
-
137
- The component includes a built-in response simulation system that responds to:
138
-
139
- - **Greetings**: "Hello", "Hi" → Friendly greeting
140
- - **Help requests**: "Help" → Assistance offer
141
- - **Documentation**: "Documentation", "Docs" → Navigation help
142
- - **General messages**: Contextual responses
143
-
144
- ### Replacing with Real API
145
-
146
- To integrate with a real chat API, replace the `simulateAssistantResponse` method:
147
-
148
- ```javascript
149
- // Replace this method in your extended component
150
- simulateAssistantResponse(userMessage) {
151
- // Call your chat API
152
- fetch('/api/chat', {
153
- method: 'POST',
154
- headers: { 'Content-Type': 'application/json' },
155
- body: JSON.stringify({ message: userMessage })
156
- })
157
- .then(response => response.json())
158
- .then(data => {
159
- this.addMessage(data.response, 'assistant');
160
- });
161
- }
162
- ```
163
-
164
- ## Browser Support
165
-
166
- - Chrome 80+
167
- - Firefox 72+
168
- - Safari 13+
169
- - Edge 80+
170
-
171
- ## Examples
172
-
173
- Check out the Storybook examples for various use cases:
174
-
175
- - **Default**: Basic chat setup
176
- - **With Timestamps**: Shows message timestamps
177
- - **Interactive Demo**: Fully functional example
178
- - **Mobile View**: Mobile device simulation
179
- - **Chat Trigger Example**: Integration patterns
@@ -1,511 +0,0 @@
1
- /* Host container */
2
- :host {
3
- font-family: "Salesforce Sans", -apple-system, BlinkMacSystemFont,
4
- "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue",
5
- sans-serif;
6
- position: absolute;
7
- top: 10px;
8
- left: 50%;
9
- z-index: 1000;
10
- }
11
-
12
- /* Edit File Trigger Button */
13
- .edit-file-trigger {
14
- background: linear-gradient(135deg, #0176d3 0%, #005fb2 100%);
15
- color: white;
16
- border: none;
17
- border-radius: 12px;
18
- padding: 12px 16px;
19
- cursor: pointer;
20
- display: flex;
21
- align-items: center;
22
- gap: 8px;
23
- box-shadow: 0 4px 16px rgb(1 118 211 / 25%), 0 2px 8px rgb(1 118 211 / 15%);
24
- transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
25
- font-size: 14px;
26
- font-weight: 500;
27
- letter-spacing: 0.02em;
28
- width: 150px;
29
- justify-content: center;
30
- }
31
-
32
- .edit-file-trigger:hover:not(:disabled) {
33
- background: linear-gradient(135deg, #005fb2 0%, #003e73 100%);
34
- transform: translateY(-2px);
35
- box-shadow: 0 6px 20px rgb(1 118 211 / 35%), 0 4px 12px rgb(1 118 211 / 25%);
36
- }
37
-
38
- .edit-file-trigger:active:not(:disabled) {
39
- transform: translateY(0);
40
- box-shadow: 0 2px 8px rgb(1 118 211 / 30%);
41
- }
42
-
43
- .edit-file-trigger:disabled {
44
- background: #d8dde6;
45
- color: #706e6b;
46
- cursor: not-allowed;
47
- transform: none;
48
- box-shadow: 0 1px 3px rgb(0 0 0 / 12%);
49
- }
50
-
51
- .edit-file-icon {
52
- width: 18px;
53
- height: 18px;
54
- flex-shrink: 0;
55
- }
56
-
57
- .edit-file-trigger-text {
58
- font-weight: 500;
59
- white-space: nowrap;
60
- }
61
-
62
- /* Overlay */
63
- .edit-file-overlay {
64
- position: fixed;
65
- top: 0;
66
- left: 0;
67
- width: 100%;
68
- height: 100%;
69
- background: rgb(0 0 0 / 50%);
70
- backdrop-filter: blur(4px);
71
- z-index: 10000;
72
- display: flex;
73
- align-items: center;
74
- justify-content: center;
75
- opacity: 0;
76
- visibility: hidden;
77
- transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
78
- padding: 20px;
79
- box-sizing: border-box;
80
- }
81
-
82
- .edit-file-overlay_open {
83
- opacity: 1;
84
- visibility: visible;
85
- }
86
-
87
- /* Popover */
88
- .edit-file-popover {
89
- background: white;
90
- border-radius: 16px;
91
- box-shadow: 0 20px 60px rgb(0 0 0 / 20%), 0 8px 24px rgb(0 0 0 / 15%);
92
- width: 100%;
93
- max-width: 900px;
94
- max-height: 90vh;
95
- display: flex;
96
- flex-direction: column;
97
- transform: scale(0.9) translateY(20px);
98
- transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
99
- overflow: hidden;
100
- }
101
-
102
- .edit-file-popover_open {
103
- transform: scale(1) translateY(0);
104
- }
105
-
106
- /* Popover Header */
107
- .edit-file-header {
108
- padding: 24px 24px 20px;
109
- border-bottom: 1px solid #e5e7ea;
110
- display: flex;
111
- align-items: flex-start;
112
- justify-content: space-between;
113
- gap: 16px;
114
- background: linear-gradient(180deg, #fafbfc 0%, #f7f9fb 100%);
115
- position: relative;
116
- }
117
-
118
- .edit-file-title {
119
- margin: 0;
120
- font-size: 24px;
121
- font-weight: 700;
122
- color: #181818;
123
- letter-spacing: -0.02em;
124
- }
125
-
126
- .edit-file-filename {
127
- margin: 8px 0 0;
128
- font-size: 14px;
129
- color: #706e6b;
130
- display: flex;
131
- align-items: center;
132
- gap: 6px;
133
- font-weight: 500;
134
- }
135
-
136
- .edit-file-file-icon {
137
- width: 16px;
138
- height: 16px;
139
- color: #0176d3;
140
- }
141
-
142
- .edit-file-close {
143
- width: 40px;
144
- height: 40px;
145
- border: none;
146
- background: transparent;
147
- border-radius: 10px;
148
- cursor: pointer;
149
- display: flex;
150
- align-items: center;
151
- justify-content: center;
152
- transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
153
- color: #706e6b;
154
- flex-shrink: 0;
155
- }
156
-
157
- .edit-file-close:hover {
158
- background: #f3f3f3;
159
- color: #181818;
160
- transform: scale(1.05);
161
- }
162
-
163
- .edit-file-close-icon {
164
- width: 20px;
165
- height: 20px;
166
- }
167
-
168
- /* Popover Content */
169
- .edit-file-content {
170
- flex: 1;
171
- padding: 24px;
172
- overflow-y: auto;
173
- min-height: 0;
174
- }
175
-
176
- /* Loading State */
177
- .edit-file-loading {
178
- display: flex;
179
- flex-direction: column;
180
- align-items: center;
181
- justify-content: center;
182
- padding: 60px 20px;
183
- gap: 16px;
184
- }
185
-
186
- .edit-file-spinner {
187
- width: 32px;
188
- height: 32px;
189
- border: 3px solid #e5e7ea;
190
- border-top: 3px solid #0176d3;
191
- border-radius: 50%;
192
- animation: edit-file-spin 1s linear infinite;
193
- }
194
-
195
- .edit-file-loading-text {
196
- margin: 0;
197
- color: #706e6b;
198
- font-size: 16px;
199
- font-weight: 500;
200
- }
201
-
202
- /* Error State */
203
- .edit-file-error {
204
- display: flex;
205
- align-items: center;
206
- gap: 12px;
207
- padding: 16px 20px;
208
- background: #fef7f7;
209
- border: 1px solid #fecaca;
210
- border-radius: 12px;
211
- color: #dc2626;
212
- margin-bottom: 20px;
213
- }
214
-
215
- .edit-file-error-icon {
216
- width: 20px;
217
- height: 20px;
218
- flex-shrink: 0;
219
- }
220
-
221
- .edit-file-error-text {
222
- font-size: 14px;
223
- font-weight: 500;
224
- }
225
-
226
- /* Editor */
227
- .edit-file-editor {
228
- width: 100%;
229
- }
230
-
231
- .edit-file-label {
232
- display: block;
233
- margin-bottom: 8px;
234
- font-size: 14px;
235
- font-weight: 600;
236
- color: #181818;
237
- }
238
-
239
- .edit-file-textarea {
240
- width: 100%;
241
- min-height: 400px;
242
- padding: 16px;
243
- border: 2px solid #e5e7ea;
244
- border-radius: 12px;
245
- font-family: "SF Mono", "Monaco", "Consolas", "Liberation Mono", "Courier New", monospace;
246
- font-size: 14px;
247
- line-height: 1.5;
248
- resize: vertical;
249
- outline: none;
250
- background: #fafbfc;
251
- transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
252
- box-sizing: border-box;
253
- }
254
-
255
- .edit-file-textarea:focus {
256
- border-color: #0176d3;
257
- background: white;
258
- box-shadow: 0 0 0 3px rgb(1 118 211 / 10%);
259
- }
260
-
261
- .edit-file-textarea::placeholder {
262
- color: #9ca3af;
263
- }
264
-
265
- /* Popover Footer */
266
- .edit-file-footer {
267
- padding: 20px 24px 24px;
268
- border-top: 1px solid #e5e7ea;
269
- display: flex;
270
- align-items: center;
271
- justify-content: space-between;
272
- gap: 16px;
273
- background: linear-gradient(180deg, #fafbfc 0%, #f7f9fb 100%);
274
- }
275
-
276
- /* Status Indicators */
277
- .edit-file-status {
278
- display: flex;
279
- align-items: center;
280
- gap: 8px;
281
- font-size: 14px;
282
- font-weight: 500;
283
- }
284
-
285
- .edit-file-saving {
286
- display: flex;
287
- align-items: center;
288
- gap: 8px;
289
- color: #0176d3;
290
- }
291
-
292
- .edit-file-mini-spinner {
293
- width: 16px;
294
- height: 16px;
295
- border: 2px solid #e5e7ea;
296
- border-top: 2px solid #0176d3;
297
- border-radius: 50%;
298
- animation: edit-file-spin 1s linear infinite;
299
- }
300
-
301
- .edit-file-unchanged {
302
- color: #706e6b;
303
- }
304
-
305
- .edit-file-modified {
306
- color: #059669;
307
- position: relative;
308
- }
309
-
310
- .edit-file-modified::before {
311
- content: "●";
312
- margin-right: 6px;
313
- color: #059669;
314
- }
315
-
316
- /* Action Buttons */
317
- .edit-file-actions {
318
- display: flex;
319
- gap: 12px;
320
- }
321
-
322
- .edit-file-button {
323
- padding: 12px 24px;
324
- border-radius: 10px;
325
- font-size: 14px;
326
- font-weight: 600;
327
- cursor: pointer;
328
- transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
329
- display: flex;
330
- align-items: center;
331
- gap: 8px;
332
- border: none;
333
- white-space: nowrap;
334
- }
335
-
336
- .edit-file-button_secondary {
337
- background: #f3f3f3;
338
- color: #181818;
339
- border: 1px solid #e5e7ea;
340
- }
341
-
342
- .edit-file-button_secondary:hover:not(:disabled) {
343
- background: #e5e7ea;
344
- transform: translateY(-1px);
345
- }
346
-
347
- .edit-file-button_primary {
348
- background: linear-gradient(135deg, #0176d3 0%, #005fb2 100%);
349
- color: white;
350
- }
351
-
352
- .edit-file-button_primary:hover:not(:disabled) {
353
- background: linear-gradient(135deg, #005fb2 0%, #003e73 100%);
354
- transform: translateY(-1px);
355
- box-shadow: 0 4px 12px rgb(1 118 211 / 25%);
356
- }
357
-
358
- .edit-file-button_disabled {
359
- background: #d8dde6 !important;
360
- color: #706e6b !important;
361
- cursor: not-allowed !important;
362
- transform: none !important;
363
- box-shadow: none !important;
364
- }
365
-
366
- .edit-file-button:disabled {
367
- background: #d8dde6;
368
- color: #706e6b;
369
- cursor: not-allowed;
370
- transform: none;
371
- box-shadow: none;
372
- }
373
-
374
- .edit-file-button-spinner {
375
- width: 16px;
376
- height: 16px;
377
- border: 2px solid transparent;
378
- border-top: 2px solid currentColor;
379
- border-radius: 50%;
380
- animation: edit-file-spin 1s linear infinite;
381
- }
382
-
383
- /* Animations */
384
- @keyframes edit-file-spin {
385
- to {
386
- transform: rotate(360deg);
387
- }
388
- }
389
-
390
- /* Responsive Design */
391
- @media (max-width: 768px) {
392
- .edit-file-trigger {
393
- padding: 10px 14px;
394
- font-size: 13px;
395
- }
396
-
397
- .edit-file-trigger-text {
398
- display: none;
399
- }
400
-
401
- .edit-file-overlay {
402
- padding: 16px;
403
- }
404
-
405
- .edit-file-popover {
406
- max-width: 100%;
407
- max-height: 95vh;
408
- }
409
-
410
- .edit-file-header {
411
- padding: 20px 20px 16px;
412
- }
413
-
414
- .edit-file-title {
415
- font-size: 20px;
416
- }
417
-
418
- .edit-file-content {
419
- padding: 20px;
420
- }
421
-
422
- .edit-file-textarea {
423
- min-height: 300px;
424
- font-size: 13px;
425
- }
426
-
427
- .edit-file-footer {
428
- padding: 16px 20px 20px;
429
- flex-direction: column;
430
- align-items: stretch;
431
- gap: 12px;
432
- }
433
-
434
- .edit-file-actions {
435
- width: 100%;
436
- justify-content: stretch;
437
- }
438
-
439
- .edit-file-button {
440
- flex: 1;
441
- justify-content: center;
442
- }
443
- }
444
-
445
- @media (max-width: 480px) {
446
- .edit-file-trigger {
447
- padding: 8px 12px;
448
- }
449
-
450
- .edit-file-overlay {
451
- padding: 12px;
452
- }
453
-
454
- .edit-file-header {
455
- padding: 16px;
456
- }
457
-
458
- .edit-file-title {
459
- font-size: 18px;
460
- }
461
-
462
- .edit-file-content {
463
- padding: 16px;
464
- }
465
-
466
- .edit-file-footer {
467
- padding: 12px 16px 16px;
468
- }
469
-
470
- .edit-file-textarea {
471
- min-height: 250px;
472
- padding: 12px;
473
- }
474
- }
475
-
476
- /* Accessibility improvements */
477
- @media (prefers-reduced-motion: reduce) {
478
- .edit-file-trigger,
479
- .edit-file-overlay,
480
- .edit-file-popover,
481
- .edit-file-close,
482
- .edit-file-button,
483
- .edit-file-textarea {
484
- transition: none;
485
- }
486
-
487
- .edit-file-spinner,
488
- .edit-file-mini-spinner,
489
- .edit-file-button-spinner {
490
- animation: none;
491
- }
492
- }
493
-
494
- /* High contrast mode support */
495
- @media (prefers-contrast: high) {
496
- .edit-file-trigger {
497
- border: 2px solid;
498
- }
499
-
500
- .edit-file-popover {
501
- border: 2px solid #000;
502
- }
503
-
504
- .edit-file-textarea {
505
- border: 2px solid #000;
506
- }
507
-
508
- .edit-file-button {
509
- border: 2px solid;
510
- }
511
- }