@arbisoft/react-design-tool 1.0.1

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/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) [2025] [arbisoft]
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,236 @@
1
+
2
+ # 🎨 React Design Tool (by @arbisoft)
3
+
4
+ A React component for creating and editing designs with templates, images, and customizable elements.
5
+ A JavaScript framework for building your own Canva-like design editors.
6
+
7
+ With this tool, you can:
8
+
9
+ - Add and manipulate **shapes**, **images**, **QR codes**, and **text**
10
+ - Load and switch between **multiple templates**
11
+ - **Customize** and **edit elements** on the canvas
12
+ - **Save** the final design data and image output
13
+
14
+ Perfect for integrating into applications that require user-driven visual content creation.
15
+
16
+ ## 📦 Installation
17
+
18
+ ```bash
19
+ npm install @arbisoft/react-design-tool
20
+ ```
21
+ OR
22
+ ```bash
23
+ yarn add @arbisoft/react-design-tool
24
+
25
+ ```
26
+ #### Required Dependencies:
27
+ ```bash
28
+ npm install konva prop-types qrcode react-konva react-konva-utils styled-components
29
+ ```
30
+
31
+ OR
32
+ ```bash
33
+ yarn add konva prop-types qrcode react-konva react-konva-utils styled-components
34
+
35
+ ```
36
+ ## 🚀 Quick Start
37
+
38
+ ```jsx
39
+ import React, { useRef } from 'react';
40
+ import { Studio } from '@arbisoft/react-design-tool';
41
+
42
+ function MyComponent() {
43
+ const studioRef = useRef(null);
44
+
45
+ return (
46
+ <Studio
47
+ ref={studioRef}
48
+ defaultTemplatesList={[]}
49
+ customTemplatesList={[]}
50
+ defaultImages={[]}
51
+ customImages={[]}
52
+ uploadImageCallBack={async (file) => {
53
+ // Upload logic here
54
+ return 'url_of_uploaded_image';
55
+ }}
56
+ elementsList={[]}
57
+ qrLink={'http://example.com'}
58
+ disableWhiteLabel={true}
59
+ title={'New Title'}
60
+ styleProps={{
61
+ primaryColor: 'red',
62
+ }}
63
+ defaultText={'Your Default Text'}
64
+ onSave={async (data) => {
65
+ console.log('Saved data:', data);
66
+ }}
67
+ saveButtonText={'Save Progress'}
68
+ locale={'fr'}
69
+ />
70
+ );
71
+ }
72
+
73
+ export default MyComponent;
74
+ ```
75
+ ## Props Configuration
76
+
77
+ #### 1. `defaultTemplatesList` (Array of templates)
78
+ Pre-loaded default templates provided by the system.
79
+ **Format:** Array of template objects
80
+ **Example:**
81
+ ```js
82
+ defaultTemplatesList={[
83
+ {
84
+ title: 'Business Card',
85
+ image: 'url',
86
+ elements: [...]
87
+ }
88
+ ]}
89
+ ```
90
+ #### 2. `customTemplatesList` (Array of templates)
91
+ **Format:** Array of template objects
92
+ **Example:**
93
+ ```js
94
+ customTemplatesList={[
95
+ {
96
+ title: 'Custom template',
97
+ image: 'url',
98
+ elements: [...]
99
+ }
100
+ ]}
101
+ ```
102
+ #### 3. `defaultImages` (Array of URLs)
103
+ System-provided stock images.
104
+
105
+ **Format:** Array of image urls
106
+ **Example:**
107
+ ```js
108
+ defaultImages={[
109
+ "https://example.com/stock1.jpg",
110
+ "https://example.com/stock2.png"
111
+ ]}
112
+ ```
113
+ #### 4. `customImages` (Array of URLs)
114
+ User-uploaded or organization-specific images.
115
+
116
+ **Format:** Array of image urls
117
+ **Example:**
118
+ ```js
119
+ customImages={[
120
+ "https://example.com/stock1.jpg",
121
+ "https://example.com/stock2.png"
122
+ ]}
123
+ ```
124
+ #### 5. `uploadImageCallBack` (Async function)
125
+ User-defined function to handle file uploads and return a hosted URL.
126
+ By default, the component handles images as base64, which may not be ideal for storage.
127
+ To avoid large payloads and for better performance, it's recommended to upload the file and return the hosted URL.
128
+
129
+ **Example:**
130
+ ```js
131
+ uploadImageCallBack={async (file) => {
132
+ // Upload logic here
133
+ return 'https://yourcdn.com/uploaded-image.png';
134
+ }}
135
+ ```
136
+ #### 6. `elementsList` (Array of elements)
137
+ An array of design elements to be rendered on the canvas by default.
138
+ If you pass an `elementsList`, the Studio will initialize with these elements already placed on the canvas.
139
+
140
+ **Example:**
141
+ ```js
142
+ elementsList={[
143
+ {...},{...},{...}
144
+ ]}
145
+ ```
146
+ #### 7. `qrLink` (URL String)
147
+ A URL string used to generate a QR code element on the canvas.
148
+ When scanned, the QR will redirect to this link.
149
+
150
+ **Example:**
151
+ ```js
152
+ qrLink={'https://somelink.com'}
153
+ ```
154
+ #### 8. `disableWhiteLabel` (Boolean)
155
+ Boolean flag to hide the white-label (branding) section from the sidebar.
156
+ Set to `true` if you want to remove branding options from the sidebar.
157
+
158
+ **Example:**
159
+ ```js
160
+ disableWhiteLabel={true}
161
+ ```
162
+ #### 9. `title` (String)
163
+ Sets the title for the current template being edited in the Studio.
164
+
165
+ **Example:**
166
+ ```js
167
+ title={'New Title'}
168
+ ```
169
+ #### 10. `styleProps` (Object)
170
+ Use this to customize the styling of the Studio, including elements like the sidebar pills.
171
+ For example, by providing a `primaryColor`, you can change the color of the sidebar pills to match your branding color.
172
+
173
+ **Example:**
174
+ ```js
175
+ styleProps={{
176
+ primaryColor: 'red',
177
+ }}
178
+ ```
179
+ #### 11. `defaultText` (String)
180
+ Overrides the predefined text content in the text section of the Studio.
181
+ There is a list of predefined texts that can be added to the canvas by clicking on them, each with predefined fonts and styles.
182
+ By providing this prop, you can change the default content for these texts.
183
+
184
+ **Example:**
185
+ ```js
186
+ defaultText={'Your Default Text'}
187
+ ```
188
+ #### 12. `onSave` (Async function)
189
+ By providing this function, a "Save" Call-to-Action (CTA) button will appear in the Studio.
190
+ When the user clicks on this button, the function will be executed, and you will receive the current design data.
191
+ This data includes an array of elements and the image of the canvas. You can then use this data as needed, such as storing the elements and image.
192
+
193
+ **Example:**
194
+ ```js
195
+ onSave={async (data) => {
196
+ console.log('Saved data:', data);
197
+ // { elements: [array of elements],image:canvas image }
198
+ // You can store this data or perform any actions you'd like
199
+ }}
200
+ ```
201
+ #### 13. `saveButtonText` (String)
202
+ Overrides the text for the Call-to-Action (CTA) button that appears in the Studio.
203
+
204
+ **Example:**
205
+ ```js
206
+ saveButtonText={'Save Progress'}
207
+ ```
208
+ #### 14. `locale` (String)
209
+ Sets the locale for the Studio to provide multilingual support.
210
+ You can set the `locale` prop to one of the supported languages: `"fr"`, `"en"`, `"ru"`, `"pl"`, `"de"`, `"es"`, or `"it"`.
211
+ The default locale is `"en"`.
212
+
213
+ **Example:**
214
+ ```js
215
+ locale={'fr'}
216
+ ```
217
+ #### 15. `ref` (reference)
218
+ A reference to the `Studio` component.
219
+ ```js
220
+ const studioRef = useRef();
221
+
222
+ <Studio
223
+ ref={studioRef}
224
+ ...
225
+ />
226
+ ```
227
+ You can use this reference to call the `onSave` function whenever you want, and retrieve the updated elements and image of the canvas, along with any other data.
228
+
229
+ **Example:**
230
+ ```js
231
+ const handleSave = async () => {
232
+ const data = await studioRef?.current?.onSave();
233
+ console.log('Saved data:', data);
234
+ // { elements: [array of elements], image: canvas image }
235
+ };
236
+ ```
Binary file