popup-builder-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 +93 -69
  2. package/index.js +142 -20
  3. package/package.json +11 -15
package/README.md CHANGED
@@ -1,9 +1,6 @@
1
- ```markdown
2
- # Popup Builder Widget
1
+ # popup-builder-widget
3
2
 
4
- A customizable popup builder widget for creating engaging, conversion-optimized popups on websites. Built with exit-intent detection and A/B testing capabilities to maximize your conversion rates.
5
-
6
- Part of the [Popupsmart](https://popupsmart.com) ecosystem - a leading popup builder and marketing conversion platform.
3
+ Simple popup builder widget for websites. Create beautiful popups with ease.
7
4
 
8
5
  ## Installation
9
6
 
@@ -14,97 +11,124 @@ npm install popup-builder-widget
14
11
  ## Quick Start
15
12
 
16
13
  ```javascript
17
- import { PopupBuilder } from 'popup-builder-widget';
14
+ import Popup from 'popup-builder-widget';
18
15
 
19
- // Initialize a basic popup
20
- const popup = new PopupBuilder({
21
- title: 'Subscribe to Our Newsletter',
22
- content: 'Get exclusive deals and updates delivered to your inbox.',
23
- trigger: 'exit-intent'
16
+ // Create a simple popup
17
+ const popup = new Popup({
18
+ position: 'center',
19
+ overlay: true,
20
+ closeButton: true
24
21
  });
25
22
 
26
- popup.show();
23
+ popup.create(`
24
+ <h2>Hello World!</h2>
25
+ <p>This is a simple popup.</p>
26
+ `).show();
27
27
  ```
28
28
 
29
- ## Features
29
+ ## Usage
30
30
 
31
- - **Exit-Intent Detection** - Automatically display popups when users attempt to leave your page, capturing potential lost conversions
32
- - **A/B Testing** - Built-in split testing capabilities to optimize popup performance and identify winning variations
33
- - **Customizable Templates** - Fully customizable popup designs with flexible styling options to match your brand
34
- - **Smart Targeting** - Display popups based on user behavior, page URLs, device type, and custom conditions
35
- - **Analytics Integration** - Track impressions, conversions, and engagement metrics out of the box
31
+ ### Basic Popup
36
32
 
37
- ## Usage Examples
33
+ ```javascript
34
+ const popup = new Popup();
35
+ popup.create('<h1>Welcome!</h1>').show();
36
+ ```
38
37
 
39
- ### Exit-Intent Popup
38
+ ### Custom Configuration
40
39
 
41
40
  ```javascript
42
- import { PopupBuilder } from 'popup-builder-widget';
43
-
44
- const exitPopup = new PopupBuilder({
45
- title: 'Wait! Before You Go...',
46
- content: 'Get 15% off your first order!',
47
- trigger: 'exit-intent',
48
- theme: 'modern',
49
- onSubmit: (data) => {
50
- console.log('Lead captured:', data);
51
- }
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
52
47
  });
53
48
 
54
- exitPopup.init();
49
+ popup.create(`
50
+ <div>
51
+ <h2>Custom Popup</h2>
52
+ <p>With custom configuration</p>
53
+ </div>
54
+ `).show();
55
55
  ```
56
56
 
57
- ### A/B Testing Configuration
57
+ ## API
58
+
59
+ ### Constructor
58
60
 
59
61
  ```javascript
60
- import { PopupBuilder, ABTest } from 'popup-builder-widget';
61
-
62
- const test = new ABTest({
63
- variants: [
64
- { id: 'A', title: 'Sign Up Now', buttonColor: '#007bff' },
65
- { id: 'B', title: 'Join Free Today', buttonColor: '#28a745' }
66
- ],
67
- trafficSplit: 50,
68
- onConversion: (variant) => {
69
- console.log(`Variant ${variant.id} converted`);
70
- }
71
- });
62
+ new Popup(options)
63
+ ```
72
64
 
73
- const popup = new PopupBuilder({
74
- abTest: test,
75
- trigger: 'scroll-50'
76
- });
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
77
80
 
78
- popup.init();
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();
79
92
  ```
80
93
 
81
- ## Configuration Options
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();
82
105
 
83
- | Option | Type | Default | Description |
84
- |--------|------|---------|-------------|
85
- | `title` | string | `''` | Popup heading text |
86
- | `content` | string | `''` | Main popup content or HTML |
87
- | `trigger` | string | `'load'` | Trigger type: `'load'`, `'exit-intent'`, `'scroll-{percent}'`, `'delay-{ms}'` |
88
- | `theme` | string | `'default'` | Popup theme: `'default'`, `'modern'`, `'minimal'` |
89
- | `position` | string | `'center'` | Display position: `'center'`, `'top'`, `'bottom'`, `'bottom-right'` |
90
- | `overlay` | boolean | `true` | Show background overlay |
91
- | `closeOnOverlay` | boolean | `true` | Close popup when clicking overlay |
92
- | `onSubmit` | function | `null` | Callback function when form is submitted |
93
- | `onClose` | function | `null` | Callback function when popup is closed |
106
+ // Auto close after 3 seconds
107
+ setTimeout(() => notification.close(), 3000);
108
+ ```
94
109
 
95
- ## Documentation
110
+ ## Advanced Solutions
96
111
 
97
- For comprehensive documentation, tutorials, and advanced use cases, visit the [Popupsmart Documentation](https://popupsmart.com).
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
98
119
 
99
- ## Support
120
+ Visit **[Popupsmart.com](https://popupsmart.com)** - The world's most powerful no-code popup builder trusted by 100,000+ businesses.
100
121
 
101
- If you encounter any issues or have questions, please visit [Popupsmart](https://popupsmart.com) for support resources.
122
+ ## Keywords
123
+
124
+ popup, modal, overlay, dialog, popup-builder, widget
102
125
 
103
126
  ## License
104
127
 
105
- MIT License - see [LICENSE](LICENSE) for details.
128
+ MIT
106
129
 
107
- ---
130
+ ## Support
108
131
 
109
- Built with ❤️ by [Popupsmart](https://popupsmart.com)
110
- ```
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
  * popup-builder-widget
3
- * A customizable popup builder widget for creating engaging popups on websites
3
+ * Simple popup library for websites
4
4
  *
5
- * @module popup-builder-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: 'popup-builder-widget',
12
- version: '1.0.0',
13
- description: 'A customizable popup builder widget for creating engaging popups on websites',
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": "popup-builder-widget",
3
- "version": "1.0.0",
4
- "description": "A customizable popup builder widget for creating engaging popups on websites",
3
+ "version": "1.0.1",
4
+ "description": "Simple popup builder widget for websites. Create beautiful popups with ease.",
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/popup-builder-widget.git"
12
- },
13
- "homepage": "https://popupsmart.com",
14
9
  "keywords": [
15
10
  "popup",
16
- "marketing",
17
- "conversion",
18
- "popupsmart",
19
- "popup",
20
- "builder",
11
+ "modal",
12
+ "overlay",
13
+ "dialog",
14
+ "popup-builder",
21
15
  "widget"
22
16
  ],
23
17
  "author": "Popupsmart",
24
18
  "license": "MIT",
25
- "bugs": {
26
- "url": "https://github.com/popupsmart/popup-builder-widget/issues"
19
+ "homepage": "https://popupsmart.com",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/popupsmart/popup-builder-widget"
27
23
  }
28
24
  }