@changebot/widgets-react 0.0.6 → 0.0.8
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 +572 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
# @changebot/widgets-react
|
|
2
|
+
|
|
3
|
+
React wrapper components for [Changebot](https://www.changebot.ai) - beautiful, customizable widgets for displaying product updates and changelogs to your users.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @changebot/widgets-react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Peer Dependencies
|
|
12
|
+
|
|
13
|
+
This package requires React 16.8.0 or later:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install react react-dom
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import {
|
|
23
|
+
ChangebotProvider,
|
|
24
|
+
ChangebotBadge,
|
|
25
|
+
ChangebotPanel
|
|
26
|
+
} from '@changebot/widgets-react';
|
|
27
|
+
|
|
28
|
+
function App() {
|
|
29
|
+
return (
|
|
30
|
+
<ChangebotProvider slug="your-team-slug">
|
|
31
|
+
<header>
|
|
32
|
+
<h1>My App</h1>
|
|
33
|
+
<ChangebotBadge />
|
|
34
|
+
</header>
|
|
35
|
+
|
|
36
|
+
<ChangebotPanel mode="drawer-right" />
|
|
37
|
+
</ChangebotProvider>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Components
|
|
43
|
+
|
|
44
|
+
### ChangebotProvider
|
|
45
|
+
|
|
46
|
+
The provider component manages state and data fetching for all child Changebot components. Wrap your components with this provider to enable automatic updates and state synchronization.
|
|
47
|
+
|
|
48
|
+
#### Props
|
|
49
|
+
|
|
50
|
+
| Prop | Type | Default | Description |
|
|
51
|
+
|------|------|---------|-------------|
|
|
52
|
+
| `slug` | `string` | required | Your Changebot team slug (from your Changebot dashboard) |
|
|
53
|
+
| `scope` | `string` | `"default"` | Scope identifier for isolating multiple instances |
|
|
54
|
+
| `children` | `ReactNode` | required | Child components |
|
|
55
|
+
|
|
56
|
+
#### Example
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
<ChangebotProvider slug="acme-corp">
|
|
60
|
+
{/* Your components */}
|
|
61
|
+
</ChangebotProvider>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
#### Multiple Instances
|
|
65
|
+
|
|
66
|
+
Use different scopes to run multiple independent instances:
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
<div>
|
|
70
|
+
<ChangebotProvider slug="team-a" scope="team-a">
|
|
71
|
+
<ChangebotBadge scope="team-a" />
|
|
72
|
+
<ChangebotPanel scope="team-a" />
|
|
73
|
+
</ChangebotProvider>
|
|
74
|
+
|
|
75
|
+
<ChangebotProvider slug="team-b" scope="team-b">
|
|
76
|
+
<ChangebotBadge scope="team-b" />
|
|
77
|
+
<ChangebotPanel scope="team-b" />
|
|
78
|
+
</ChangebotProvider>
|
|
79
|
+
</div>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
### ChangebotBadge
|
|
85
|
+
|
|
86
|
+
A badge component that displays the count of new, unread updates. Clicking the badge opens the associated panel.
|
|
87
|
+
|
|
88
|
+
#### Props
|
|
89
|
+
|
|
90
|
+
| Prop | Type | Default | Description |
|
|
91
|
+
|------|------|---------|-------------|
|
|
92
|
+
| `scope` | `string` | `"default"` | Scope to connect to (must match provider scope) |
|
|
93
|
+
| `showCount` | `boolean` | `true` | Whether to display the numeric count |
|
|
94
|
+
| `theme` | `Theme` | - | Fixed theme (see Theming section) |
|
|
95
|
+
| `light` | `Theme` | - | Theme for light mode (auto-switches based on system preference) |
|
|
96
|
+
| `dark` | `Theme` | - | Theme for dark mode (auto-switches based on system preference) |
|
|
97
|
+
|
|
98
|
+
#### Example
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
// Basic usage
|
|
102
|
+
<ChangebotBadge />
|
|
103
|
+
|
|
104
|
+
// With theme
|
|
105
|
+
<ChangebotBadge theme="catppuccin-mocha" />
|
|
106
|
+
|
|
107
|
+
// Auto-switching theme
|
|
108
|
+
<ChangebotBadge
|
|
109
|
+
light="catppuccin-latte"
|
|
110
|
+
dark="catppuccin-mocha"
|
|
111
|
+
/>
|
|
112
|
+
|
|
113
|
+
// Hidden count (shows dot only)
|
|
114
|
+
<ChangebotBadge showCount={false} />
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
### ChangebotPanel
|
|
120
|
+
|
|
121
|
+
A panel component that displays your product updates. Can be displayed as a drawer (left/right) or centered modal.
|
|
122
|
+
|
|
123
|
+
#### Props
|
|
124
|
+
|
|
125
|
+
| Prop | Type | Default | Description |
|
|
126
|
+
|------|------|---------|-------------|
|
|
127
|
+
| `scope` | `string` | `"default"` | Scope to connect to (must match provider scope) |
|
|
128
|
+
| `mode` | `"drawer-left"` \| `"drawer-right"` \| `"modal"` | `"drawer-right"` | Display mode |
|
|
129
|
+
| `theme` | `Theme` | - | Fixed theme (see Theming section) |
|
|
130
|
+
| `light` | `Theme` | - | Theme for light mode (auto-switches based on system preference) |
|
|
131
|
+
| `dark` | `Theme` | - | Theme for dark mode (auto-switches based on system preference) |
|
|
132
|
+
|
|
133
|
+
#### Methods
|
|
134
|
+
|
|
135
|
+
Use refs to access methods:
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
const panelRef = useRef<HTMLChangebotPanelElement>(null);
|
|
139
|
+
|
|
140
|
+
// Open the panel
|
|
141
|
+
await panelRef.current?.open();
|
|
142
|
+
|
|
143
|
+
// Close the panel
|
|
144
|
+
await panelRef.current?.close();
|
|
145
|
+
|
|
146
|
+
// Set updates programmatically (for standalone usage)
|
|
147
|
+
await panelRef.current?.setUpdates(updatesArray);
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
#### Example
|
|
151
|
+
|
|
152
|
+
```tsx
|
|
153
|
+
import { useRef } from 'react';
|
|
154
|
+
import { ChangebotPanel } from '@changebot/widgets-react';
|
|
155
|
+
|
|
156
|
+
function App() {
|
|
157
|
+
const panelRef = useRef<HTMLChangebotPanelElement>(null);
|
|
158
|
+
|
|
159
|
+
const handleOpenPanel = async () => {
|
|
160
|
+
await panelRef.current?.open();
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
<>
|
|
165
|
+
<button onClick={handleOpenPanel}>Show Updates</button>
|
|
166
|
+
<ChangebotPanel
|
|
167
|
+
ref={panelRef}
|
|
168
|
+
mode="drawer-right"
|
|
169
|
+
theme="nord"
|
|
170
|
+
/>
|
|
171
|
+
</>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
### ChangebotBanner
|
|
179
|
+
|
|
180
|
+
A banner component that displays a highlighted update at the top of your page. Automatically shows the most recent update marked with `highlight_target="banner"`.
|
|
181
|
+
|
|
182
|
+
#### Props
|
|
183
|
+
|
|
184
|
+
| Prop | Type | Default | Description |
|
|
185
|
+
|------|------|---------|-------------|
|
|
186
|
+
| `scope` | `string` | `"default"` | Scope to connect to (must match provider scope) |
|
|
187
|
+
| `theme` | `Theme` | - | Fixed theme (see Theming section) |
|
|
188
|
+
| `light` | `Theme` | - | Theme for light mode (auto-switches based on system preference) |
|
|
189
|
+
| `dark` | `Theme` | - | Theme for dark mode (auto-switches based on system preference) |
|
|
190
|
+
|
|
191
|
+
#### Methods
|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
const bannerRef = useRef<HTMLChangebotBannerElement>(null);
|
|
195
|
+
|
|
196
|
+
// Show banner with specific update
|
|
197
|
+
await bannerRef.current?.show(update);
|
|
198
|
+
|
|
199
|
+
// Dismiss the banner
|
|
200
|
+
await bannerRef.current?.dismiss();
|
|
201
|
+
|
|
202
|
+
// Toggle expanded state
|
|
203
|
+
await bannerRef.current?.toggle();
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
#### Example
|
|
207
|
+
|
|
208
|
+
```tsx
|
|
209
|
+
<ChangebotBanner
|
|
210
|
+
theme="dracula"
|
|
211
|
+
/>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
### ChangebotToast
|
|
217
|
+
|
|
218
|
+
A toast notification component that displays brief update notifications. Automatically shows the most recent update marked with `highlight_target="toast"`.
|
|
219
|
+
|
|
220
|
+
#### Props
|
|
221
|
+
|
|
222
|
+
| Prop | Type | Default | Description |
|
|
223
|
+
|------|------|---------|-------------|
|
|
224
|
+
| `scope` | `string` | `"default"` | Scope to connect to (must match provider scope) |
|
|
225
|
+
| `position` | `"top-left"` \| `"top-right"` \| `"bottom-left"` \| `"bottom-right"` | `"bottom-right"` | Screen position for the toast |
|
|
226
|
+
| `autoDismiss` | `number` | - | Auto-dismiss after N seconds (optional) |
|
|
227
|
+
| `theme` | `Theme` | - | Fixed theme (see Theming section) |
|
|
228
|
+
| `light` | `Theme` | - | Theme for light mode (auto-switches based on system preference) |
|
|
229
|
+
| `dark` | `Theme` | - | Theme for dark mode (auto-switches based on system preference) |
|
|
230
|
+
|
|
231
|
+
#### Methods
|
|
232
|
+
|
|
233
|
+
```tsx
|
|
234
|
+
const toastRef = useRef<HTMLChangebotToastElement>(null);
|
|
235
|
+
|
|
236
|
+
// Show toast with specific update
|
|
237
|
+
await toastRef.current?.show(update);
|
|
238
|
+
|
|
239
|
+
// Dismiss the toast
|
|
240
|
+
await toastRef.current?.dismiss();
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
#### Example
|
|
244
|
+
|
|
245
|
+
```tsx
|
|
246
|
+
<ChangebotToast
|
|
247
|
+
position="bottom-right"
|
|
248
|
+
autoDismiss={5}
|
|
249
|
+
theme="tokyo-night"
|
|
250
|
+
/>
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Theming
|
|
256
|
+
|
|
257
|
+
Changebot widgets include 15 beautiful pre-built themes:
|
|
258
|
+
|
|
259
|
+
### Available Themes
|
|
260
|
+
|
|
261
|
+
- **Catppuccin**: `catppuccin-latte` (light), `catppuccin-frappe`, `catppuccin-macchiato`, `catppuccin-mocha` (dark)
|
|
262
|
+
- **Gruvbox**: `gruvbox-light`, `gruvbox-dark`
|
|
263
|
+
- **Popular**: `dracula`, `nord`, `tokyo-night`, `cyberpunk`
|
|
264
|
+
- **Solarized**: `solarized-light`, `solarized-dark`
|
|
265
|
+
- **Everforest**: `everforest-light`, `everforest-dark`
|
|
266
|
+
- **Modern**: `frost` (clean, minimal light theme)
|
|
267
|
+
|
|
268
|
+
### Using Themes
|
|
269
|
+
|
|
270
|
+
#### Fixed Theme
|
|
271
|
+
|
|
272
|
+
Use the `theme` prop for a theme that never changes:
|
|
273
|
+
|
|
274
|
+
```tsx
|
|
275
|
+
<ChangebotPanel theme="catppuccin-mocha" />
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
#### Auto-Switching Theme
|
|
279
|
+
|
|
280
|
+
Use `light` and `dark` props to automatically switch based on user's system preference:
|
|
281
|
+
|
|
282
|
+
```tsx
|
|
283
|
+
<ChangebotPanel
|
|
284
|
+
light="catppuccin-latte"
|
|
285
|
+
dark="catppuccin-mocha"
|
|
286
|
+
/>
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
#### Apply to All Components
|
|
290
|
+
|
|
291
|
+
```tsx
|
|
292
|
+
<ChangebotProvider slug="acme">
|
|
293
|
+
<ChangebotBadge
|
|
294
|
+
light="gruvbox-light"
|
|
295
|
+
dark="gruvbox-dark"
|
|
296
|
+
/>
|
|
297
|
+
<ChangebotPanel
|
|
298
|
+
light="gruvbox-light"
|
|
299
|
+
dark="gruvbox-dark"
|
|
300
|
+
/>
|
|
301
|
+
<ChangebotBanner
|
|
302
|
+
light="gruvbox-light"
|
|
303
|
+
dark="gruvbox-dark"
|
|
304
|
+
/>
|
|
305
|
+
<ChangebotToast
|
|
306
|
+
light="gruvbox-light"
|
|
307
|
+
dark="gruvbox-dark"
|
|
308
|
+
/>
|
|
309
|
+
</ChangebotProvider>
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## Display Modes
|
|
315
|
+
|
|
316
|
+
The `ChangebotPanel` component supports three display modes:
|
|
317
|
+
|
|
318
|
+
### drawer-right (default)
|
|
319
|
+
|
|
320
|
+
Slides in from the right side of the screen. Great for most applications.
|
|
321
|
+
|
|
322
|
+
```tsx
|
|
323
|
+
<ChangebotPanel mode="drawer-right" />
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### drawer-left
|
|
327
|
+
|
|
328
|
+
Slides in from the left side of the screen. Useful when your navigation is on the right.
|
|
329
|
+
|
|
330
|
+
```tsx
|
|
331
|
+
<ChangebotPanel mode="drawer-left" />
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### modal
|
|
335
|
+
|
|
336
|
+
Displays as a centered modal dialog with backdrop overlay. Best for focused, important updates.
|
|
337
|
+
|
|
338
|
+
```tsx
|
|
339
|
+
<ChangebotPanel mode="modal" />
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
|
|
344
|
+
## Advanced Usage
|
|
345
|
+
|
|
346
|
+
### Standalone Usage (Without Provider)
|
|
347
|
+
|
|
348
|
+
Components can work independently without a provider for simple use cases:
|
|
349
|
+
|
|
350
|
+
#### Standalone Badge
|
|
351
|
+
|
|
352
|
+
```tsx
|
|
353
|
+
import { ChangebotBadge } from '@changebot/widgets-react';
|
|
354
|
+
|
|
355
|
+
function Header() {
|
|
356
|
+
const [count, setCount] = useState(3);
|
|
357
|
+
|
|
358
|
+
return (
|
|
359
|
+
<ChangebotBadge count={count} showCount={true} />
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
#### Standalone Panel
|
|
365
|
+
|
|
366
|
+
```tsx
|
|
367
|
+
import { useRef, useState } from 'react';
|
|
368
|
+
import { ChangebotPanel } from '@changebot/widgets-react';
|
|
369
|
+
|
|
370
|
+
function Updates() {
|
|
371
|
+
const panelRef = useRef<HTMLChangebotPanelElement>(null);
|
|
372
|
+
|
|
373
|
+
const openWithUpdates = async () => {
|
|
374
|
+
await panelRef.current?.setUpdates([
|
|
375
|
+
{
|
|
376
|
+
id: 1,
|
|
377
|
+
title: 'New Feature',
|
|
378
|
+
content: '<p>Check out our new feature!</p>',
|
|
379
|
+
display_date: '2024-01-15',
|
|
380
|
+
published_at: '2024-01-15T10:00:00Z',
|
|
381
|
+
expires_on: null,
|
|
382
|
+
highlight_target: null,
|
|
383
|
+
hosted_url: null,
|
|
384
|
+
tags: [{ id: 1, name: 'Feature', color: '#3b82f6' }]
|
|
385
|
+
}
|
|
386
|
+
]);
|
|
387
|
+
await panelRef.current?.open();
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
return (
|
|
391
|
+
<>
|
|
392
|
+
<button onClick={openWithUpdates}>Show Updates</button>
|
|
393
|
+
<ChangebotPanel ref={panelRef} />
|
|
394
|
+
</>
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## Complete Examples
|
|
402
|
+
|
|
403
|
+
### Basic Setup with All Components
|
|
404
|
+
|
|
405
|
+
```tsx
|
|
406
|
+
import {
|
|
407
|
+
ChangebotProvider,
|
|
408
|
+
ChangebotBadge,
|
|
409
|
+
ChangebotPanel,
|
|
410
|
+
ChangebotBanner,
|
|
411
|
+
ChangebotToast
|
|
412
|
+
} from '@changebot/widgets-react';
|
|
413
|
+
|
|
414
|
+
function App() {
|
|
415
|
+
return (
|
|
416
|
+
<ChangebotProvider slug="acme-corp">
|
|
417
|
+
{/* Banner appears automatically for banner-highlighted updates */}
|
|
418
|
+
<ChangebotBanner theme="catppuccin-mocha" />
|
|
419
|
+
|
|
420
|
+
<header>
|
|
421
|
+
<h1>ACME Corp</h1>
|
|
422
|
+
{/* Badge shows count of new updates */}
|
|
423
|
+
<ChangebotBadge theme="catppuccin-mocha" />
|
|
424
|
+
</header>
|
|
425
|
+
|
|
426
|
+
<main>
|
|
427
|
+
{/* Your app content */}
|
|
428
|
+
</main>
|
|
429
|
+
|
|
430
|
+
{/* Panel opens when badge is clicked */}
|
|
431
|
+
<ChangebotPanel
|
|
432
|
+
mode="drawer-right"
|
|
433
|
+
theme="catppuccin-mocha"
|
|
434
|
+
/>
|
|
435
|
+
|
|
436
|
+
{/* Toast appears for toast-highlighted updates */}
|
|
437
|
+
<ChangebotToast
|
|
438
|
+
position="bottom-right"
|
|
439
|
+
autoDismiss={5}
|
|
440
|
+
theme="catppuccin-mocha"
|
|
441
|
+
/>
|
|
442
|
+
</ChangebotProvider>
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
### Responsive Theme Example
|
|
448
|
+
|
|
449
|
+
```tsx
|
|
450
|
+
import {
|
|
451
|
+
ChangebotProvider,
|
|
452
|
+
ChangebotBadge,
|
|
453
|
+
ChangebotPanel
|
|
454
|
+
} from '@changebot/widgets-react';
|
|
455
|
+
|
|
456
|
+
function App() {
|
|
457
|
+
// Automatically switches between light/dark based on system preference
|
|
458
|
+
return (
|
|
459
|
+
<ChangebotProvider slug="acme-corp">
|
|
460
|
+
<header>
|
|
461
|
+
<h1>My App</h1>
|
|
462
|
+
<ChangebotBadge
|
|
463
|
+
light="catppuccin-latte"
|
|
464
|
+
dark="catppuccin-mocha"
|
|
465
|
+
/>
|
|
466
|
+
</header>
|
|
467
|
+
|
|
468
|
+
<ChangebotPanel
|
|
469
|
+
mode="drawer-right"
|
|
470
|
+
light="catppuccin-latte"
|
|
471
|
+
dark="catppuccin-mocha"
|
|
472
|
+
/>
|
|
473
|
+
</ChangebotProvider>
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
### Multiple Scopes Example
|
|
479
|
+
|
|
480
|
+
```tsx
|
|
481
|
+
import {
|
|
482
|
+
ChangebotProvider,
|
|
483
|
+
ChangebotBadge,
|
|
484
|
+
ChangebotPanel
|
|
485
|
+
} from '@changebot/widgets-react';
|
|
486
|
+
|
|
487
|
+
function MultiTenantApp() {
|
|
488
|
+
return (
|
|
489
|
+
<div>
|
|
490
|
+
{/* Product Updates */}
|
|
491
|
+
<ChangebotProvider slug="product-updates" scope="product">
|
|
492
|
+
<section>
|
|
493
|
+
<h2>
|
|
494
|
+
Product News
|
|
495
|
+
<ChangebotBadge scope="product" theme="nord" />
|
|
496
|
+
</h2>
|
|
497
|
+
<ChangebotPanel scope="product" mode="drawer-right" theme="nord" />
|
|
498
|
+
</section>
|
|
499
|
+
</ChangebotProvider>
|
|
500
|
+
|
|
501
|
+
{/* Company Announcements */}
|
|
502
|
+
<ChangebotProvider slug="company-news" scope="company">
|
|
503
|
+
<section>
|
|
504
|
+
<h2>
|
|
505
|
+
Company Announcements
|
|
506
|
+
<ChangebotBadge scope="company" theme="dracula" />
|
|
507
|
+
</h2>
|
|
508
|
+
<ChangebotPanel scope="company" mode="drawer-left" theme="dracula" />
|
|
509
|
+
</section>
|
|
510
|
+
</ChangebotProvider>
|
|
511
|
+
</div>
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
### Programmatic Control Example
|
|
517
|
+
|
|
518
|
+
```tsx
|
|
519
|
+
import { useRef } from 'react';
|
|
520
|
+
import {
|
|
521
|
+
ChangebotProvider,
|
|
522
|
+
ChangebotPanel
|
|
523
|
+
} from '@changebot/widgets-react';
|
|
524
|
+
|
|
525
|
+
function App() {
|
|
526
|
+
const panelRef = useRef<HTMLChangebotPanelElement>(null);
|
|
527
|
+
|
|
528
|
+
const showUpdates = async () => {
|
|
529
|
+
await panelRef.current?.open();
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
const hideUpdates = async () => {
|
|
533
|
+
await panelRef.current?.close();
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
return (
|
|
537
|
+
<ChangebotProvider slug="acme-corp">
|
|
538
|
+
<div>
|
|
539
|
+
<button onClick={showUpdates}>Show Updates</button>
|
|
540
|
+
<button onClick={hideUpdates}>Hide Updates</button>
|
|
541
|
+
</div>
|
|
542
|
+
|
|
543
|
+
<ChangebotPanel ref={panelRef} mode="modal" />
|
|
544
|
+
</ChangebotProvider>
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
---
|
|
550
|
+
|
|
551
|
+
## TypeScript Support
|
|
552
|
+
|
|
553
|
+
This package includes TypeScript definitions out of the box. All components are fully typed.
|
|
554
|
+
|
|
555
|
+
```tsx
|
|
556
|
+
import type { HTMLChangebotPanelElement } from '@changebot/widgets-react';
|
|
557
|
+
|
|
558
|
+
const panelRef = useRef<HTMLChangebotPanelElement>(null);
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
---
|
|
562
|
+
|
|
563
|
+
## License
|
|
564
|
+
|
|
565
|
+
Apache-2.0
|
|
566
|
+
|
|
567
|
+
## Links
|
|
568
|
+
|
|
569
|
+
- [Changebot Website](https://www.changebot.ai)
|
|
570
|
+
- [Documentation](https://docs.changebot.ai)
|
|
571
|
+
- [GitHub Repository](https://github.com/changebot-ai/widgets)
|
|
572
|
+
- [NPM Package](https://www.npmjs.com/package/@changebot/widgets-react)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@changebot/widgets-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "React wrapper components for Changebot widgets",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@stencil/react-output-target": "^1.2.0",
|
|
17
|
-
"@changebot/core": "^0.0.
|
|
17
|
+
"@changebot/core": "^0.0.8"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/react": "^18.2.0",
|