email-builder-pro 1.0.0
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/INTEGRATION.md +250 -0
- package/PUBLISH.md +116 -0
- package/README.md +158 -0
- package/app/globals.css +46 -0
- package/components/Canvas.tsx +78 -0
- package/components/ComponentPalette.tsx +297 -0
- package/components/ComponentRenderer.tsx +496 -0
- package/components/DraggableComponent.tsx +84 -0
- package/components/DroppableComponent.tsx +80 -0
- package/components/EmailBuilder.tsx +59 -0
- package/components/ImageUpload.tsx +186 -0
- package/components/NumberInput.tsx +73 -0
- package/components/PreviewPanel.tsx +125 -0
- package/components/PropertiesPanel.tsx +1386 -0
- package/components/TemplateManager.tsx +104 -0
- package/components/Toolbar.tsx +242 -0
- package/lib/store.ts +198 -0
- package/package.json +76 -0
- package/postcss.config.js +8 -0
- package/src/index.tsx +42 -0
- package/tailwind.config.js +29 -0
- package/types/email.ts +22 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useDrag } from 'react-dnd';
|
|
4
|
+
import {
|
|
5
|
+
Layout,
|
|
6
|
+
Type,
|
|
7
|
+
Heading,
|
|
8
|
+
MousePointerClick,
|
|
9
|
+
Image,
|
|
10
|
+
Minus,
|
|
11
|
+
Square,
|
|
12
|
+
Columns,
|
|
13
|
+
Container as ContainerIcon,
|
|
14
|
+
Link as LinkIcon,
|
|
15
|
+
List,
|
|
16
|
+
Table,
|
|
17
|
+
FileText,
|
|
18
|
+
Quote,
|
|
19
|
+
Share2,
|
|
20
|
+
Menu,
|
|
21
|
+
} from 'lucide-react';
|
|
22
|
+
import { ComponentDefinition } from '@/types/email';
|
|
23
|
+
|
|
24
|
+
const componentDefinitions: ComponentDefinition[] = [
|
|
25
|
+
{
|
|
26
|
+
type: 'container',
|
|
27
|
+
label: 'Container',
|
|
28
|
+
icon: 'container',
|
|
29
|
+
category: 'layout',
|
|
30
|
+
defaultProps: {
|
|
31
|
+
backgroundColor: '#ffffff',
|
|
32
|
+
padding: 20,
|
|
33
|
+
margin: 0,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: 'row',
|
|
38
|
+
label: 'Row',
|
|
39
|
+
icon: 'row',
|
|
40
|
+
category: 'layout',
|
|
41
|
+
defaultProps: {
|
|
42
|
+
columns: 2,
|
|
43
|
+
gap: 10,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: 'column',
|
|
48
|
+
label: 'Column',
|
|
49
|
+
icon: 'column',
|
|
50
|
+
category: 'layout',
|
|
51
|
+
defaultProps: {
|
|
52
|
+
width: '50%',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
type: 'text',
|
|
57
|
+
label: 'Text',
|
|
58
|
+
icon: 'text',
|
|
59
|
+
category: 'content',
|
|
60
|
+
defaultProps: {
|
|
61
|
+
text: 'Lorem ipsum dolor sit amet',
|
|
62
|
+
fontSize: 16,
|
|
63
|
+
color: '#000000',
|
|
64
|
+
textAlign: 'left',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
type: 'heading',
|
|
69
|
+
label: 'Heading',
|
|
70
|
+
icon: 'heading',
|
|
71
|
+
category: 'content',
|
|
72
|
+
defaultProps: {
|
|
73
|
+
text: 'Heading',
|
|
74
|
+
level: 1,
|
|
75
|
+
fontSize: 24,
|
|
76
|
+
color: '#000000',
|
|
77
|
+
textAlign: 'left',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: 'button',
|
|
82
|
+
label: 'Button',
|
|
83
|
+
icon: 'button',
|
|
84
|
+
category: 'action',
|
|
85
|
+
defaultProps: {
|
|
86
|
+
text: 'Click Me',
|
|
87
|
+
href: '#',
|
|
88
|
+
backgroundColor: '#007bff',
|
|
89
|
+
color: '#ffffff',
|
|
90
|
+
padding: 12,
|
|
91
|
+
borderRadius: 4,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
type: 'image',
|
|
96
|
+
label: 'Image',
|
|
97
|
+
icon: 'image',
|
|
98
|
+
category: 'media',
|
|
99
|
+
defaultProps: {
|
|
100
|
+
src: 'https://via.placeholder.com/400x200',
|
|
101
|
+
alt: 'Image',
|
|
102
|
+
width: '100%',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
type: 'divider',
|
|
107
|
+
label: 'Divider',
|
|
108
|
+
icon: 'divider',
|
|
109
|
+
category: 'content',
|
|
110
|
+
defaultProps: {
|
|
111
|
+
color: '#e0e0e0',
|
|
112
|
+
height: 1,
|
|
113
|
+
margin: 20,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
type: 'spacer',
|
|
118
|
+
label: 'Spacer',
|
|
119
|
+
icon: 'spacer',
|
|
120
|
+
category: 'layout',
|
|
121
|
+
defaultProps: {
|
|
122
|
+
height: 20,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
type: 'header',
|
|
127
|
+
label: 'Header',
|
|
128
|
+
icon: 'header',
|
|
129
|
+
category: 'structure',
|
|
130
|
+
defaultProps: {
|
|
131
|
+
backgroundColor: '#ffffff',
|
|
132
|
+
padding: 20,
|
|
133
|
+
logoUrl: '',
|
|
134
|
+
logoAlt: 'Logo',
|
|
135
|
+
showLogo: true,
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
type: 'footer',
|
|
140
|
+
label: 'Footer',
|
|
141
|
+
icon: 'footer',
|
|
142
|
+
category: 'structure',
|
|
143
|
+
defaultProps: {
|
|
144
|
+
backgroundColor: '#f5f5f5',
|
|
145
|
+
padding: 20,
|
|
146
|
+
copyright: '© 2024 Company Name. All rights reserved.',
|
|
147
|
+
showSocialLinks: true,
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
type: 'section',
|
|
152
|
+
label: 'Section',
|
|
153
|
+
icon: 'section',
|
|
154
|
+
category: 'structure',
|
|
155
|
+
defaultProps: {
|
|
156
|
+
backgroundColor: '#ffffff',
|
|
157
|
+
padding: 20,
|
|
158
|
+
margin: 0,
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
type: 'link',
|
|
163
|
+
label: 'Link',
|
|
164
|
+
icon: 'link',
|
|
165
|
+
category: 'content',
|
|
166
|
+
defaultProps: {
|
|
167
|
+
text: 'Link Text',
|
|
168
|
+
href: '#',
|
|
169
|
+
color: '#007bff',
|
|
170
|
+
underline: true,
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
type: 'list',
|
|
175
|
+
label: 'List',
|
|
176
|
+
icon: 'list',
|
|
177
|
+
category: 'content',
|
|
178
|
+
defaultProps: {
|
|
179
|
+
items: ['Item 1', 'Item 2', 'Item 3'],
|
|
180
|
+
listType: 'unordered',
|
|
181
|
+
fontSize: 16,
|
|
182
|
+
color: '#000000',
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
type: 'table',
|
|
187
|
+
label: 'Table',
|
|
188
|
+
icon: 'table',
|
|
189
|
+
category: 'content',
|
|
190
|
+
defaultProps: {
|
|
191
|
+
headers: ['Header 1', 'Header 2', 'Header 3'],
|
|
192
|
+
rows: [
|
|
193
|
+
['Cell 1', 'Cell 2', 'Cell 3'],
|
|
194
|
+
['Cell 4', 'Cell 5', 'Cell 6'],
|
|
195
|
+
],
|
|
196
|
+
borderWidth: 1,
|
|
197
|
+
borderColor: '#e0e0e0',
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
type: 'social-links',
|
|
202
|
+
label: 'Social Links',
|
|
203
|
+
icon: 'social',
|
|
204
|
+
category: 'action',
|
|
205
|
+
defaultProps: {
|
|
206
|
+
facebook: '',
|
|
207
|
+
twitter: '',
|
|
208
|
+
instagram: '',
|
|
209
|
+
linkedin: '',
|
|
210
|
+
iconSize: 24,
|
|
211
|
+
gap: 10,
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
type: 'quote',
|
|
216
|
+
label: 'Quote',
|
|
217
|
+
icon: 'quote',
|
|
218
|
+
category: 'content',
|
|
219
|
+
defaultProps: {
|
|
220
|
+
text: 'This is a quote',
|
|
221
|
+
author: '',
|
|
222
|
+
fontSize: 18,
|
|
223
|
+
color: '#666666',
|
|
224
|
+
borderLeft: true,
|
|
225
|
+
borderColor: '#007bff',
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
];
|
|
229
|
+
|
|
230
|
+
const iconMap: Record<string, any> = {
|
|
231
|
+
container: ContainerIcon,
|
|
232
|
+
row: Columns,
|
|
233
|
+
column: Columns,
|
|
234
|
+
text: Type,
|
|
235
|
+
heading: Heading,
|
|
236
|
+
button: MousePointerClick,
|
|
237
|
+
image: Image,
|
|
238
|
+
divider: Minus,
|
|
239
|
+
spacer: Square,
|
|
240
|
+
header: Menu,
|
|
241
|
+
footer: FileText,
|
|
242
|
+
section: Layout,
|
|
243
|
+
link: LinkIcon,
|
|
244
|
+
list: List,
|
|
245
|
+
table: Table,
|
|
246
|
+
'social-links': Share2,
|
|
247
|
+
quote: Quote,
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
export default function ComponentPalette() {
|
|
251
|
+
const categories = ['layout', 'structure', 'content', 'media', 'action'] as const;
|
|
252
|
+
|
|
253
|
+
return (
|
|
254
|
+
<div className="p-4">
|
|
255
|
+
<h2 className="text-sm font-semibold text-gray-700 mb-4">Components</h2>
|
|
256
|
+
{categories.map((category) => (
|
|
257
|
+
<div key={category} className="mb-6">
|
|
258
|
+
<h3 className="text-xs font-medium text-gray-500 uppercase mb-2">
|
|
259
|
+
{category}
|
|
260
|
+
</h3>
|
|
261
|
+
<div className="space-y-1">
|
|
262
|
+
{componentDefinitions
|
|
263
|
+
.filter((def) => def.category === category)
|
|
264
|
+
.map((def) => (
|
|
265
|
+
<DraggableComponent key={def.type} definition={def} />
|
|
266
|
+
))}
|
|
267
|
+
</div>
|
|
268
|
+
</div>
|
|
269
|
+
))}
|
|
270
|
+
</div>
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function DraggableComponent({ definition }: { definition: ComponentDefinition }) {
|
|
275
|
+
const [{ isDragging }, drag] = useDrag({
|
|
276
|
+
type: 'component',
|
|
277
|
+
item: { type: definition.type, defaultProps: definition.defaultProps },
|
|
278
|
+
collect: (monitor) => ({
|
|
279
|
+
isDragging: monitor.isDragging(),
|
|
280
|
+
}),
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
const Icon = iconMap[definition.icon] || Layout;
|
|
284
|
+
|
|
285
|
+
return (
|
|
286
|
+
<div
|
|
287
|
+
ref={drag as any}
|
|
288
|
+
className={`flex items-center gap-2 p-2 rounded-md cursor-move hover:bg-gray-100 transition-colors ${
|
|
289
|
+
isDragging ? 'opacity-50' : ''
|
|
290
|
+
}`}
|
|
291
|
+
>
|
|
292
|
+
<Icon size={16} className="text-gray-600" />
|
|
293
|
+
<span className="text-sm text-gray-700">{definition.label}</span>
|
|
294
|
+
</div>
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
|