@hsafa/ui-sdk 0.6.2 → 0.6.4
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/dist/index.cjs +70 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +70 -9
- package/dist/index.js.map +1 -1
- package/docs/HSAFA_CHAT_CSS_GUIDE.md +650 -0
- package/docs/README.md +36 -0
- package/package.json +1 -1
|
@@ -0,0 +1,650 @@
|
|
|
1
|
+
# HsafaChat CSS Customization Guide
|
|
2
|
+
|
|
3
|
+
Complete guide for customizing HsafaChat components using CSS. All styles are theme-aware and work seamlessly with both dark and light themes.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
- [Quick Start](#quick-start)
|
|
7
|
+
- [CSS Variables](#css-variables)
|
|
8
|
+
- [Data Attributes](#data-attributes)
|
|
9
|
+
- [Component Selectors](#component-selectors)
|
|
10
|
+
- [Common Customizations](#common-customizations)
|
|
11
|
+
- [Theme-Aware Styling](#theme-aware-styling)
|
|
12
|
+
- [Advanced Examples](#advanced-examples)
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
Pass custom CSS to `HsafaChat` using the `customStyles` prop:
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
<HsafaChat
|
|
22
|
+
agentId="my-agent"
|
|
23
|
+
customStyles={`
|
|
24
|
+
/* Your custom CSS here */
|
|
25
|
+
[data-hsafa-chat] {
|
|
26
|
+
font-family: 'Inter', sans-serif;
|
|
27
|
+
}
|
|
28
|
+
`}
|
|
29
|
+
/>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## CSS Variables
|
|
35
|
+
|
|
36
|
+
All color values are exposed as CSS variables that automatically update based on theme and props.
|
|
37
|
+
|
|
38
|
+
### Available Variables
|
|
39
|
+
|
|
40
|
+
```css
|
|
41
|
+
:root {
|
|
42
|
+
/* Theme indicator */
|
|
43
|
+
--hsafa-theme: dark | light;
|
|
44
|
+
|
|
45
|
+
/* Base colors */
|
|
46
|
+
--hsafa-primary: #4D78FF; /* Primary brand color */
|
|
47
|
+
--hsafa-background: #0B0B0F; /* Main background */
|
|
48
|
+
--hsafa-border: #2A2C33; /* Border color */
|
|
49
|
+
--hsafa-text: #EDEEF0; /* Primary text */
|
|
50
|
+
--hsafa-accent: #17181C; /* Accent background */
|
|
51
|
+
--hsafa-muted-text: #6f7276; /* Secondary text */
|
|
52
|
+
|
|
53
|
+
/* Component backgrounds */
|
|
54
|
+
--hsafa-input-bg: #17181C; /* Input field background */
|
|
55
|
+
--hsafa-card-bg: #121318; /* Card/message background */
|
|
56
|
+
--hsafa-hover-bg: #1c1e25; /* Hover state background */
|
|
57
|
+
|
|
58
|
+
/* Status colors */
|
|
59
|
+
--hsafa-error: #ef4444; /* Error state */
|
|
60
|
+
--hsafa-error-light: #fee2e2; /* Error background */
|
|
61
|
+
--hsafa-error-dark: #991b1b; /* Error dark variant */
|
|
62
|
+
|
|
63
|
+
--hsafa-success: #10b981; /* Success state */
|
|
64
|
+
--hsafa-success-light: rgba(16,185,129,0.15); /* Success background */
|
|
65
|
+
|
|
66
|
+
--hsafa-warning: #eab308; /* Warning state */
|
|
67
|
+
--hsafa-warning-light: rgba(234,179,8,0.15); /* Warning background */
|
|
68
|
+
|
|
69
|
+
--hsafa-info: #3b82f6; /* Info state */
|
|
70
|
+
--hsafa-info-light: rgba(59,130,246,0.15); /* Info background */
|
|
71
|
+
|
|
72
|
+
--hsafa-danger: #ef4444; /* Danger state */
|
|
73
|
+
--hsafa-danger-light: rgba(239,68,68,0.1); /* Danger background */
|
|
74
|
+
--hsafa-danger-dark: #991b1b; /* Danger dark variant */
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Using Variables
|
|
79
|
+
|
|
80
|
+
```css
|
|
81
|
+
/* Example: Change input background */
|
|
82
|
+
[data-hsafa-chat] textarea {
|
|
83
|
+
background: var(--hsafa-input-bg) !important;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* Example: Custom primary color usage */
|
|
87
|
+
[data-hsafa-chat] button[aria-label="Send"] {
|
|
88
|
+
background: var(--hsafa-primary) !important;
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Data Attributes
|
|
95
|
+
|
|
96
|
+
Use data attributes to target specific chat instances or themes:
|
|
97
|
+
|
|
98
|
+
### Chat Type
|
|
99
|
+
- `[data-hsafa-chat="fullpage"]` - Full-page chat layout
|
|
100
|
+
- `[data-hsafa-chat="panel"]` - Floating panel chat layout
|
|
101
|
+
|
|
102
|
+
### Theme
|
|
103
|
+
- `[data-hsafa-theme="dark"]` - Dark theme
|
|
104
|
+
- `[data-hsafa-theme="light"]` - Light theme
|
|
105
|
+
|
|
106
|
+
### Agent ID
|
|
107
|
+
- `[data-hsafa-agent-id="your-agent-id"]` - Specific agent
|
|
108
|
+
|
|
109
|
+
### Examples
|
|
110
|
+
|
|
111
|
+
```css
|
|
112
|
+
/* Style only full-page chats */
|
|
113
|
+
[data-hsafa-chat="fullpage"] {
|
|
114
|
+
background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* Style specific agent */
|
|
118
|
+
[data-hsafa-agent-id="support-agent"] {
|
|
119
|
+
--hsafa-primary: #10b981;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* Dark theme specific styles */
|
|
123
|
+
[data-hsafa-theme="dark"] {
|
|
124
|
+
--hsafa-card-bg: #000000;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* Light theme specific styles */
|
|
128
|
+
[data-hsafa-theme="light"] {
|
|
129
|
+
--hsafa-card-bg: #f5f5f5;
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Component Selectors
|
|
136
|
+
|
|
137
|
+
### Chat Container
|
|
138
|
+
|
|
139
|
+
```css
|
|
140
|
+
/* Main chat container */
|
|
141
|
+
[data-hsafa-chat] {
|
|
142
|
+
font-family: 'Your Font', sans-serif;
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Messages Area
|
|
147
|
+
|
|
148
|
+
```css
|
|
149
|
+
/* Messages container */
|
|
150
|
+
[data-hsafa-chat] > div > div[style*="flex-direction: column"] {
|
|
151
|
+
padding: 20px;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* Individual message */
|
|
155
|
+
[data-hsafa-chat] [style*="margin-bottom"] > div {
|
|
156
|
+
border-radius: 12px;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/* User message */
|
|
160
|
+
[data-hsafa-chat] div[style*="align-items: flex-end"] {
|
|
161
|
+
/* Styles for user messages */
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/* Assistant message */
|
|
165
|
+
[data-hsafa-chat] div[style*="align-items: flex-start"] {
|
|
166
|
+
/* Styles for assistant messages */
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Input Area
|
|
171
|
+
|
|
172
|
+
```css
|
|
173
|
+
/* Input container */
|
|
174
|
+
[data-hsafa-chat] div[style*="padding: 12px"] {
|
|
175
|
+
background: var(--hsafa-input-bg);
|
|
176
|
+
border-radius: 16px;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/* Textarea */
|
|
180
|
+
[data-hsafa-chat] textarea {
|
|
181
|
+
background: var(--hsafa-input-bg) !important;
|
|
182
|
+
color: var(--hsafa-text) !important;
|
|
183
|
+
border: 1px solid var(--hsafa-border) !important;
|
|
184
|
+
border-radius: 12px !important;
|
|
185
|
+
padding: 12px 16px !important;
|
|
186
|
+
font-size: 15px !important;
|
|
187
|
+
line-height: 1.5 !important;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/* Send button */
|
|
191
|
+
[data-hsafa-chat] button[aria-label="Send"],
|
|
192
|
+
[data-hsafa-chat] button[title="Send message"] {
|
|
193
|
+
background: var(--hsafa-primary) !important;
|
|
194
|
+
color: white !important;
|
|
195
|
+
border-radius: 10px !important;
|
|
196
|
+
padding: 10px 16px !important;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/* Stop button */
|
|
200
|
+
[data-hsafa-chat] button[title="Stop generation"] {
|
|
201
|
+
background: var(--hsafa-danger-light) !important;
|
|
202
|
+
color: var(--hsafa-danger) !important;
|
|
203
|
+
border: 1px solid var(--hsafa-danger) !important;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/* Attachment button */
|
|
207
|
+
[data-hsafa-chat] button[aria-label="Attach files"] {
|
|
208
|
+
color: var(--hsafa-muted-text) !important;
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Header
|
|
213
|
+
|
|
214
|
+
```css
|
|
215
|
+
/* Header container */
|
|
216
|
+
[data-hsafa-chat] > div > div:first-child {
|
|
217
|
+
background: var(--hsafa-card-bg);
|
|
218
|
+
border-bottom: 1px solid var(--hsafa-border);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/* Title */
|
|
222
|
+
[data-hsafa-chat] div[style*="font-size: 16px"][style*="font-weight: 600"] {
|
|
223
|
+
font-size: 18px !important;
|
|
224
|
+
font-weight: 700 !important;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/* New chat button */
|
|
228
|
+
[data-hsafa-chat] button[title="New"] {
|
|
229
|
+
background: var(--hsafa-accent) !important;
|
|
230
|
+
border-radius: 8px !important;
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Chat History
|
|
235
|
+
|
|
236
|
+
```css
|
|
237
|
+
/* History panel */
|
|
238
|
+
[data-hsafa-chat] div[style*="width: 280px"] {
|
|
239
|
+
background: var(--hsafa-card-bg);
|
|
240
|
+
border-right: 1px solid var(--hsafa-border);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/* Search input */
|
|
244
|
+
[data-hsafa-chat] input[placeholder*="Search"] {
|
|
245
|
+
background: var(--hsafa-input-bg) !important;
|
|
246
|
+
border: 1px solid var(--hsafa-border) !important;
|
|
247
|
+
border-radius: 8px !important;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/* Chat item */
|
|
251
|
+
[data-hsafa-chat] div[style*="cursor: pointer"][style*="padding: 12px"] {
|
|
252
|
+
border-radius: 8px;
|
|
253
|
+
margin: 4px 8px;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/* Delete button */
|
|
257
|
+
[data-hsafa-chat] button[title*="Delete"] {
|
|
258
|
+
color: var(--hsafa-muted-text);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
[data-hsafa-chat] button[title*="Delete"]:hover {
|
|
262
|
+
color: var(--hsafa-danger) !important;
|
|
263
|
+
background: var(--hsafa-danger-light) !important;
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Tool Calls & Status Badges
|
|
268
|
+
|
|
269
|
+
```css
|
|
270
|
+
/* Tool call container */
|
|
271
|
+
[data-hsafa-chat] div[style*="border-left"] {
|
|
272
|
+
border-left: 2px solid var(--hsafa-primary) !important;
|
|
273
|
+
background: var(--hsafa-accent);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/* Status badges */
|
|
277
|
+
[data-hsafa-chat] span[style*="padding: 2px"] {
|
|
278
|
+
border-radius: 4px;
|
|
279
|
+
font-weight: 500;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/* Error status */
|
|
283
|
+
[data-hsafa-chat] span[style*="color: #ef4444"] {
|
|
284
|
+
color: var(--hsafa-error) !important;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/* Success status */
|
|
288
|
+
[data-hsafa-chat] span[style*="color: #10b981"] {
|
|
289
|
+
color: var(--hsafa-success) !important;
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Error Messages
|
|
294
|
+
|
|
295
|
+
```css
|
|
296
|
+
/* Error banner */
|
|
297
|
+
[data-hsafa-chat] div[style*="backgroundColor"][style*="#ef4444"] {
|
|
298
|
+
background: var(--hsafa-error) !important;
|
|
299
|
+
border-radius: 8px;
|
|
300
|
+
padding: 12px 16px;
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Floating Button
|
|
305
|
+
|
|
306
|
+
```css
|
|
307
|
+
/* Floating chat button */
|
|
308
|
+
button[style*="position: fixed"][style*="z-index: 1000"] {
|
|
309
|
+
background: var(--hsafa-primary) !important;
|
|
310
|
+
box-shadow: 0 8px 24px rgba(0,0,0,0.3) !important;
|
|
311
|
+
width: 60px !important;
|
|
312
|
+
height: 60px !important;
|
|
313
|
+
border-radius: 50% !important;
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## Common Customizations
|
|
320
|
+
|
|
321
|
+
### Change Input Background
|
|
322
|
+
|
|
323
|
+
```css
|
|
324
|
+
/* Make input background transparent */
|
|
325
|
+
[data-hsafa-chat] textarea {
|
|
326
|
+
background: transparent !important;
|
|
327
|
+
border: 2px solid var(--hsafa-border) !important;
|
|
328
|
+
}
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Custom Message Bubbles
|
|
332
|
+
|
|
333
|
+
```css
|
|
334
|
+
/* Rounded message bubbles */
|
|
335
|
+
[data-hsafa-chat] [style*="margin-bottom"] > div > div {
|
|
336
|
+
border-radius: 16px !important;
|
|
337
|
+
padding: 12px 16px !important;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/* User message bubble */
|
|
341
|
+
[data-hsafa-chat] div[style*="align-items: flex-end"] > div {
|
|
342
|
+
background: var(--hsafa-primary) !important;
|
|
343
|
+
color: white !important;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/* Assistant message bubble */
|
|
347
|
+
[data-hsafa-chat] div[style*="align-items: flex-start"] > div {
|
|
348
|
+
background: var(--hsafa-card-bg) !important;
|
|
349
|
+
border: 1px solid var(--hsafa-border);
|
|
350
|
+
}
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### Custom Fonts
|
|
354
|
+
|
|
355
|
+
```css
|
|
356
|
+
/* Apply custom font family */
|
|
357
|
+
[data-hsafa-chat] {
|
|
358
|
+
font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/* Input specific font */
|
|
362
|
+
[data-hsafa-chat] textarea {
|
|
363
|
+
font-family: 'Inter', sans-serif !important;
|
|
364
|
+
font-size: 15px !important;
|
|
365
|
+
}
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### Compact Mode
|
|
369
|
+
|
|
370
|
+
```css
|
|
371
|
+
/* Reduce spacing for compact layout */
|
|
372
|
+
[data-hsafa-chat] {
|
|
373
|
+
--spacing-scale: 0.75;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
[data-hsafa-chat] div[style*="padding"] {
|
|
377
|
+
padding: calc(12px * var(--spacing-scale)) !important;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
[data-hsafa-chat] div[style*="margin"] {
|
|
381
|
+
margin: calc(8px * var(--spacing-scale)) !important;
|
|
382
|
+
}
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### Glassmorphism Effect
|
|
386
|
+
|
|
387
|
+
```css
|
|
388
|
+
/* Glass effect for panel */
|
|
389
|
+
[data-hsafa-chat="panel"] {
|
|
390
|
+
backdrop-filter: blur(20px) !important;
|
|
391
|
+
background: rgba(11, 11, 15, 0.8) !important;
|
|
392
|
+
border: 1px solid rgba(255, 255, 255, 0.1) !important;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
[data-hsafa-theme="dark"][data-hsafa-chat] textarea {
|
|
396
|
+
background: rgba(23, 24, 28, 0.6) !important;
|
|
397
|
+
backdrop-filter: blur(10px) !important;
|
|
398
|
+
}
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## Theme-Aware Styling
|
|
404
|
+
|
|
405
|
+
### Conditional Styling by Theme
|
|
406
|
+
|
|
407
|
+
```css
|
|
408
|
+
/* Dark theme styles */
|
|
409
|
+
[data-hsafa-theme="dark"] {
|
|
410
|
+
--hsafa-input-bg: #1a1b1f;
|
|
411
|
+
--hsafa-card-bg: #0d0e11;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/* Light theme styles */
|
|
415
|
+
[data-hsafa-theme="light"] {
|
|
416
|
+
--hsafa-input-bg: #f8f9fa;
|
|
417
|
+
--hsafa-card-bg: #ffffff;
|
|
418
|
+
--hsafa-border: #e1e4e8;
|
|
419
|
+
}
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### Using CSS Custom Properties
|
|
423
|
+
|
|
424
|
+
```css
|
|
425
|
+
/* Define theme-specific values */
|
|
426
|
+
[data-hsafa-theme="dark"] {
|
|
427
|
+
--message-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
|
|
428
|
+
--message-border: rgba(255, 255, 255, 0.1);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
[data-hsafa-theme="light"] {
|
|
432
|
+
--message-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
433
|
+
--message-border: rgba(0, 0, 0, 0.1);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/* Apply them */
|
|
437
|
+
[data-hsafa-chat] div[style*="margin-bottom"] > div {
|
|
438
|
+
box-shadow: var(--message-shadow) !important;
|
|
439
|
+
border: 1px solid var(--message-border) !important;
|
|
440
|
+
}
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
---
|
|
444
|
+
|
|
445
|
+
## Advanced Examples
|
|
446
|
+
|
|
447
|
+
### Brand Customization
|
|
448
|
+
|
|
449
|
+
```tsx
|
|
450
|
+
<HsafaChat
|
|
451
|
+
agentId="brand-agent"
|
|
452
|
+
primaryColor="#6366f1"
|
|
453
|
+
customStyles={`
|
|
454
|
+
/* Brand colors */
|
|
455
|
+
[data-hsafa-agent-id="brand-agent"] {
|
|
456
|
+
--hsafa-primary: #6366f1;
|
|
457
|
+
--hsafa-accent: #eef2ff;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/* Custom gradients */
|
|
461
|
+
[data-hsafa-agent-id="brand-agent"] button[aria-label="Send"] {
|
|
462
|
+
background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%) !important;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/* Brand fonts */
|
|
466
|
+
[data-hsafa-agent-id="brand-agent"] {
|
|
467
|
+
font-family: 'Poppins', sans-serif;
|
|
468
|
+
}
|
|
469
|
+
`}
|
|
470
|
+
/>
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
### Minimal UI
|
|
474
|
+
|
|
475
|
+
```tsx
|
|
476
|
+
<HsafaChat
|
|
477
|
+
agentId="minimal-agent"
|
|
478
|
+
customStyles={`
|
|
479
|
+
/* Hide borders */
|
|
480
|
+
[data-hsafa-chat] * {
|
|
481
|
+
border: none !important;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/* Minimal input */
|
|
485
|
+
[data-hsafa-chat] textarea {
|
|
486
|
+
background: transparent !important;
|
|
487
|
+
padding: 8px 0 !important;
|
|
488
|
+
border-bottom: 1px solid var(--hsafa-border) !important;
|
|
489
|
+
border-radius: 0 !important;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/* Simple messages */
|
|
493
|
+
[data-hsafa-chat] [style*="margin-bottom"] > div > div {
|
|
494
|
+
background: transparent !important;
|
|
495
|
+
padding: 8px 0 !important;
|
|
496
|
+
}
|
|
497
|
+
`}
|
|
498
|
+
/>
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
### Animated Interactions
|
|
502
|
+
|
|
503
|
+
```tsx
|
|
504
|
+
<HsafaChat
|
|
505
|
+
agentId="animated-agent"
|
|
506
|
+
customStyles={`
|
|
507
|
+
/* Smooth transitions */
|
|
508
|
+
[data-hsafa-chat] * {
|
|
509
|
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/* Button hover effects */
|
|
513
|
+
[data-hsafa-chat] button:hover {
|
|
514
|
+
transform: translateY(-2px);
|
|
515
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/* Message fade in */
|
|
519
|
+
[data-hsafa-chat] [style*="margin-bottom"] {
|
|
520
|
+
animation: fadeInUp 0.3s ease-out;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
@keyframes fadeInUp {
|
|
524
|
+
from {
|
|
525
|
+
opacity: 0;
|
|
526
|
+
transform: translateY(10px);
|
|
527
|
+
}
|
|
528
|
+
to {
|
|
529
|
+
opacity: 1;
|
|
530
|
+
transform: translateY(0);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
`}
|
|
534
|
+
/>
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
### Scrollbar Styling
|
|
538
|
+
|
|
539
|
+
```tsx
|
|
540
|
+
<HsafaChat
|
|
541
|
+
agentId="scrollbar-agent"
|
|
542
|
+
customStyles={`
|
|
543
|
+
/* Custom scrollbar for dark theme */
|
|
544
|
+
[data-hsafa-theme="dark"] ::-webkit-scrollbar {
|
|
545
|
+
width: 8px;
|
|
546
|
+
height: 8px;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
[data-hsafa-theme="dark"] ::-webkit-scrollbar-track {
|
|
550
|
+
background: var(--hsafa-accent);
|
|
551
|
+
border-radius: 4px;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
[data-hsafa-theme="dark"] ::-webkit-scrollbar-thumb {
|
|
555
|
+
background: var(--hsafa-border);
|
|
556
|
+
border-radius: 4px;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
[data-hsafa-theme="dark"] ::-webkit-scrollbar-thumb:hover {
|
|
560
|
+
background: var(--hsafa-muted-text);
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/* Custom scrollbar for light theme */
|
|
564
|
+
[data-hsafa-theme="light"] ::-webkit-scrollbar-thumb {
|
|
565
|
+
background: #cbd5e1;
|
|
566
|
+
}
|
|
567
|
+
`}
|
|
568
|
+
/>
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
---
|
|
572
|
+
|
|
573
|
+
## Tips & Best Practices
|
|
574
|
+
|
|
575
|
+
### 1. Use `!important` Sparingly
|
|
576
|
+
Only use `!important` when necessary to override inline styles. Prefer using more specific selectors.
|
|
577
|
+
|
|
578
|
+
### 2. Leverage CSS Variables
|
|
579
|
+
Always use CSS variables for colors to maintain theme consistency:
|
|
580
|
+
```css
|
|
581
|
+
/* Good */
|
|
582
|
+
background: var(--hsafa-primary);
|
|
583
|
+
|
|
584
|
+
/* Avoid */
|
|
585
|
+
background: #4D78FF;
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
### 3. Test Both Themes
|
|
589
|
+
Always test your customizations in both dark and light themes:
|
|
590
|
+
```tsx
|
|
591
|
+
<HsafaChat theme="dark" customStyles={yourStyles} />
|
|
592
|
+
<HsafaChat theme="light" customStyles={yourStyles} />
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
### 4. Scope Your Styles
|
|
596
|
+
Use data attributes to prevent affecting other components:
|
|
597
|
+
```css
|
|
598
|
+
/* Scoped to specific agent */
|
|
599
|
+
[data-hsafa-agent-id="your-agent"] {
|
|
600
|
+
/* Your styles */
|
|
601
|
+
}
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
### 5. Responsive Design
|
|
605
|
+
Consider mobile views:
|
|
606
|
+
```css
|
|
607
|
+
@media (max-width: 768px) {
|
|
608
|
+
[data-hsafa-chat] {
|
|
609
|
+
/* Mobile-specific styles */
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
---
|
|
615
|
+
|
|
616
|
+
## Debugging Styles
|
|
617
|
+
|
|
618
|
+
### Inspect Elements
|
|
619
|
+
Use browser DevTools to inspect elements and find their current styles.
|
|
620
|
+
|
|
621
|
+
### View Applied Variables
|
|
622
|
+
Check computed CSS variables in DevTools:
|
|
623
|
+
```javascript
|
|
624
|
+
getComputedStyle(document.documentElement).getPropertyValue('--hsafa-primary')
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
### Override Check
|
|
628
|
+
If styles aren't applying, check specificity:
|
|
629
|
+
```css
|
|
630
|
+
/* Lower specificity */
|
|
631
|
+
div { color: red; }
|
|
632
|
+
|
|
633
|
+
/* Higher specificity */
|
|
634
|
+
[data-hsafa-chat] div { color: blue; }
|
|
635
|
+
|
|
636
|
+
/* Highest (avoid) */
|
|
637
|
+
div { color: green !important; }
|
|
638
|
+
```
|
|
639
|
+
|
|
640
|
+
---
|
|
641
|
+
|
|
642
|
+
## Need Help?
|
|
643
|
+
|
|
644
|
+
- **Documentation**: [SDK Docs](../README.md)
|
|
645
|
+
- **Examples**: [examples/](../examples/)
|
|
646
|
+
- **Issues**: [GitHub Issues](https://github.com/husamabusafa/hsafa/issues)
|
|
647
|
+
|
|
648
|
+
---
|
|
649
|
+
|
|
650
|
+
**Version**: Compatible with @hsafa/ui-sdk v0.6.2+
|
package/docs/README.md
CHANGED
|
@@ -108,6 +108,7 @@ Important props (selected):
|
|
|
108
108
|
- `dir?: 'ltr' | 'rtl'` — controls layout RTL/LTR
|
|
109
109
|
- **Base colors** (override theme defaults): `primaryColor`, `backgroundColor`, `borderColor`, `textColor`, `accentColor`
|
|
110
110
|
- **Status colors** (new in v0.6.2): `errorColor`, `errorColorLight`, `errorColorDark`, `successColor`, `successColorLight`, `warningColor`, `warningColorLight`, `infoColor`, `infoColorLight`, `dangerColor`, `dangerColorLight`, `dangerColorDark`
|
|
111
|
+
- **CSS customization** (new in v0.6.2): `customStyles` - Inject custom CSS with access to CSS variables. See [CSS Guide](./HSAFA_CHAT_CSS_GUIDE.md)
|
|
111
112
|
- Layout: `width` (default 420), `height` (default `100vh`), `floatingButtonPosition`, `alwaysOpen`, `defaultOpen`, `expandable`, `maximized`
|
|
112
113
|
- Borders/animation: `enableBorderAnimation`, `enableContentPadding`, `enableContentBorder`, `borderRadius`
|
|
113
114
|
- UX copy: `placeholder`, `title`
|
|
@@ -180,6 +181,8 @@ Example of a single final item payload (simplified):
|
|
|
180
181
|
|
|
181
182
|
Theme presets (`light`/`dark`) with overridable colors. See `sdk/src/utils/chat-theme.ts`.
|
|
182
183
|
|
|
184
|
+
**📚 For advanced CSS customization, see [CSS Customization Guide](./HSAFA_CHAT_CSS_GUIDE.md)**
|
|
185
|
+
|
|
183
186
|
### Base Colors
|
|
184
187
|
- `primaryColor`, `backgroundColor`, `borderColor`, `textColor`, `accentColor`
|
|
185
188
|
- Derived: `mutedTextColor`, `inputBackground`, `cardBackground`, `hoverBackground`
|
|
@@ -213,6 +216,39 @@ Example with custom colors:
|
|
|
213
216
|
/>
|
|
214
217
|
```
|
|
215
218
|
|
|
219
|
+
### CSS Customization (v0.6.2+)
|
|
220
|
+
|
|
221
|
+
For complete control over component styling, use `customStyles` to inject custom CSS with access to theme-aware CSS variables:
|
|
222
|
+
|
|
223
|
+
```tsx
|
|
224
|
+
<HsafaChat
|
|
225
|
+
agentId="my-agent"
|
|
226
|
+
customStyles={`
|
|
227
|
+
/* Change input background */
|
|
228
|
+
[data-hsafa-chat] textarea {
|
|
229
|
+
background: var(--hsafa-input-bg) !important;
|
|
230
|
+
border-radius: 12px !important;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/* Custom message bubbles */
|
|
234
|
+
[data-hsafa-chat] div[style*="margin-bottom"] > div {
|
|
235
|
+
border-radius: 16px !important;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/* Theme-specific styles */
|
|
239
|
+
[data-hsafa-theme="dark"] {
|
|
240
|
+
--hsafa-input-bg: #1a1b1f;
|
|
241
|
+
}
|
|
242
|
+
`}
|
|
243
|
+
/>
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
See the complete [CSS Customization Guide](./HSAFA_CHAT_CSS_GUIDE.md) for:
|
|
247
|
+
- All available CSS variables
|
|
248
|
+
- Component selectors reference
|
|
249
|
+
- Theme-aware styling patterns
|
|
250
|
+
- Common customization examples
|
|
251
|
+
|
|
216
252
|
Markdown with Mermaid is supported via `MarkdownRenderer` / `MarkdownRendererWithMermaid` and `MermaidDiagram`.
|
|
217
253
|
|
|
218
254
|
---
|