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

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.
package/lwc.config.json CHANGED
@@ -12,6 +12,7 @@
12
12
  "doc/contentCallout",
13
13
  "doc/chat",
14
14
  "doc/doDont",
15
+ "doc/editFile",
15
16
  "doc/contentLayout",
16
17
  "doc/contentMedia",
17
18
  "doc/docXmlContent",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "0.0.11-chat",
3
+ "version": "0.0.11-edit",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -0,0 +1,179 @@
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