PluginProbe
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor / 2.0.11
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor v2.0.11
2.0.13 2.0.12 2.0.11 2.0.10 2.0.9 trunk 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8
blockenberg / blocks / browser-mockup / frontend.js

frontend.js in Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor 2.0.11, at blocks/browser-mockup/frontend.js

182 lines 8.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function () {
2 'use strict';
3
4 function mk(tag, cls, styles) {
5 var d = document.createElement(tag);
6 if (cls) d.className = cls;
7 if (styles) Object.keys(styles).forEach(function (k) { d.style[k] = styles[k]; });
8 return d;
9 }
10 function tx(tag, cls, text, styles) {
11 var d = mk(tag, cls, styles);
12 d.textContent = text;
13 return d;
14 }
15 function ap(p) {
16 Array.prototype.slice.call(arguments, 1).forEach(function (c) { if (c) p.appendChild(c); });
17 return p;
18 }
19
20 function sectionIcon(type) {
21 if (type === 'nav') return '\u2630';
22 if (type === 'hero') return '\u2605';
23 if (type === 'feature') return '\u25C8';
24 if (type === 'content') return '\u00B6';
25 if (type === 'cta') return '\u25B6';
26 if (type === 'footer') return '\u25FB';
27 return '\u25AA';
28 }
29
30 function buildBlock(appEl) {
31 if (appEl.dataset.rendered) return;
32 appEl.dataset.rendered = '1';
33
34 var a;
35 try { a = JSON.parse(appEl.dataset.opts || '{}'); } catch (e) { a = {}; }
36
37 var isDark = a.browserStyle === 'dark';
38 var isMinimal = a.browserStyle === 'minimal';
39
40 var frameBg = isDark ? '#1e1e1e' : (a.frameBg || '#e8e8e8');
41 var frameText = isDark ? '#d4d4d4' : (a.frameText || '#3c3c3c');
42 var fontSize = a.fontSize || 13;
43 var radius = a.borderRadius || 12;
44
45 // Outer frame
46 var frame = mk('div', '', {
47 borderRadius: radius + 'px',
48 overflow: 'hidden',
49 boxShadow: '0 20px 60px ' + (a.frameShadow || '#00000033') + ', 0 4px 12px ' + (a.frameShadow || '#00000033'),
50 border: '1px solid ' + (isDark ? '#444' : '#d1d5db'),
51 fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'
52 });
53
54 // ── Tab bar ──────────────────────────────────────────────────
55 if (!isMinimal && a.showTabs) {
56 var tabRow = mk('div', '', {
57 display: 'flex', alignItems: 'flex-end', gap: '2px',
58 padding: '8px 12px 0', background: frameBg
59 });
60
61 // Traffic lights
62 var dots = mk('div', '', { display: 'flex', gap: '6px', alignItems: 'center', flexShrink: '0' });
63 [['#ef4444'],['#f59e0b'],['#22c55e']].forEach(function (c) {
64 ap(dots, mk('span', '', { width: '12px', height: '12px', borderRadius: '50%', background: c[0], display: 'block' }));
65 });
66 ap(tabRow, dots);
67 ap(tabRow, mk('div', '', { width: '16px' }));
68
69 // Active tab
70 var activeTab = mk('div', '', {
71 display: 'flex', alignItems: 'center', gap: '6px',
72 background: a.tabActiveBg || '#ffffff', color: a.tabActiveText || '#111827',
73 borderRadius: '6px 6px 0 0', padding: '6px 14px',
74 fontSize: (a.titleFontSize || 13) + 'px', fontWeight: '500',
75 maxWidth: '160px', whiteSpace: 'nowrap', overflow: 'hidden'
76 });
77 ap(activeTab, tx('span', '', '\u25C9', { fontSize: '10px' }), tx('span', '', a.tabTitle || 'Tab', {}));
78 ap(tabRow, activeTab);
79
80 // Inactive tabs
81 [a.tabTitle ? 'New Tab' : 'Tab 2', '+'].forEach(function (t) {
82 ap(tabRow, tx('div', '', t, {
83 background: a.tabInactiveBg || '#d1d5db', color: a.tabInactiveText || '#6b7280',
84 borderRadius: '6px 6px 0 0', padding: '6px 10px', fontSize: (fontSize - 1) + 'px'
85 }));
86 });
87 ap(frame, tabRow);
88 }
89
90 // Minimal-only dots header
91 if (isMinimal) {
92 var minHead = mk('div', '', { display: 'flex', alignItems: 'center', gap: '6px', padding: '10px 14px', background: frameBg });
93 [['#ef4444'],['#f59e0b'],['#22c55e']].forEach(function (c) {
94 ap(minHead, mk('span', '', { width: '12px', height: '12px', borderRadius: '50%', background: c[0], display: 'block' }));
95 });
96 ap(frame, minHead);
97 }
98
99 // ── URL bar ──────────────────────────────────────────────────
100 if (a.showURL) {
101 var urlRow = mk('div', '', {
102 display: 'flex', alignItems: 'center', gap: '8px',
103 padding: isMinimal ? '0 14px 6px' : '8px 12px',
104 background: frameBg
105 });
106
107 // Dots when no tab bar
108 if (!a.showTabs && !isMinimal) {
109 var dotsInline = mk('div', '', { display: 'flex', gap: '6px', alignItems: 'center', marginRight: '8px' });
110 [['#ef4444'],['#f59e0b'],['#22c55e']].forEach(function (c) {
111 ap(dotsInline, mk('span', '', { width: '12px', height: '12px', borderRadius: '50%', background: c[0], display: 'block' }));
112 });
113 ap(urlRow, dotsInline);
114 }
115
116 // Nav arrows
117 ap(urlRow, tx('div', '', '\u25C0 \u25B6 \u21BB', {
118 color: frameText, fontSize: (fontSize - 1) + 'px', opacity: '.7', cursor: 'default', whiteSpace: 'nowrap'
119 }));
120
121 // URL pill
122 var urlPill = mk('div', '', {
123 flex: '1', background: a.urlBarBg || '#ffffff',
124 border: '1px solid ' + (a.urlBarBorder || '#d1d5db'),
125 borderRadius: '20px', padding: '4px 14px',
126 display: 'flex', alignItems: 'center', gap: '6px'
127 });
128 ap(urlPill, tx('span', '', '\uD83D\uDD12', { fontSize: '10px', color: '#22c55e' }));
129 ap(urlPill, tx('span', '', a.url || 'https://yoursite.com', {
130 color: a.urlBarText || '#374151', fontSize: fontSize + 'px', userSelect: 'none'
131 }));
132 ap(urlRow, urlPill);
133
134 ap(urlRow, tx('div', '', '\u22EF \u2606 \u2B07', {
135 color: frameText, fontSize: (fontSize - 1) + 'px', opacity: '.7', whiteSpace: 'nowrap'
136 }));
137 ap(frame, urlRow);
138 }
139
140 // ── Bookmarks bar ─────────────────────────────────────────────
141 if (a.showBookmarks && a.bookmarks && a.bookmarks.length) {
142 var bmRow = mk('div', '', {
143 display: 'flex', alignItems: 'center', gap: '2px',
144 padding: '4px 14px', background: frameBg,
145 borderBottom: '1px solid ' + (isDark ? '#333' : '#d1d5db')
146 });
147 a.bookmarks.forEach(function (bk) {
148 ap(bmRow, tx('div', '', '\uD83D\uDCC4 ' + bk.label, {
149 padding: '2px 10px', borderRadius: '4px', cursor: 'pointer',
150 color: frameText, fontSize: (fontSize - 1) + 'px', opacity: '.8'
151 }));
152 });
153 ap(frame, bmRow);
154 }
155
156 // ── Page sections ─────────────────────────────────────────────
157 var pageWrap = mk('div', '', { overflow: 'hidden' });
158 (a.sections || []).forEach(function (sec) {
159 var row = mk('div', '', {
160 height: sec.height + 'px', background: sec.bg,
161 color: sec.textColor, display: 'flex',
162 alignItems: 'center', justifyContent: 'center',
163 fontSize: fontSize + 'px',
164 fontWeight: sec.type === 'hero' ? '700' : '400',
165 overflow: 'hidden', gap: '10px'
166 });
167 ap(row, tx('span', '', sectionIcon(sec.type), { fontSize: '18px', opacity: '.6' }));
168 ap(row, tx('span', '', sec.label || '', {
169 overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', maxWidth: '80%'
170 }));
171 ap(pageWrap, row);
172 });
173 ap(frame, pageWrap);
174 ap(appEl, frame);
175 }
176
177 function init() {
178 document.querySelectorAll('.bkbg-browser-mockup-app').forEach(buildBlock);
179 }
180 if (document.readyState !== 'loading') { init(); } else { document.addEventListener('DOMContentLoaded', init); }
181 })();
182