ragged-chat-sdk 1.0.2 → 1.0.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/README.md +45 -2
- package/index.d.ts +2 -0
- package/index.js +53 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,14 +26,57 @@ init({
|
|
|
26
26
|
| --- | --- | --- |
|
|
27
27
|
| `subdomain` | `string` | **Required**. The unique subdomain of your chatbot. |
|
|
28
28
|
| `apiUrl` | `string` | Optional. The base URL of the Ragged API. Defaults to `https://ragflowdb.onrender.com/api`. |
|
|
29
|
+
| `widgetShape` | `'circle' \| 'rounded-square'` | Optional. The shape of the floating widget button. Defaults to `'circle'`. |
|
|
30
|
+
| `widgetSize` | `'small' \| 'medium' \| 'large'` | Optional. The size of the floating widget button. Defaults to `'medium'`. |
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
### Widget Customization
|
|
33
|
+
|
|
34
|
+
You can customize the appearance of the floating chat widget button:
|
|
35
|
+
|
|
36
|
+
**Shape Options:**
|
|
37
|
+
- `'circle'` - Circular button (default)
|
|
38
|
+
- `'rounded-square'` - Square button with rounded corners
|
|
39
|
+
|
|
40
|
+
**Size Options:**
|
|
41
|
+
- `'small'` - 48x48 pixels
|
|
42
|
+
- `'medium'` - 56x56 pixels (default)
|
|
43
|
+
- `'large'` - 68x68 pixels
|
|
44
|
+
|
|
45
|
+
## Examples
|
|
46
|
+
|
|
47
|
+
### Basic Setup
|
|
31
48
|
|
|
32
49
|
```javascript
|
|
33
50
|
import { init } from 'ragged-chat-sdk';
|
|
34
51
|
|
|
35
|
-
// Initialize the chatbot
|
|
52
|
+
// Initialize the chatbot with default settings
|
|
36
53
|
init({
|
|
37
54
|
subdomain: 'my-awesome-bot'
|
|
38
55
|
});
|
|
39
56
|
```
|
|
57
|
+
|
|
58
|
+
### Custom Widget Appearance
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
import { init } from 'ragged-chat-sdk';
|
|
62
|
+
|
|
63
|
+
// Large rounded square button
|
|
64
|
+
init({
|
|
65
|
+
subdomain: 'my-awesome-bot',
|
|
66
|
+
widgetShape: 'rounded-square',
|
|
67
|
+
widgetSize: 'large'
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Small Circular Button
|
|
72
|
+
|
|
73
|
+
```javascript
|
|
74
|
+
import { init } from 'ragged-chat-sdk';
|
|
75
|
+
|
|
76
|
+
// Small circular button
|
|
77
|
+
init({
|
|
78
|
+
subdomain: 'my-awesome-bot',
|
|
79
|
+
widgetShape: 'circle',
|
|
80
|
+
widgetSize: 'small'
|
|
81
|
+
});
|
|
82
|
+
```
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -4,6 +4,8 @@ export function init(config = {}) {
|
|
|
4
4
|
// Configuration
|
|
5
5
|
const API_URL = config.apiUrl || 'https://ragflowdb.onrender.com/api';
|
|
6
6
|
const subdomain = config.subdomain;
|
|
7
|
+
let widgetShape = config.widgetShape || 'circle'; // Fallback to circle
|
|
8
|
+
let widgetSize = config.widgetSize || 'medium'; // Fallback to medium
|
|
7
9
|
|
|
8
10
|
if (!subdomain) {
|
|
9
11
|
console.error('[Ragged SDK] Error: subdomain is required. Usage: Ragged.init({ subdomain: "your-subdomain" })');
|
|
@@ -535,10 +537,7 @@ export function init(config = {}) {
|
|
|
535
537
|
}
|
|
536
538
|
|
|
537
539
|
#ragged-toggle-btn {
|
|
538
|
-
width: 56px;
|
|
539
|
-
height: 56px;
|
|
540
540
|
border: none;
|
|
541
|
-
border-radius: 50%;
|
|
542
541
|
color: white;
|
|
543
542
|
cursor: pointer;
|
|
544
543
|
display: flex;
|
|
@@ -550,6 +549,31 @@ export function init(config = {}) {
|
|
|
550
549
|
overflow: hidden;
|
|
551
550
|
}
|
|
552
551
|
|
|
552
|
+
/* Size variations */
|
|
553
|
+
#ragged-toggle-btn.size-small {
|
|
554
|
+
width: 48px;
|
|
555
|
+
height: 48px;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
#ragged-toggle-btn.size-medium {
|
|
559
|
+
width: 56px;
|
|
560
|
+
height: 56px;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
#ragged-toggle-btn.size-large {
|
|
564
|
+
width: 68px;
|
|
565
|
+
height: 68px;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
/* Shape variations */
|
|
569
|
+
#ragged-toggle-btn.shape-circle {
|
|
570
|
+
border-radius: 50%;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
#ragged-toggle-btn.shape-rounded-square {
|
|
574
|
+
border-radius: 16px;
|
|
575
|
+
}
|
|
576
|
+
|
|
553
577
|
#ragged-toggle-btn:hover {
|
|
554
578
|
transform: scale(1.1);
|
|
555
579
|
}
|
|
@@ -784,6 +808,32 @@ export function init(config = {}) {
|
|
|
784
808
|
input.placeholder = chatConfig.settings?.placeholder || 'Type your message here...';
|
|
785
809
|
emptyTitle.textContent = chatConfig.settings?.welcomeMessage || 'How can I help you?';
|
|
786
810
|
|
|
811
|
+
// Apply widget shape and size customization
|
|
812
|
+
if (chatConfig.settings) {
|
|
813
|
+
// Prioritize backend settings if they exist, otherwise use init config
|
|
814
|
+
if (chatConfig.settings.widgetShape) widgetShape = chatConfig.settings.widgetShape;
|
|
815
|
+
if (chatConfig.settings.widgetSize) widgetSize = chatConfig.settings.widgetSize;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
if (toggleBtn) {
|
|
819
|
+
// Clear any existing shape/size classes
|
|
820
|
+
toggleBtn.classList.remove('shape-circle', 'shape-rounded-square', 'size-small', 'size-medium', 'size-large');
|
|
821
|
+
toggleBtn.classList.add(`shape-${widgetShape}`);
|
|
822
|
+
toggleBtn.classList.add(`size-${widgetSize}`);
|
|
823
|
+
|
|
824
|
+
// Also update icon sizing
|
|
825
|
+
const iconMessage = document.getElementById('ragged-icon-message');
|
|
826
|
+
const iconClose = document.getElementById('ragged-icon-close');
|
|
827
|
+
if (iconMessage) {
|
|
828
|
+
iconMessage.setAttribute('width', widgetSize === 'small' ? '24' : widgetSize === 'large' ? '32' : '28');
|
|
829
|
+
iconMessage.setAttribute('height', widgetSize === 'small' ? '24' : widgetSize === 'large' ? '32' : '28');
|
|
830
|
+
}
|
|
831
|
+
if (iconClose) {
|
|
832
|
+
iconClose.setAttribute('width', widgetSize === 'small' ? '24' : widgetSize === 'large' ? '32' : '28');
|
|
833
|
+
iconClose.setAttribute('height', widgetSize === 'small' ? '24' : widgetSize === 'large' ? '32' : '28');
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
|
|
787
837
|
// Set custom logo for all users (free platform)
|
|
788
838
|
if (chatConfig.settings?.brandLogo) {
|
|
789
839
|
const logoUrl = chatConfig.settings.brandLogo;
|