image-salon-sdk 1.0.7 → 1.0.9
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 +92 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# image-salon-sdk
|
|
2
|
+
|
|
3
|
+
library to upload images
|
|
4
|
+
|
|
5
|
+
# Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install image-salon-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
import ImageSalon, { ImageUploadResponse } from "image-salon-sdk";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
# React implementation
|
|
16
|
+
|
|
17
|
+
```typescript jsx
|
|
18
|
+
const imageSalon = new ImageSalon({
|
|
19
|
+
folderName: "livestream-cms",
|
|
20
|
+
handleUpload: () => {
|
|
21
|
+
handleImageUpload();
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
imageSalon._init();
|
|
27
|
+
imageSalon.create({
|
|
28
|
+
imageUploadMainContainerId: "example",
|
|
29
|
+
});
|
|
30
|
+
}, []);
|
|
31
|
+
|
|
32
|
+
const handleImageUpload = () => {
|
|
33
|
+
imageSalon._upload().then((res: ImageUploadResponse[]) => {
|
|
34
|
+
// rest of the code
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return <div id="example" />;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
# Svelte implementation
|
|
42
|
+
|
|
43
|
+
```typescript svelte
|
|
44
|
+
---
|
|
45
|
+
**NOTE**
|
|
46
|
+
server-side rendering needs to be disabled
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
import {onMount} from "svelte"
|
|
50
|
+
|
|
51
|
+
onMount(() => {
|
|
52
|
+
if (typeof window === undefined || typeof document === undefined) return;
|
|
53
|
+
imageSalon._init();
|
|
54
|
+
imageSalon.create({
|
|
55
|
+
imageUploadMainContainerId: 'image-upload-main'
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
parameters for ImageUpload class
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
folderName: string; // folder name to upload file
|
|
64
|
+
handleUpload: () => void; //callback to handle upload event on click.
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
parameters for create method
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
imageUploadMainContainerId: string; //id of the container where you want to load message snippet.
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
upload response
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
key: string;
|
|
77
|
+
name: string;
|
|
78
|
+
folderName: string;
|
|
79
|
+
nestedFolderName: string;
|
|
80
|
+
url: string;
|
|
81
|
+
thumborUrl: string;
|
|
82
|
+
proxyUrl: string;
|
|
83
|
+
type: number;
|
|
84
|
+
metadata: {
|
|
85
|
+
height: number;
|
|
86
|
+
width: number;
|
|
87
|
+
backgroundColor: string;
|
|
88
|
+
aspectRatio: number;
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
# React implementation
|