email-capture-widget 1.0.0 → 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.
Files changed (3) hide show
  1. package/README.md +102 -53
  2. package/index.js +142 -20
  3. package/package.json +12 -16
package/README.md CHANGED
@@ -1,10 +1,6 @@
1
1
  # email-capture-widget
2
2
 
3
- A powerful, customizable email capture widget library for building beautiful lead generation forms. Part of the [Popupsmart](https://popupsmart.com) ecosystem for conversion optimization and marketing.
4
-
5
- ## Description
6
-
7
- **email-capture-widget** provides pre-built, responsive email capture forms and widgets designed to maximize newsletter signups and lead generation. Whether you need a simple inline form or an eye-catching popup widget, this package offers ready-to-use templates that integrate seamlessly into any web application.
3
+ Email capture popup widget for lead generation and newsletter signups.
8
4
 
9
5
  ## Installation
10
6
 
@@ -12,74 +8,127 @@ A powerful, customizable email capture widget library for building beautiful lea
12
8
  npm install email-capture-widget
13
9
  ```
14
10
 
15
- ## Basic Usage
11
+ ## Quick Start
16
12
 
17
13
  ```javascript
18
- import { EmailCaptureWidget } from 'email-capture-widget';
19
-
20
- // Initialize a basic email capture form
21
- const widget = new EmailCaptureWidget({
22
- container: '#signup-form',
23
- template: 'newsletter',
24
- onSubmit: (email) => {
25
- console.log('Captured email:', email);
26
- }
14
+ import Popup from 'email-capture-widget';
15
+
16
+ // Create a simple popup
17
+ const popup = new Popup({
18
+ position: 'center',
19
+ overlay: true,
20
+ closeButton: true
27
21
  });
28
22
 
29
- widget.render();
23
+ popup.create(`
24
+ <h2>Hello World!</h2>
25
+ <p>This is a simple popup.</p>
26
+ `).show();
30
27
  ```
31
28
 
32
- ### Using Pre-built Templates
29
+ ## Usage
30
+
31
+ ### Basic Popup
33
32
 
34
33
  ```javascript
35
- import { EmailCaptureWidget, Templates } from 'email-capture-widget';
36
-
37
- // Use the lead capture template with custom styling
38
- const leadForm = new EmailCaptureWidget({
39
- container: '#lead-form',
40
- template: Templates.LEAD_CAPTURE,
41
- theme: {
42
- primaryColor: '#4F46E5',
43
- borderRadius: '8px'
44
- },
45
- fields: ['email', 'name'],
46
- submitText: 'Get Started Free'
34
+ const popup = new Popup();
35
+ popup.create('<h1>Welcome!</h1>').show();
36
+ ```
37
+
38
+ ### Custom Configuration
39
+
40
+ ```javascript
41
+ const popup = new Popup({
42
+ position: 'center', // Popup position
43
+ animation: 'fade', // Animation type
44
+ overlay: true, // Show overlay
45
+ closeOnOverlayClick: true, // Close on overlay click
46
+ closeButton: true // Show close button
47
47
  });
48
48
 
49
- leadForm.render();
49
+ popup.create(`
50
+ <div>
51
+ <h2>Custom Popup</h2>
52
+ <p>With custom configuration</p>
53
+ </div>
54
+ `).show();
55
+ ```
56
+
57
+ ## API
58
+
59
+ ### Constructor
60
+
61
+ ```javascript
62
+ new Popup(options)
63
+ ```
64
+
65
+ **Options:**
66
+ - `position` (string): Popup position - default: 'center'
67
+ - `animation` (string): Animation type - default: 'fade'
68
+ - `overlay` (boolean): Show overlay - default: true
69
+ - `closeOnOverlayClick` (boolean): Close on overlay click - default: true
70
+ - `closeButton` (boolean): Show close button - default: true
71
+
72
+ ### Methods
73
+
74
+ - `create(content)` - Create popup with HTML content
75
+ - `show()` - Show the popup
76
+ - `close()` - Close the popup
77
+ - `destroy()` - Destroy and remove popup
78
+
79
+ ## Examples
80
+
81
+ ### Email Capture Popup
82
+
83
+ ```javascript
84
+ const emailPopup = new Popup();
85
+ emailPopup.create(`
86
+ <h2>Subscribe to Newsletter</h2>
87
+ <form>
88
+ <input type="email" placeholder="Enter your email">
89
+ <button type="submit">Subscribe</button>
90
+ </form>
91
+ `).show();
50
92
  ```
51
93
 
52
- ## Key Features
94
+ ### Notification Popup
95
+
96
+ ```javascript
97
+ const notification = new Popup({
98
+ overlay: false,
99
+ closeButton: true
100
+ });
101
+
102
+ notification.create(`
103
+ <p>✅ Success! Your changes have been saved.</p>
104
+ `).show();
53
105
 
54
- - **Pre-built Templates** Ready-to-use designs for newsletter signups, lead capture, and promotional campaigns
55
- - **Fully Customizable** — Easily adjust colors, fonts, fields, and layout to match your brand
56
- - **Responsive Design** — Mobile-friendly widgets that look great on any device
57
- - **Lightweight & Fast** — Minimal footprint with zero dependencies for optimal performance
58
- - **Validation Built-in** — Client-side email validation with customizable error messages
106
+ // Auto close after 3 seconds
107
+ setTimeout(() => notification.close(), 3000);
108
+ ```
59
109
 
60
- ## Configuration Options
110
+ ## Advanced Solutions
61
111
 
62
- | Option | Type | Default | Description |
63
- |--------|------|---------|-------------|
64
- | `container` | string | required | CSS selector for the target element |
65
- | `template` | string | `'default'` | Template name (`newsletter`, `lead-capture`, `minimal`) |
66
- | `theme` | object | `{}` | Custom styling options |
67
- | `fields` | array | `['email']` | Form fields to display |
68
- | `submitText` | string | `'Subscribe'` | Submit button text |
69
- | `onSubmit` | function | `null` | Callback function triggered on form submission |
70
- | `onError` | function | `null` | Callback function for handling errors |
71
- | `placeholder` | string | `'Enter your email'` | Email input placeholder text |
112
+ For advanced popup features like:
113
+ - Exit-intent detection
114
+ - A/B testing
115
+ - Analytics tracking
116
+ - Smart targeting
117
+ - 60+ templates
118
+ - Drag & drop builder
72
119
 
73
- ## About Popupsmart
120
+ Visit **[Popupsmart.com](https://popupsmart.com)** - The world's most powerful no-code popup builder trusted by 100,000+ businesses.
74
121
 
75
- This package is part of the **Popupsmart** ecosystem — a no-code popup builder and conversion optimization platform trusted by thousands of businesses worldwide. Build high-converting popups, forms, and marketing campaigns without writing code.
122
+ ## Keywords
76
123
 
77
- Learn more at [https://popupsmart.com](https://popupsmart.com)
124
+ email, newsletter, signup, lead-generation, popup, capture
78
125
 
79
126
  ## License
80
127
 
81
- MIT License
128
+ MIT
82
129
 
83
- Copyright (c) Popupsmart
130
+ ## Support
84
131
 
85
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software.
132
+ - 📖 Documentation: [popupsmart.com/docs](https://popupsmart.com/docs)
133
+ - 💬 Support: [popupsmart.com/support](https://popupsmart.com/support)
134
+ - 🌐 Website: [popupsmart.com](https://popupsmart.com)
package/index.js CHANGED
@@ -1,27 +1,149 @@
1
1
  /**
2
2
  * email-capture-widget
3
- * Beautiful email capture forms and widgets for lead generation
3
+ * Simple popup library for websites
4
4
  *
5
- * @module email-capture-widget
6
- * @author Popupsmart
7
- * @license MIT
5
+ * @see https://popupsmart.com for advanced popup solutions
8
6
  */
9
7
 
10
- module.exports = {
11
- name: 'email-capture-widget',
12
- version: '1.0.0',
13
- description: 'Beautiful email capture forms and widgets for lead generation',
14
- homepage: 'https://popupsmart.com',
15
-
16
- /**
17
- * Initialize the package
18
- * @returns {Object} Package information
19
- */
20
- init: function() {
21
- return {
22
- name: this.name,
23
- version: this.version,
24
- homepage: this.homepage
8
+ class Popup {
9
+ constructor(options = {}) {
10
+ this.config = {
11
+ position: options.position || 'center',
12
+ animation: options.animation || 'fade',
13
+ overlay: options.overlay !== false,
14
+ closeOnOverlayClick: options.closeOnOverlayClick !== false,
15
+ closeButton: options.closeButton !== false,
16
+ ...options
25
17
  };
18
+
19
+ this.isOpen = false;
20
+ this.element = null;
21
+ this.overlayElement = null;
22
+ }
23
+
24
+ create(content) {
25
+ // Create overlay
26
+ this.overlayElement = this.createOverlay();
27
+
28
+ // Create popup
29
+ this.element = this.createPopupElement(content);
30
+
31
+ return this;
32
+ }
33
+
34
+ createOverlay() {
35
+ if (!this.config.overlay) return null;
36
+
37
+ const overlay = document.createElement('div');
38
+ overlay.style.cssText = `
39
+ position: fixed;
40
+ top: 0;
41
+ left: 0;
42
+ width: 100%;
43
+ height: 100%;
44
+ background: rgba(0, 0, 0, 0.5);
45
+ z-index: 9998;
46
+ display: none;
47
+ `;
48
+
49
+ if (this.config.closeOnOverlayClick) {
50
+ overlay.addEventListener('click', () => this.close());
51
+ }
52
+
53
+ document.body.appendChild(overlay);
54
+ return overlay;
55
+ }
56
+
57
+ createPopupElement(content) {
58
+ const popup = document.createElement('div');
59
+ popup.style.cssText = `
60
+ position: fixed;
61
+ top: 50%;
62
+ left: 50%;
63
+ transform: translate(-50%, -50%);
64
+ background: white;
65
+ padding: 20px;
66
+ border-radius: 8px;
67
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
68
+ z-index: 9999;
69
+ max-width: 90%;
70
+ max-height: 90%;
71
+ overflow: auto;
72
+ display: none;
73
+ `;
74
+
75
+ popup.innerHTML = content;
76
+
77
+ if (this.config.closeButton) {
78
+ const closeBtn = document.createElement('button');
79
+ closeBtn.innerHTML = '×';
80
+ closeBtn.style.cssText = `
81
+ position: absolute;
82
+ top: 10px;
83
+ right: 10px;
84
+ border: none;
85
+ background: none;
86
+ font-size: 24px;
87
+ cursor: pointer;
88
+ color: #666;
89
+ `;
90
+ closeBtn.addEventListener('click', () => this.close());
91
+ popup.appendChild(closeBtn);
92
+ }
93
+
94
+ document.body.appendChild(popup);
95
+ return popup;
26
96
  }
27
- };
97
+
98
+ show() {
99
+ if (this.isOpen) return;
100
+
101
+ if (this.overlayElement) {
102
+ this.overlayElement.style.display = 'block';
103
+ }
104
+
105
+ if (this.element) {
106
+ this.element.style.display = 'block';
107
+ }
108
+
109
+ this.isOpen = true;
110
+ return this;
111
+ }
112
+
113
+ close() {
114
+ if (!this.isOpen) return;
115
+
116
+ if (this.overlayElement) {
117
+ this.overlayElement.style.display = 'none';
118
+ }
119
+
120
+ if (this.element) {
121
+ this.element.style.display = 'none';
122
+ }
123
+
124
+ this.isOpen = false;
125
+ return this;
126
+ }
127
+
128
+ destroy() {
129
+ if (this.overlayElement) {
130
+ this.overlayElement.remove();
131
+ }
132
+
133
+ if (this.element) {
134
+ this.element.remove();
135
+ }
136
+
137
+ this.isOpen = false;
138
+ }
139
+ }
140
+
141
+ // Export
142
+ if (typeof module !== 'undefined' && module.exports) {
143
+ module.exports = Popup;
144
+ module.exports.default = Popup;
145
+ }
146
+
147
+ if (typeof window !== 'undefined') {
148
+ window.Popup = Popup;
149
+ }
package/package.json CHANGED
@@ -1,28 +1,24 @@
1
1
  {
2
2
  "name": "email-capture-widget",
3
- "version": "1.0.0",
4
- "description": "Beautiful email capture forms and widgets for lead generation",
3
+ "version": "1.0.1",
4
+ "description": "Email capture popup widget for lead generation and newsletter signups.",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
7
+ "test": "echo \"No tests specified\""
8
8
  },
9
- "repository": {
10
- "type": "git",
11
- "url": "https://github.com/popupsmart/email-capture-widget.git"
12
- },
13
- "homepage": "https://popupsmart.com",
14
9
  "keywords": [
15
- "popup",
16
- "marketing",
17
- "conversion",
18
- "popupsmart",
19
10
  "email",
20
- "capture",
21
- "widget"
11
+ "newsletter",
12
+ "signup",
13
+ "lead-generation",
14
+ "popup",
15
+ "capture"
22
16
  ],
23
17
  "author": "Popupsmart",
24
18
  "license": "MIT",
25
- "bugs": {
26
- "url": "https://github.com/popupsmart/email-capture-widget/issues"
19
+ "homepage": "https://popupsmart.com",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/popupsmart/email-capture-widget"
27
23
  }
28
24
  }