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 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
- ## Example
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
@@ -1,6 +1,8 @@
1
1
  export interface InitOptions {
2
2
  subdomain: string;
3
3
  apiUrl?: string;
4
+ widgetShape?: 'circle' | 'rounded-square';
5
+ widgetSize?: 'small' | 'medium' | 'large';
4
6
  [key: string]: any;
5
7
  }
6
8
 
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ragged-chat-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Official SDK for integrating Ragged Chatbots into your website.",
5
5
  "type": "module",
6
6
  "main": "index.js",