@sqid-dev/playground 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +67 -2
- package/bin/sqid-playground.js +7 -0
- package/package.json +40 -4
- package/public/panel.css +76 -0
- package/public/panel.js +354 -0
- package/public/recipes.js +194 -0
- package/public/site.css +115 -0
- package/public/site.js +89 -0
- package/src/index.js +70 -0
- package/src/layout.js +89 -0
- package/src/pages/cart.html +16 -0
- package/src/pages/demo.html +19 -0
- package/src/pages/desk.html +23 -0
- package/src/pages/desks.html +18 -0
- package/src/pages/home.html +25 -0
- package/src/pages/pricing.html +29 -0
- package/src/pages/signin.html +13 -0
- package/src/pages/teams.html +11 -0
- package/src/server.js +65 -0
- package/src/sqid.js +167 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// The docs recipes, runnable on this site. Each one is the code from docs.sqid.dev/recipes,
|
|
2
|
+
// trimmed to what the page needs, and shown in the panel as is. `apply` is called by the
|
|
3
|
+
// panel with the visitor's traits whenever a recipe is on and the visitor changes.
|
|
4
|
+
(function(){
|
|
5
|
+
'use strict';
|
|
6
|
+
const page = () => document.body.dataset.page;
|
|
7
|
+
const cap = (s) => String(s || '').replace(/\b[a-z]/g, c => c.toUpperCase());
|
|
8
|
+
const first = (v) => cap(v?.firstName || (v?.name || '').split(' ')[0] || '') || null;
|
|
9
|
+
const company = (v) => v?.company ? cap(v.company) : null;
|
|
10
|
+
const sizeOf = (v) => v?.company_size || v?.job_company_size || null;
|
|
11
|
+
|
|
12
|
+
const RECIPES = {
|
|
13
|
+
dom : {
|
|
14
|
+
title : 'DOM personalisation', where : 'home h1', docs : 'https://docs.sqid.dev/recipes/dom-personalization',
|
|
15
|
+
code : `const engine = new squid.engine();
|
|
16
|
+
|
|
17
|
+
engine.on('visitor.identified', (e) => {
|
|
18
|
+
const v = e.detail;
|
|
19
|
+
document.querySelector('h1').textContent =
|
|
20
|
+
\`Welcome back, \${v.firstName}. \${v.company}'s desks ship in 3 days.\`;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
engine.on('visitor.unknown', () => {
|
|
24
|
+
// leave the default headline
|
|
25
|
+
});`,
|
|
26
|
+
apply(v, on){
|
|
27
|
+
for(let [id, text] of [['hero-title', v && on ? `Welcome back, ${first(v)}. ${company(v)}'s desks ship in 3 days.` : null], ['teams-title', v && on ? `${company(v)}, outfit a floor without a spreadsheet.` : null]]){
|
|
28
|
+
let el = document.getElementById(id); if(!el){ continue; }
|
|
29
|
+
el.textContent = text || el.dataset.default;
|
|
30
|
+
}
|
|
31
|
+
let sub = document.getElementById('hero-sub');
|
|
32
|
+
if(sub){ sub.textContent = v && on ? 'The headline just changed because Sqid identified you. The panel shows what it knew, and when.' : sub.dataset.default; }
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
pricing : {
|
|
36
|
+
title : 'Pricing personalisation', where : '/pricing', docs : 'https://docs.sqid.dev/recipes/pricing-personalization',
|
|
37
|
+
code : `const engine = new squid.engine();
|
|
38
|
+
|
|
39
|
+
engine.on('visitor.identified', (e) => {
|
|
40
|
+
const v = e.detail;
|
|
41
|
+
const size = v.company_size || '';
|
|
42
|
+
const team = /^(1[01]-|51-|201-)/.test(size); // 10 to 500 people
|
|
43
|
+
document.querySelector('#pricing-title').textContent = \`Team pricing for \${v.company}\`;
|
|
44
|
+
document.querySelector('#plan-team').classList.toggle('featured', team);
|
|
45
|
+
});`,
|
|
46
|
+
apply(v, on){
|
|
47
|
+
if(page() !== 'pricing'){ return; }
|
|
48
|
+
let t = document.getElementById('pricing-title'), s = document.getElementById('pricing-sub'), pill = document.getElementById('pricing-pill');
|
|
49
|
+
let team = document.getElementById('plan-team'), badge = document.getElementById('plan-team-badge'), ent = document.getElementById('plan-enterprise');
|
|
50
|
+
let size = sizeOf(v) || '';
|
|
51
|
+
let big = /^(1001|5001|10001)/.test(size), mid = /^(11-|51-|201-|501-)/.test(size);
|
|
52
|
+
if(v && on){
|
|
53
|
+
t.textContent = `Team pricing for ${company(v)}`;
|
|
54
|
+
s.textContent = big ? `Companies your size usually roll out by floor. Enterprise is where ${company(v)} fits.` : mid ? `Teams of ${size} get volume pricing and a dedicated account manager.` : `Start with one desk; the Team tier is there when ${company(v)} grows.`;
|
|
55
|
+
pill.classList.remove('hidden');
|
|
56
|
+
team.classList.toggle('featured', mid); badge.classList.toggle('hidden', !mid);
|
|
57
|
+
ent.classList.toggle('featured', big);
|
|
58
|
+
} else {
|
|
59
|
+
t.textContent = t.dataset.default; s.textContent = s.dataset.default; pill.classList.add('hidden');
|
|
60
|
+
team.classList.remove('featured'); badge.classList.add('hidden'); ent.classList.remove('featured');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
chat : {
|
|
65
|
+
title : 'Chat integration', where : 'widget', docs : 'https://docs.sqid.dev/recipes/chat-integration',
|
|
66
|
+
code : `const engine = new squid.engine();
|
|
67
|
+
|
|
68
|
+
engine.on('visitor.identified', (e) => {
|
|
69
|
+
const v = e.detail;
|
|
70
|
+
// Intercom / Drift / Crisp / Zendesk all have an identify call:
|
|
71
|
+
window.Intercom?.('update', { email: v.email, name: v.name, company: { name: v.company } });
|
|
72
|
+
openChat(\`Hi \${v.firstName}, want the Team quote for \${v.company}?\`);
|
|
73
|
+
});`,
|
|
74
|
+
apply(v, on){
|
|
75
|
+
let w = document.getElementById('rc-chat');
|
|
76
|
+
if(!(v && on)){ w && w.remove(); return; }
|
|
77
|
+
if(!w){ w = document.createElement('div'); w.id = 'rc-chat'; w.className = 'rc-chat'; document.body.appendChild(w); }
|
|
78
|
+
w.innerHTML = `<div class="avatar" aria-hidden="true">D</div><div class="msg"><strong>Hi ${esc(first(v))}, want the Team quote for ${esc(company(v))}?</strong><span>The widget was handed the profile, so it never asks for an email.</span></div>`;
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
prefill : {
|
|
82
|
+
title : 'Form prefill', where : '/demo', docs : 'https://docs.sqid.dev/recipes/form-prefill',
|
|
83
|
+
code : `const engine = new squid.engine();
|
|
84
|
+
|
|
85
|
+
engine.on('visitor.identified', (e) => {
|
|
86
|
+
const v = e.detail;
|
|
87
|
+
const form = document.querySelector('#demo-form');
|
|
88
|
+
form.name.value = v.name;
|
|
89
|
+
form.email.value = v.email;
|
|
90
|
+
form.company.value = v.company;
|
|
91
|
+
});`,
|
|
92
|
+
apply(v, on){
|
|
93
|
+
let form = document.getElementById('demo-form'); if(!form){ return; }
|
|
94
|
+
for(let [k, val] of [['name', v?.name], ['email', v?.email], ['company', company(v)]]){
|
|
95
|
+
let input = form.elements[k]; if(!input){ continue; }
|
|
96
|
+
if(v && on && val && !input.dataset.typed){ input.value = k === 'email' ? val : cap(val); input.classList.add('prefilled'); }
|
|
97
|
+
else if(!on && input.classList.contains('prefilled')){ input.value = ''; input.classList.remove('prefilled'); }
|
|
98
|
+
}
|
|
99
|
+
form.addEventListener('input', e => { e.target.dataset.typed = '1'; e.target.classList.remove('prefilled'); }, { once : false });
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
exit : {
|
|
103
|
+
title : 'Exit intent', where : 'any page', docs : 'https://docs.sqid.dev/recipes/exit-intent',
|
|
104
|
+
code : `const engine = new squid.engine();
|
|
105
|
+
let visitor = null;
|
|
106
|
+
engine.on('visitor.identified', (e) => { visitor = e.detail; });
|
|
107
|
+
|
|
108
|
+
document.addEventListener('mouseleave', (e) => {
|
|
109
|
+
if (e.clientY > 0 || !visitor) return;
|
|
110
|
+
showPopup(\`Before you go, \${visitor.firstName}: want us to send \${visitor.company} a quote?\`);
|
|
111
|
+
}, { once: true });`,
|
|
112
|
+
apply(v, on){
|
|
113
|
+
this._visitor = v; this._on = on;
|
|
114
|
+
if(this._wired){ return; } this._wired = true;
|
|
115
|
+
document.addEventListener('sqid:page', e => {
|
|
116
|
+
if(e.detail.what !== 'exit_intent' || !this._on || !this._visitor || sessionStorage.getItem('rc.exit')){ return; }
|
|
117
|
+
sessionStorage.setItem('rc.exit', '1');
|
|
118
|
+
let m = document.createElement('div'); m.className = 'rc-exit'; m.setAttribute('role', 'dialog');
|
|
119
|
+
m.innerHTML = `<div class="box"><h3>Before you go, ${esc(first(this._visitor))}</h3><p>Want us to send ${esc(company(this._visitor))} a quote for the Team tier? No forms, we already know where to send it.</p><div class="hero-actions"><button class="btn btn-dark" type="button">Send the quote</button><button class="btn btn-ghost" type="button">No thanks</button></div><p class="hint">Exit intent recipe. Suppressed for existing customers on a real site.</p></div>`;
|
|
120
|
+
m.querySelectorAll('button').forEach(b => b.addEventListener('click', () => m.remove()));
|
|
121
|
+
document.body.appendChild(m);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
analytics : {
|
|
126
|
+
title : 'Analytics enrichment', where : 'console', docs : 'https://docs.sqid.dev/recipes/analytics-enrichment',
|
|
127
|
+
code : `const engine = new squid.engine();
|
|
128
|
+
|
|
129
|
+
engine.on('visitor.identified', (e) => {
|
|
130
|
+
const v = e.detail;
|
|
131
|
+
// GA4 / Segment / Mixpanel / Amplitude / PostHog: one identify call each
|
|
132
|
+
window.gtag?.('set', 'user_properties', { company: v.company, role: v.company_role });
|
|
133
|
+
window.analytics?.identify(v.id, { email: v.email, company: v.company });
|
|
134
|
+
window.posthog?.identify(v.id, { email: v.email });
|
|
135
|
+
});`,
|
|
136
|
+
apply(v, on){
|
|
137
|
+
if(!(v && on)){ return; }
|
|
138
|
+
console.log('[analytics] identify', { id : v.id, email : v.email, company : v.company, role : v.company_role });
|
|
139
|
+
document.dispatchEvent(new CustomEvent('sqid:recipe', { detail : { recipe : 'analytics', text : `identify(${v.id}) sent to the analytics stubs (see the console)` } }));
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
sp : {
|
|
143
|
+
title : 'Service provider (your database)', where : 'built-in mock', docs : 'https://docs.sqid.dev/recipes/local-database',
|
|
144
|
+
code : `// Browser: route the profile through your backend first
|
|
145
|
+
const engine = new squid.engine({ sp: 'https://api.yourapp.com' });
|
|
146
|
+
|
|
147
|
+
engine.on('visitor.identified', (e) => {
|
|
148
|
+
// e.detail is YOUR server's answer: Sqid's traits + your fields
|
|
149
|
+
const v = e.detail;
|
|
150
|
+
if (v.accountType === 'Team') showAccountManagerBanner(v);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// Server: POST /visitor_details receives the traits
|
|
154
|
+
app.post('/visitor_details', async (req, res) => {
|
|
155
|
+
const row = await db.customers.findByEmail(req.body.email);
|
|
156
|
+
res.json({ ...req.body, ...row });
|
|
157
|
+
});`,
|
|
158
|
+
apply(v, on){
|
|
159
|
+
if(!on || this._engine || !window.squid?.engine){ return; }
|
|
160
|
+
this._engine = new window.squid.engine({ sp : location.origin + '/_sqid/sp' });
|
|
161
|
+
this._engine.on('visitor.identified', e => document.dispatchEvent(new CustomEvent('sqid:recipe', { detail : { recipe : 'sp', text : `your database answered: ${e.detail.accountType} customer since ${e.detail.customerSince}, lifetime value $${e.detail.lifetimeValue}`, data : e.detail } })));
|
|
162
|
+
this._engine.on('error', e => document.dispatchEvent(new CustomEvent('sqid:recipe', { detail : { recipe : 'sp', text : `service provider error: ${e.detail?.message || e.detail}` } })));
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
moment : {
|
|
166
|
+
title : 'React to a moment (chat opens)', where : 'needs a real site', docs : 'https://docs.sqid.dev/guides/signals', locked : true,
|
|
167
|
+
code : `const engine = new squid.engine();
|
|
168
|
+
|
|
169
|
+
engine.on('visitor.moment', (e) => {
|
|
170
|
+
const m = e.detail; // { decision_id, kind, decision: { action, instruction }, ... }
|
|
171
|
+
if (m.decision.action !== 'engage') return;
|
|
172
|
+
openChat(m.decision.instruction); // e.g. "Offer to help with the signup form, in one line."
|
|
173
|
+
});`,
|
|
174
|
+
apply(){ /* Sandbox sites never receive moments */ }
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
function esc(s){ return String(s ?? '').replace(/[&<>"']/g, c => ({ '&' : '&', '<' : '<', '>' : '>', '"' : '"', "'" : ''' }[c])); }
|
|
179
|
+
|
|
180
|
+
const KEY = 'sqid.playground.recipes';
|
|
181
|
+
const DEFAULT_ON = ['dom', 'chat', 'prefill'];
|
|
182
|
+
function enabled(){ try{ let s = JSON.parse(localStorage.getItem(KEY)); return Array.isArray(s) ? s : DEFAULT_ON; }catch(error){ return DEFAULT_ON; } }
|
|
183
|
+
function setEnabled(list){ localStorage.setItem(KEY, JSON.stringify(list)); }
|
|
184
|
+
|
|
185
|
+
window.SqidRecipes = {
|
|
186
|
+
all : RECIPES,
|
|
187
|
+
enabled,
|
|
188
|
+
toggle(key){ let on = enabled(); let next = on.includes(key) ? on.filter(k => k !== key) : [...on, key]; setEnabled(next); return next; },
|
|
189
|
+
apply(visitor){
|
|
190
|
+
let on = enabled();
|
|
191
|
+
for(let [key, r] of Object.entries(RECIPES)){ try{ r.apply(visitor, on.includes(key)); }catch(error){ console.warn('[recipe]', key, error); } }
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
})();
|
package/public/site.css
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/* Driftwood: a plain, well-made site. Light on purpose; the Sqid panel is the only dark thing. */
|
|
2
|
+
:root{
|
|
3
|
+
--ink:#18181b; --ink-2:#52525b; --ink-3:#71717a; --line:#e4e4e7; --bg:#ffffff; --bg-2:#f4f4f5; --bg-3:#fafafa;
|
|
4
|
+
--link:#0e7490; --sea:#ecfeff; --sea-line:#a5f3fc; --sea-ink:#155e75;
|
|
5
|
+
}
|
|
6
|
+
*{box-sizing:border-box}
|
|
7
|
+
html,body{margin:0;background:var(--bg);color:var(--ink);font-family:'Inter',system-ui,sans-serif;font-size:15px;line-height:1.5}
|
|
8
|
+
a{color:var(--link);text-decoration:none}a:hover{color:var(--sea-ink)}
|
|
9
|
+
h1{font-size:44px;line-height:1.08;letter-spacing:-.03em;font-weight:700;margin:0 0 14px}
|
|
10
|
+
h2{font-size:24px;letter-spacing:-.02em;margin:0 0 8px}
|
|
11
|
+
p{margin:0 0 12px}
|
|
12
|
+
.hidden{display:none !important}
|
|
13
|
+
|
|
14
|
+
.pg-shell{display:flex;flex-wrap:wrap;min-height:100vh}
|
|
15
|
+
.pg-site{flex:999 1 560px;min-width:0;display:flex;flex-direction:column}
|
|
16
|
+
.pg-panel{flex:0 0 420px;max-width:100%}
|
|
17
|
+
body.pg-panel-hidden .pg-panel{display:none}
|
|
18
|
+
|
|
19
|
+
.site-nav{display:flex;align-items:center;gap:24px;padding:0 40px;height:64px;border-bottom:1px solid var(--line);font-size:14px;font-weight:500}
|
|
20
|
+
.site-nav .brand{font-weight:700;font-size:19px;letter-spacing:-.02em;color:var(--ink)}
|
|
21
|
+
.site-nav nav{display:flex;gap:22px}
|
|
22
|
+
.site-nav nav a,.nav-right a{color:var(--ink)}
|
|
23
|
+
.nav-right a.btn-dark{color:#fff}
|
|
24
|
+
.site-nav nav a.on{border-bottom:2px solid var(--ink);padding:20px 0}
|
|
25
|
+
.nav-right{margin-left:auto;display:flex;align-items:center;gap:18px}
|
|
26
|
+
.cart-link span{display:inline-block;min-width:18px;padding:0 5px;border-radius:9px;background:var(--bg-2);font-size:12px;text-align:center}
|
|
27
|
+
.flash{margin:0;padding:10px 40px;background:var(--sea);border-bottom:1px solid var(--sea-line);color:var(--sea-ink);font-size:14px}
|
|
28
|
+
main{flex-grow:1}
|
|
29
|
+
.site-footer{display:flex;flex-wrap:wrap;gap:12px;justify-content:space-between;padding:20px 40px;border-top:1px solid var(--line);font-size:13px;color:var(--ink-3)}
|
|
30
|
+
|
|
31
|
+
.wrap{padding:48px 40px;max-width:1080px}
|
|
32
|
+
.center{text-align:center}
|
|
33
|
+
.eyebrow{display:block;font-size:12px;font-weight:600;letter-spacing:.08em;color:var(--ink-3);margin-bottom:14px}
|
|
34
|
+
.lede{font-size:18px;color:var(--ink-2);max-width:560px}
|
|
35
|
+
.hint{font-size:13px;color:var(--ink-3)}
|
|
36
|
+
ul.plain{padding-left:18px;color:var(--ink-2);font-size:14px;line-height:1.8}
|
|
37
|
+
|
|
38
|
+
.btn{display:inline-flex;align-items:center;justify-content:center;height:40px;padding:0 16px;border-radius:8px;border:1px solid var(--line);background:#fff;color:var(--ink);font-weight:600;font-size:14px;font-family:inherit;cursor:pointer}
|
|
39
|
+
.btn-dark{background:var(--ink);color:#fff;border-color:var(--ink)}.btn-dark:hover{background:#000;color:#fff}
|
|
40
|
+
.btn-ghost{background:#fff;color:var(--ink)}.btn-ghost:hover{color:var(--ink);background:var(--bg-3)}
|
|
41
|
+
.btn-lg{height:46px;padding:0 20px;font-size:15px}
|
|
42
|
+
|
|
43
|
+
.hero{display:flex;flex-wrap:wrap;gap:48px;align-items:center;padding-top:72px}
|
|
44
|
+
.hero-copy{flex:1 1 380px;min-width:0}
|
|
45
|
+
.hero-copy h1{font-size:52px;max-width:620px}
|
|
46
|
+
.hero-copy p{font-size:18px;color:var(--ink-2);max-width:520px;margin-bottom:22px}
|
|
47
|
+
.hero-actions{display:flex;gap:12px;flex-wrap:wrap}
|
|
48
|
+
.hero-art{flex:1 1 320px;min-width:0;height:320px;border-radius:16px;background:var(--bg-2);display:flex;align-items:flex-end;justify-content:center;overflow:hidden}
|
|
49
|
+
.desk{position:relative;width:260px;height:14px;background:#6b5744;border-radius:4px;margin-bottom:110px}
|
|
50
|
+
.desk .leg{position:absolute;top:14px;width:10px;height:96px;background:#3f3f46}
|
|
51
|
+
.desk .leg:first-child{left:40px}.desk .leg:last-child{right:40px}
|
|
52
|
+
.desk.small{width:160px;height:10px;margin-bottom:70px}.desk.small .leg{height:60px;width:7px}.desk.small .leg:first-child{left:24px}.desk.small .leg:last-child{right:24px}
|
|
53
|
+
.desk.dark{background:#1f1f22}.desk.light{background:#c8a97e}
|
|
54
|
+
.desk.big{width:320px;height:16px;margin-bottom:150px}.desk.big .leg{height:130px;width:12px}.desk.big .leg:first-child{left:50px}.desk.big .leg:last-child{right:50px}
|
|
55
|
+
.desk[data-finish="Oak"]{background:#c8a97e}.desk[data-finish="Black"]{background:#1f1f22}.desk[data-finish="Walnut"]{background:#6b5744}
|
|
56
|
+
|
|
57
|
+
.tiles{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:20px;padding-top:0}
|
|
58
|
+
.tile{display:flex;flex-direction:column;gap:6px;padding:20px;border:1px solid var(--line);border-radius:12px;color:var(--ink)}
|
|
59
|
+
.tile strong{font-weight:600}.tile span{font-size:14px;color:var(--ink-2)}
|
|
60
|
+
.band{padding-top:0}.band-inner{padding:28px;border-radius:16px;background:var(--bg-3);border:1px solid var(--line)}
|
|
61
|
+
.band-inner p{color:var(--ink-2);margin:0}
|
|
62
|
+
|
|
63
|
+
.products{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:20px;margin-top:24px}
|
|
64
|
+
.product{display:flex;flex-direction:column;gap:4px;color:var(--ink)}
|
|
65
|
+
.product-art{height:200px;border-radius:14px;background:var(--bg-2);display:flex;align-items:flex-end;justify-content:center;overflow:hidden;margin-bottom:10px}
|
|
66
|
+
.product strong{font-weight:600}.product span{font-size:13px;color:var(--ink-2)}.product em{font-style:normal;color:var(--ink-3)}
|
|
67
|
+
|
|
68
|
+
.product-page{display:flex;flex-wrap:wrap;gap:48px}
|
|
69
|
+
.product-hero{flex:1 1 340px;min-width:0;height:440px;border-radius:16px;background:var(--bg-2);display:flex;align-items:flex-end;justify-content:center;overflow:hidden}
|
|
70
|
+
.product-form{flex:1 1 340px;min-width:0;display:flex;flex-direction:column;gap:20px}
|
|
71
|
+
.product-form h1{font-size:32px;margin:0}
|
|
72
|
+
.price{font-size:20px;color:var(--ink-2);margin:0}
|
|
73
|
+
.options{border:0;padding:0;margin:0}
|
|
74
|
+
.options legend{font-size:13px;font-weight:600;margin-bottom:10px}
|
|
75
|
+
.options .opt{display:inline-flex;align-items:center;height:40px;padding:0 16px;margin:0 8px 8px 0;border-radius:8px;border:1px solid #d4d4d8;font-size:14px;cursor:pointer;user-select:none}
|
|
76
|
+
.options .opt:has(input:checked){border:2px solid var(--ink);font-weight:600}
|
|
77
|
+
.options .opt input{margin:0 8px 0 0}
|
|
78
|
+
.qty-row{display:flex;align-items:center;gap:12px}.qty-row label{font-size:13px;font-weight:600}
|
|
79
|
+
.qty-row input{width:72px;height:40px;border-radius:8px;border:1px solid #d4d4d8;padding:0 10px;font:inherit}
|
|
80
|
+
|
|
81
|
+
.pricing .plans{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:20px;margin:28px 0 20px}
|
|
82
|
+
.plan{position:relative;display:flex;flex-direction:column;gap:12px;padding:24px;border:1px solid var(--line);border-radius:14px}
|
|
83
|
+
.plan.featured{border:2px solid var(--ink)}
|
|
84
|
+
.plan-badge{position:absolute;top:-12px;left:24px;padding:2px 10px;border-radius:999px;background:var(--ink);color:#fff;font-size:11px;font-weight:600}
|
|
85
|
+
.plan-name{font-size:14px;font-weight:600;color:var(--ink-2)}
|
|
86
|
+
.plan-price{font-size:32px;font-weight:700;letter-spacing:-.02em}.plan-price small{font-size:14px;font-weight:500;color:var(--ink-3)}
|
|
87
|
+
.plan-desc{font-size:13px;color:var(--ink-2)}
|
|
88
|
+
.pill{display:inline-flex;align-items:center;gap:8px;padding:4px 10px;border-radius:999px;background:var(--sea);border:1px solid var(--sea-line);color:var(--sea-ink);font-size:12px;font-weight:500}
|
|
89
|
+
|
|
90
|
+
.two-col{display:flex;flex-wrap:wrap;gap:48px}
|
|
91
|
+
.two-col>div{flex:1 1 300px;min-width:0}
|
|
92
|
+
.card-form{flex:1 1 360px;min-width:0;display:flex;flex-direction:column;gap:14px;padding:28px;border:1px solid var(--line);border-radius:16px}
|
|
93
|
+
.card-form label{display:flex;flex-direction:column;gap:6px;font-size:13px;font-weight:600}
|
|
94
|
+
.card-form input{height:42px;border-radius:8px;border:1px solid #d4d4d8;padding:0 12px;font:inherit;font-weight:400}
|
|
95
|
+
.card-form input.prefilled{background:var(--sea)}
|
|
96
|
+
.form-error{color:#b91c1c;font-size:13px;margin:0}
|
|
97
|
+
.total{display:flex;justify-content:space-between;font-size:15px;padding-top:8px;border-top:1px solid var(--line)}
|
|
98
|
+
.cart-lines{display:flex;flex-direction:column;gap:10px;margin:16px 0}
|
|
99
|
+
.cart-line{display:flex;gap:12px;align-items:center;padding:14px;border:1px solid var(--line);border-radius:12px}
|
|
100
|
+
.cart-line span{color:var(--ink-2);font-size:13px;flex-grow:1}.cart-line em{font-style:normal}
|
|
101
|
+
pre.code{padding:12px 14px;border-radius:8px;background:var(--bg-3);border:1px solid var(--line);font-family:'JetBrains Mono',monospace;font-size:13px;overflow-x:auto}
|
|
102
|
+
|
|
103
|
+
/* Recipe widgets */
|
|
104
|
+
.rc-chat{position:fixed;left:24px;bottom:24px;z-index:40;display:flex;align-items:center;gap:12px;max-width:360px;padding:12px 14px;border-radius:14px;background:#fff;border:1px solid var(--line);box-shadow:0 10px 30px rgba(0,0,0,.08);font-size:14px}
|
|
105
|
+
.rc-chat .avatar{width:36px;height:36px;border-radius:18px;background:var(--ink);color:#fff;display:flex;align-items:center;justify-content:center;font-weight:600;flex-shrink:0}
|
|
106
|
+
.rc-chat .msg strong{display:block;font-size:13px}.rc-chat .msg span{font-size:12px;color:var(--ink-3)}
|
|
107
|
+
.rc-exit{position:fixed;inset:0;z-index:50;background:rgba(24,24,27,.5);display:flex;align-items:center;justify-content:center;padding:16px}
|
|
108
|
+
.rc-exit .box{background:#fff;border-radius:16px;padding:28px;max-width:420px;width:100%;display:flex;flex-direction:column;gap:10px}
|
|
109
|
+
.rc-exit h3{margin:0;font-size:22px;letter-spacing:-.02em}
|
|
110
|
+
|
|
111
|
+
@media (max-width:900px){
|
|
112
|
+
.wrap{padding:32px 16px}.site-nav,.site-footer,.flash{padding-left:16px;padding-right:16px}
|
|
113
|
+
.site-nav nav{display:none}.hero-copy h1{font-size:36px}h1{font-size:32px}
|
|
114
|
+
.tiles,.products,.pricing .plans{grid-template-columns:1fr}
|
|
115
|
+
}
|
package/public/site.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Driftwood's own page behaviour: the bits a real site would have (variant picker, cart count,
|
|
2
|
+
// sign-in calling squid.identify). It also tells the panel what the visitor did on the page
|
|
3
|
+
// through `sqid:page` events, so scenarios can be ticked off.
|
|
4
|
+
(function(){
|
|
5
|
+
'use strict';
|
|
6
|
+
const page = document.body.dataset.page;
|
|
7
|
+
const tell = (what, detail) => document.dispatchEvent(new CustomEvent('sqid:page', { detail : { what, ...detail } }));
|
|
8
|
+
|
|
9
|
+
// Wait for the SDK (the snippet loads it async).
|
|
10
|
+
function whenSquid(cb, tries = 150){
|
|
11
|
+
if(window.squid && window.squid.engine){ return cb(window.squid); }
|
|
12
|
+
if(tries <= 0){ return; }
|
|
13
|
+
setTimeout(() => whenSquid(cb, tries - 1), 100);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Label the clicks that matter: a real site would do exactly this.
|
|
17
|
+
whenSquid(squid => {
|
|
18
|
+
document.querySelectorAll('[data-sqid-label]').forEach(el => {
|
|
19
|
+
try{ squid.labelClicks({ matches : `[data-sqid-label="${el.dataset.sqidLabel}"]`, label : el.dataset.sqidLabel, type : el.dataset.sqidType || 'key_event' }); }catch(error){ /* older SDK */ }
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
document.addEventListener('click', e => {
|
|
23
|
+
let el = e.target.closest('[data-sqid-label]');
|
|
24
|
+
if(el){ tell('label_click', { label : el.dataset.sqidLabel, type : el.dataset.sqidType || 'key_event' }); }
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Cart count (localStorage, nothing fancy)
|
|
28
|
+
const cartCount = () => Number(localStorage.getItem('driftwood.cart') || 0);
|
|
29
|
+
const el = document.getElementById('cart-count'); if(el){ el.textContent = String(cartCount()); }
|
|
30
|
+
if(page === 'cart' && new URLSearchParams(location.search).get('added')){ localStorage.setItem('driftwood.cart', String(cartCount() + 1)); if(el){ el.textContent = String(cartCount()); } }
|
|
31
|
+
if(page === 'cart' && new URLSearchParams(location.search).get('ordered')){ localStorage.setItem('driftwood.cart', '0'); if(el){ el.textContent = '0'; } }
|
|
32
|
+
|
|
33
|
+
// Product page: price and finish follow the picker; count switches for the scenario.
|
|
34
|
+
if(page === 'desk'){
|
|
35
|
+
let form = document.getElementById('product-form');
|
|
36
|
+
let switches = 0, hovers = 0, lastHover = null;
|
|
37
|
+
form.addEventListener('change', e => {
|
|
38
|
+
if(e.target.name === 'size'){ document.getElementById('size-label').textContent = e.target.value; document.getElementById('price').textContent = '$' + e.target.dataset.price; }
|
|
39
|
+
if(e.target.name === 'finish'){ document.getElementById('finish-label').textContent = e.target.value; document.getElementById('desk-art').dataset.finish = e.target.value; }
|
|
40
|
+
switches++; tell('variant_switch', { option : e.target.name, value : e.target.value, switches, hovers });
|
|
41
|
+
});
|
|
42
|
+
form.addEventListener('mouseover', e => {
|
|
43
|
+
let opt = e.target.closest('.opt'); if(!opt || opt === lastHover){ return; }
|
|
44
|
+
lastHover = opt; hovers++;
|
|
45
|
+
if(hovers % 3 === 0){ tell('variant_hover', { hovers, switches }); }
|
|
46
|
+
});
|
|
47
|
+
form.addEventListener('submit', () => tell('add_to_cart', { size : form.size.value, finish : form.finish.value, qty : form.qty.value }));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Cart page: a discount code that never works (the discount-codes signal), and sitting still.
|
|
51
|
+
if(page === 'cart'){
|
|
52
|
+
let btn = document.getElementById('apply-code');
|
|
53
|
+
btn && btn.addEventListener('click', () => { document.getElementById('code-error').classList.remove('hidden'); tell('discount_declined', {}); });
|
|
54
|
+
setTimeout(() => tell('cart_stall', { after_s : 45 }), 45 * 1000);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Demo form: prefill marker, stall detection (two fields touched, then a minute of nothing).
|
|
58
|
+
if(page === 'demo'){
|
|
59
|
+
let form = document.getElementById('demo-form');
|
|
60
|
+
let touched = new Set(), timer = null;
|
|
61
|
+
form.addEventListener('input', e => {
|
|
62
|
+
touched.add(e.target.name);
|
|
63
|
+
clearTimeout(timer);
|
|
64
|
+
if(touched.size >= 2){ timer = setTimeout(() => tell('form_stall', { fields : [...touched] }), 60 * 1000); }
|
|
65
|
+
});
|
|
66
|
+
form.addEventListener('submit', () => { clearTimeout(timer); tell('form_submit', { fields : [...touched] }); });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Sign in: tell Sqid who this is, then let the form go.
|
|
70
|
+
if(page === 'signin'){
|
|
71
|
+
let form = document.getElementById('signin-form');
|
|
72
|
+
form.addEventListener('submit', e => {
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
let email = form.email.value.trim();
|
|
75
|
+
tell('identify', { email });
|
|
76
|
+
whenSquid(async squid => { try{ await squid.identify({ email }); }catch(error){ /* reported by the SDK */ } form.submit(); }, 20);
|
|
77
|
+
setTimeout(() => form.submit(), 2500); // never strand the person
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Pricing visits (deliberation) and exit intent, counted across pages.
|
|
82
|
+
if(page === 'pricing'){
|
|
83
|
+
let n = Number(sessionStorage.getItem('driftwood.pricing_visits') || 0) + 1;
|
|
84
|
+
sessionStorage.setItem('driftwood.pricing_visits', String(n));
|
|
85
|
+
tell('pricing_visit', { visits : n });
|
|
86
|
+
}
|
|
87
|
+
let exited = false;
|
|
88
|
+
document.addEventListener('mouseleave', e => { if(!exited && e.clientY <= 0){ exited = true; tell('exit_intent', {}); } });
|
|
89
|
+
})();
|
package/src/index.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// sqid-playground: argv in, a running Driftwood site out.
|
|
2
|
+
//
|
|
3
|
+
// sqid-playground [--port 3000] [--site <id>] [--no-open] [--api <origin>]
|
|
4
|
+
//
|
|
5
|
+
// Signs in through the sqid CLI's credentials (run `sqid auth login` once, or let this do it),
|
|
6
|
+
// finds the account's Sandbox site, allows this origin on it, and serves the site with the
|
|
7
|
+
// Sqid panel docked on the right.
|
|
8
|
+
|
|
9
|
+
import { createServer } from 'node:http';
|
|
10
|
+
import { spawn } from 'node:child_process';
|
|
11
|
+
import { createApp } from './server.js';
|
|
12
|
+
import { Bridge } from './sqid.js';
|
|
13
|
+
|
|
14
|
+
const USAGE = `Usage: sqid-playground [options]
|
|
15
|
+
|
|
16
|
+
Runs the Sqid Playground on localhost: a real-looking website (Driftwood) with the Sqid panel
|
|
17
|
+
docked on the side. Watch a visitor get identified, try the scenarios and recipes, see the
|
|
18
|
+
record that goes out, then go live on your own site.
|
|
19
|
+
|
|
20
|
+
Options:
|
|
21
|
+
--port <n> Port to listen on (default 3000)
|
|
22
|
+
--site <id> Use this site instead of the account's Sandbox
|
|
23
|
+
--no-open Do not open the browser
|
|
24
|
+
--api <origin> Sqid API origin (default https://app.sqid.dev)
|
|
25
|
+
-h, --help This text
|
|
26
|
+
|
|
27
|
+
Needs a Sqid sign-in: run "npx -y @sqid-dev/sqid auth login" first, or this will ask.`;
|
|
28
|
+
|
|
29
|
+
export function parse(argv){
|
|
30
|
+
let flags = { port : 3000, open : true };
|
|
31
|
+
for(let i = 0; i < argv.length; i++){
|
|
32
|
+
let a = argv[i];
|
|
33
|
+
if(a === '-h' || a === '--help'){ flags.help = true; }
|
|
34
|
+
else if(a === '--no-open'){ flags.open = false; }
|
|
35
|
+
else if(a === '--port'){ flags.port = Number(argv[++i]); }
|
|
36
|
+
else if(a === '--site'){ flags.site = argv[++i]; }
|
|
37
|
+
else if(a === '--api'){ flags.api = argv[++i]; }
|
|
38
|
+
else if(a.startsWith('--port=')){ flags.port = Number(a.slice(7)); }
|
|
39
|
+
else { throw Object.assign(new Error(`Unknown option ${a}\n\n${USAGE}`), { exit : 2 }); }
|
|
40
|
+
}
|
|
41
|
+
if(!Number.isInteger(flags.port) || flags.port < 1 || flags.port > 65535){ throw Object.assign(new Error('--port must be a number between 1 and 65535'), { exit : 2 }); }
|
|
42
|
+
return flags;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function main(argv){
|
|
46
|
+
let flags = parse(argv);
|
|
47
|
+
if(flags.help){ console.log(USAGE); return; }
|
|
48
|
+
|
|
49
|
+
let bridge = new Bridge(flags);
|
|
50
|
+
let origin = `http://localhost:${flags.port}`;
|
|
51
|
+
|
|
52
|
+
process.stdout.write('Sqid Playground\n');
|
|
53
|
+
let ready = await bridge.prepare(origin); // signs in if needed, finds the Sandbox, allows the origin
|
|
54
|
+
process.stdout.write(` Signed in as ${ready.email}\n`);
|
|
55
|
+
process.stdout.write(` Site: ${ready.site.name} (${ready.site.id})${ready.site.sandbox ? ', Sandbox' : ''}\n`);
|
|
56
|
+
process.stdout.write(` Origin ${origin} ${ready.originAdded ? 'allowed on the site' : 'already allowed'}\n`);
|
|
57
|
+
|
|
58
|
+
let app = createApp(bridge);
|
|
59
|
+
let server = createServer(app);
|
|
60
|
+
await new Promise((resolve, reject) => { server.once('error', reject); server.listen(flags.port, resolve); });
|
|
61
|
+
process.stdout.write(`\n Open ${origin}\n\n`);
|
|
62
|
+
|
|
63
|
+
if(flags.open){ openBrowser(origin); }
|
|
64
|
+
return server;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function openBrowser(url){
|
|
68
|
+
let cmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open';
|
|
69
|
+
try{ spawn(cmd, [url], { stdio : 'ignore', detached : true, shell : process.platform === 'win32' }).unref(); }catch(error){ /* the URL is printed */ }
|
|
70
|
+
}
|
package/src/layout.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Driftwood page shell: nav, the page body, the Sqid snippet before </head>, the panel after the
|
|
2
|
+
// body. One template, every page.
|
|
3
|
+
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
|
|
8
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const pages = path.join(here, 'pages');
|
|
10
|
+
|
|
11
|
+
export const PAGES = {
|
|
12
|
+
'/' : 'home',
|
|
13
|
+
'/desks' : 'desks',
|
|
14
|
+
'/desk' : 'desk',
|
|
15
|
+
'/pricing' : 'pricing',
|
|
16
|
+
'/demo' : 'demo',
|
|
17
|
+
'/cart' : 'cart',
|
|
18
|
+
'/signin' : 'signin',
|
|
19
|
+
'/teams' : 'teams'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const TITLES = {
|
|
23
|
+
home : 'Driftwood: standing desks for teams',
|
|
24
|
+
desks : 'Desks',
|
|
25
|
+
desk : 'Driftwood Rise',
|
|
26
|
+
pricing : 'Team pricing',
|
|
27
|
+
demo : 'Book a demo',
|
|
28
|
+
cart : 'Your cart',
|
|
29
|
+
signin : 'Sign in',
|
|
30
|
+
teams : 'Driftwood for teams',
|
|
31
|
+
notfound : 'Not found'
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const esc = (s) => String(s ?? '').replace(/[&<>"']/g, c => ({ '&' : '&', '<' : '<', '>' : '>', '"' : '"', "'" : ''' }[c]));
|
|
35
|
+
|
|
36
|
+
function body(page){
|
|
37
|
+
let file = path.join(pages, `${page}.html`);
|
|
38
|
+
return fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : '<section class="wrap"><h1>Not found</h1><p>That page is not part of the demo.</p></section>';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function render(page, { bridge, path : route, query }){
|
|
42
|
+
let site = bridge.site;
|
|
43
|
+
let nav = (href, label) => `<a href="${href}"${route === href ? ' aria-current="page" class="on"' : ''}>${label}</a>`;
|
|
44
|
+
let flash = '';
|
|
45
|
+
if(query.added) { flash = `<div class="flash" role="status">Added to your cart. Now leave it there for a bit; that is a cart stall.</div>`; }
|
|
46
|
+
if(query.sent) { flash = `<div class="flash" role="status">Demo requested. That was a conversion key event; the panel's Live tab has it.</div>`; }
|
|
47
|
+
if(query.ordered) { flash = `<div class="flash" role="status">Order placed (not really). Thanks for testing.</div>`; }
|
|
48
|
+
if(query.signed_in) { flash = `<div class="flash" role="status">Signed in as ${esc(query.email)}. The page called squid.identify() with that email.</div>`; }
|
|
49
|
+
|
|
50
|
+
return `<!doctype html>
|
|
51
|
+
<html lang="en">
|
|
52
|
+
<head>
|
|
53
|
+
<meta charset="utf-8">
|
|
54
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
55
|
+
<title>${esc(TITLES[page] || 'Driftwood')} · Driftwood</title>
|
|
56
|
+
<meta name="robots" content="noindex">
|
|
57
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
58
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
59
|
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
|
|
60
|
+
<link rel="stylesheet" href="/assets/site.css">
|
|
61
|
+
<link rel="stylesheet" href="/assets/panel.css">
|
|
62
|
+
<script>window.SQID_PLAYGROUND = ${JSON.stringify({ site : { id : site.id, name : site.name, sandbox : !!site.sandbox }, page, path : route })};</script>
|
|
63
|
+
${bridge.snippet()}
|
|
64
|
+
</head>
|
|
65
|
+
<body data-page="${esc(page)}">
|
|
66
|
+
<div class="pg-shell">
|
|
67
|
+
<div class="pg-site">
|
|
68
|
+
<header class="site-nav">
|
|
69
|
+
<a href="/" class="brand" aria-label="Driftwood home">Driftwood</a>
|
|
70
|
+
<nav>${nav('/desks', 'Desks')}${nav('/teams', 'Teams')}${nav('/pricing', 'Pricing')}</nav>
|
|
71
|
+
<div class="nav-right">${nav('/signin', 'Sign in')}<a href="/cart" class="cart-link" data-sqid-label="view_cart" data-sqid-type="key_event">Cart <span id="cart-count">0</span></a><a href="/demo" class="btn btn-dark" data-sqid-label="book_demo_nav" data-sqid-type="key_event">Book a demo</a></div>
|
|
72
|
+
</header>
|
|
73
|
+
${flash}
|
|
74
|
+
<main id="main">
|
|
75
|
+
${body(page)}
|
|
76
|
+
</main>
|
|
77
|
+
<footer class="site-footer">
|
|
78
|
+
<span>Driftwood is a made-up company. This site exists so you can watch Sqid work.</span>
|
|
79
|
+
<span><a href="https://docs.sqid.dev">Sqid docs</a> · <a href="https://github.com/sqid-dev/playground">Source</a></span>
|
|
80
|
+
</footer>
|
|
81
|
+
</div>
|
|
82
|
+
<aside class="pg-panel" id="sqid-panel" aria-label="Sqid panel"></aside>
|
|
83
|
+
</div>
|
|
84
|
+
<script src="/assets/recipes.js"></script>
|
|
85
|
+
<script src="/assets/site.js"></script>
|
|
86
|
+
<script src="/assets/panel.js"></script>
|
|
87
|
+
</body>
|
|
88
|
+
</html>`;
|
|
89
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<section class="wrap two-col">
|
|
2
|
+
<div>
|
|
3
|
+
<h1>Your cart</h1>
|
|
4
|
+
<div class="cart-lines" id="cart-lines">
|
|
5
|
+
<div class="cart-line"><strong>Driftwood Rise</strong><span>60 in · Walnut · Qty 1</span><em>$749</em></div>
|
|
6
|
+
</div>
|
|
7
|
+
<p class="hint">Sit here and do nothing for a while. On a real site with Signals on, that is a cart stall. The discount box below is the discount-codes signal.</p>
|
|
8
|
+
</div>
|
|
9
|
+
<form class="card-form" action="/cart/checkout" method="post" id="checkout-form">
|
|
10
|
+
<label>Discount code<input name="code" type="text" placeholder="Try SAVE10 (it will not work)" autocomplete="off"></label>
|
|
11
|
+
<button type="button" class="btn btn-ghost" id="apply-code" data-sqid-label="apply_discount" data-sqid-type="key_event">Apply</button>
|
|
12
|
+
<p class="form-error hidden" id="code-error">That code is not valid.</p>
|
|
13
|
+
<div class="total"><span>Total</span><strong>$749</strong></div>
|
|
14
|
+
<button type="submit" class="btn btn-dark btn-lg" data-sqid-label="checkout" data-sqid-type="conversion">Place order</button>
|
|
15
|
+
</form>
|
|
16
|
+
</section>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<section class="wrap two-col">
|
|
2
|
+
<div>
|
|
3
|
+
<h1>Book a demo</h1>
|
|
4
|
+
<p>A 20 minute walkthrough with a desk specialist. If Sqid knows you, the form is already filled in.</p>
|
|
5
|
+
<ul class="plain">
|
|
6
|
+
<li>Prefilled by the Form prefill recipe when it is on</li>
|
|
7
|
+
<li>Fill two fields, then stop for a minute: that is a form stall</li>
|
|
8
|
+
<li>Send it: a conversion key event</li>
|
|
9
|
+
</ul>
|
|
10
|
+
</div>
|
|
11
|
+
<form class="card-form" action="/demo" method="post" id="demo-form">
|
|
12
|
+
<label>Name<input name="name" type="text" autocomplete="off" required></label>
|
|
13
|
+
<label>Work email<input name="email" type="email" autocomplete="off" required></label>
|
|
14
|
+
<label>Company<input name="company" type="text" autocomplete="off"></label>
|
|
15
|
+
<label>How many desks?<input name="desks" type="text" placeholder="e.g. 80" autocomplete="off"></label>
|
|
16
|
+
<label>When works?<input name="when" type="text" placeholder="Next week, mornings" autocomplete="off"></label>
|
|
17
|
+
<button type="submit" class="btn btn-dark btn-lg" data-sqid-label="request_demo" data-sqid-type="conversion">Request a demo</button>
|
|
18
|
+
</form>
|
|
19
|
+
</section>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<section class="wrap product-page">
|
|
2
|
+
<div class="product-hero" aria-hidden="true"><div class="desk big" id="desk-art"><span class="leg"></span><span class="leg"></span></div></div>
|
|
3
|
+
<form class="product-form" action="/cart/add" method="post" id="product-form">
|
|
4
|
+
<span class="eyebrow">DRIFTWOOD RISE</span>
|
|
5
|
+
<h1>Driftwood Rise</h1>
|
|
6
|
+
<p class="price" id="price">$749</p>
|
|
7
|
+
<fieldset class="options" data-option="Size">
|
|
8
|
+
<legend>Size: <span id="size-label">60 in</span></legend>
|
|
9
|
+
<label class="opt"><input type="radio" name="size" value="48 in" data-price="649">48 in</label>
|
|
10
|
+
<label class="opt"><input type="radio" name="size" value="60 in" data-price="749" checked>60 in</label>
|
|
11
|
+
<label class="opt"><input type="radio" name="size" value="72 in" data-price="899">72 in</label>
|
|
12
|
+
</fieldset>
|
|
13
|
+
<fieldset class="options" data-option="Finish">
|
|
14
|
+
<legend>Finish: <span id="finish-label">Walnut</span></legend>
|
|
15
|
+
<label class="opt"><input type="radio" name="finish" value="Walnut" checked>Walnut</label>
|
|
16
|
+
<label class="opt"><input type="radio" name="finish" value="Oak">Oak</label>
|
|
17
|
+
<label class="opt"><input type="radio" name="finish" value="Black">Black</label>
|
|
18
|
+
</fieldset>
|
|
19
|
+
<div class="qty-row"><label for="qty">Qty</label><input id="qty" name="qty" type="number" min="1" max="500" value="1"></div>
|
|
20
|
+
<button type="submit" class="btn btn-dark btn-lg" data-sqid-label="add_to_cart" data-sqid-type="key_event">Add to cart</button>
|
|
21
|
+
<p class="hint">Hover and switch between sizes a few times without adding to cart. The panel's Live tab shows what the SDK saw.</p>
|
|
22
|
+
</form>
|
|
23
|
+
</section>
|