-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
434 lines (397 loc) · 12.4 KB
/
Copy pathindex.html
File metadata and controls
434 lines (397 loc) · 12.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Lume - Dev Playground</title>
<link rel="stylesheet" href="./src/lume.css" />
<style>
:root {
--bg-canvas: #0f1117;
--bg-surface: #181b24;
--bg-surface-elevated: #222634;
--border-subtle: #2d3348;
--border-strong: #404863;
--text-primary: #f0f3f8;
--text-secondary: #9ba3b8;
--text-muted: #626b84;
--accent-gradient: linear-gradient(135deg, #f5af19 0%, #f12711 100%);
--font-sans:
-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
background-color: var(--bg-canvas);
color: var(--text-primary);
font-family: var(--font-sans);
line-height: 1.6;
padding: 40px 20px 250px;
}
.container {
max-width: 900px;
margin: 0 auto;
display: flex;
flex-direction: column;
gap: 32px;
}
header.app-header {
display: flex;
align-items: center;
gap: 20px;
padding-bottom: 24px;
border-bottom: 1px solid var(--border-subtle);
}
.brand-logo {
width: 56px;
height: 56px;
flex-shrink: 0;
}
.header-info h1 {
font-size: 28px;
font-weight: 700;
letter-spacing: -0.02em;
}
.header-info p {
color: var(--text-secondary);
font-size: 14px;
}
.card {
background: var(--bg-surface);
border: 1px solid var(--border-subtle);
border-radius: 12px;
padding: 24px;
display: flex;
flex-direction: column;
gap: 16px;
}
.card h2 {
font-size: 18px;
font-weight: 600;
color: var(--text-primary);
display: flex;
align-items: center;
gap: 8px;
}
.card-description {
color: var(--text-secondary);
font-size: 14px;
}
.interactive-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 16px;
margin-top: 8px;
}
.btn {
appearance: none;
background: var(--bg-surface-elevated);
color: var(--text-primary);
border: 1px solid var(--border-strong);
border-radius: 8px;
padding: 12px 18px;
font-size: 14px;
font-weight: 500;
cursor: pointer;
text-align: center;
transition:
background 0.15s ease,
border-color 0.15s ease,
transform 0.1s ease;
user-select: none;
}
.btn:hover {
background: #2b3042;
border-color: #586386;
}
.btn:active {
transform: scale(0.98);
}
.btn-accent {
background: var(--accent-gradient);
color: #ffffff;
border: none;
font-weight: 600;
}
.btn-accent:hover {
opacity: 0.92;
}
.dynamic-shelf {
display: flex;
flex-wrap: wrap;
gap: 12px;
min-height: 48px;
padding: 12px;
background: var(--bg-canvas);
border: 1px dashed var(--border-subtle);
border-radius: 8px;
align-items: center;
}
.dynamic-tag {
background: var(--bg-surface-elevated);
border: 1px solid var(--border-strong);
padding: 6px 12px;
border-radius: 6px;
font-size: 13px;
display: inline-flex;
align-items: center;
gap: 8px;
cursor: help;
}
.dynamic-tag .remove-btn {
background: none;
border: none;
color: var(--text-muted);
cursor: pointer;
font-size: 14px;
padding: 0 2px;
}
.dynamic-tag .remove-btn:hover {
color: #ff5c5c;
}
.prose-sample {
background: var(--bg-canvas);
padding: 16px 20px;
border-radius: 8px;
border-left: 3px solid #f5af19;
color: var(--text-secondary);
font-size: 15px;
line-height: 1.8;
}
.status-badge {
display: inline-flex;
align-items: center;
gap: 6px;
font-size: 12px;
font-family: var(--font-mono);
background: var(--bg-surface-elevated);
padding: 4px 10px;
border-radius: 999px;
border: 1px solid var(--border-subtle);
color: #4ade80;
}
.status-dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: #4ade80;
}
</style>
</head>
<body>
<div class="container">
<header class="app-header">
<img src="./branding/lume-logo.svg" alt="Lume Logo" class="brand-logo" />
<div class="header-info">
<h1>Lume Development Playground</h1>
<p>Zero-dependency tooltip engine with smart collision and DOM mutation tracking.</p>
</div>
<div style="margin-left: auto">
<span class="status-badge"><span class="status-dot"></span> Local Dev</span>
</div>
</header>
<section class="card">
<h2>■ Directional Placement & Smart Collision</h2>
<p class="card-description">
Test tooltip positioning and auto-flip behavior across all four vectors.
</p>
<div class="interactive-grid">
<button
class="btn"
data-lume="Vector calculated above target element."
data-lume-title="Top Vector"
data-lume-direction="top"
>
Top Vector
</button>
<button
class="btn"
data-lume="Vector calculated below target element."
data-lume-title="Bottom Vector"
data-lume-direction="bottom"
>
Bottom Vector
</button>
<button
class="btn"
data-lume="Vector positioned to the left boundary."
data-lume-title="Left Vector"
data-lume-direction="left"
>
Left Vector
</button>
<button
class="btn"
data-lume="Vector positioned to the right boundary."
data-lume-title="Right Vector"
data-lume-direction="right"
>
Right Vector
</button>
</div>
</section>
<section class="card">
<h2>■ Inline Text Trigger Demonstration</h2>
<div class="prose-sample">
StaticCanvas web modules embed
<span
class="lume-inline"
data-lume="High-performance client positioning with hardware transforms."
data-lume-direction="top"
data-lume-title="Core Engine"
>
Lume Tooltips
</span>
into natural prose with minimal DOM overhead.
</div>
</section>
<section class="card">
<h2>■ Rich HTML & Custom Offset</h2>
<p class="card-description">
Demonstrate raw HTML content injection and per-element pixel spacing offsets.
</p>
<div class="interactive-grid">
<button
class="btn"
data-lume-title="System Health"
data-lume-content="Status: <span style='color: #4ade80; font-weight: 600;'>99.98% Uptime</span><br><small style='color: #9ba3b8;'>Latency: 14ms (p99)</small>"
data-lume-direction="bottom"
>
HTML Content
</button>
<button
class="btn"
data-lume="This tooltip has an offset of 28px away from the trigger button."
data-lume-title="Extended Spacing"
data-lume-offset="28"
data-lume-direction="top"
>
Custom Offset (28px)
</button>
</div>
</section>
<section class="card">
<h2>■ Custom Theming Variants</h2>
<p class="card-description">
Demonstrate per-element styling using <code>data-lume-class</code>.
</p>
<style>
.lume-tooltip.demo-danger {
--lume-bg: #dc2626;
--lume-text: #ffffff;
--lume-accent: rgba(255, 255, 255, 0.25);
}
.lume-tooltip.demo-success {
--lume-bg: #059669;
--lume-text: #ffffff;
--lume-accent: rgba(255, 255, 255, 0.25);
}
.lume-tooltip.demo-violet {
--lume-bg: #4f46e5;
--lume-text: #ffffff;
--lume-accent: rgba(255, 255, 255, 0.25);
}
</style>
<div class="interactive-grid">
<button
class="btn"
data-lume="Irreversible operation on production servers!"
data-lume-title="Critical Danger"
data-lume-class="demo-danger"
data-lume-direction="top"
>
Danger Theme
</button>
<button
class="btn"
data-lume="All 48 test suites passed with 100% coverage."
data-lume-title="Build Successful"
data-lume-class="demo-success"
data-lume-direction="top"
>
Success Theme
</button>
<button
class="btn"
data-lume="Custom brand palette override via CSS variables."
data-lume-title="Indigo Variant"
data-lume-class="demo-violet"
data-lume-direction="top"
>
Indigo Theme
</button>
</div>
</section>
<section class="card">
<h2>■ Programmatic API Controls</h2>
<p class="card-description">Invoke instance methods directly from JavaScript.</p>
<div style="display: flex; gap: 12px; align-items: center; flex-wrap: wrap">
<button
id="targetElement"
class="btn btn-accent"
data-lume="Programmatically triggered tooltip content"
data-lume-title="API Target"
>
Programmatic Target
</button>
<button id="progShowBtn" class="btn">lume.show(target)</button>
<button id="progHideBtn" class="btn">lume.hide()</button>
</div>
</section>
<section class="card">
<h2>■ Dynamic Nodes (MutationObserver Auto-Init & Orphan Cleanup)</h2>
<div style="display: flex; gap: 12px">
<button id="addNodeBtn" class="btn btn-accent">+ Inject Node</button>
<button id="clearNodesBtn" class="btn">Clear Nodes</button>
</div>
<div id="dynamicShelf" class="dynamic-shelf">
<span
class="dynamic-tag"
data-lume="I was present in the initial DOM tree."
data-lume-title="Initial Node"
>
Initial Node
</span>
</div>
</section>
</div>
<script type="module">
import { Lume } from './src/lume.js';
const lume = new Lume({ smart: true, offset: 12 });
window.lumeInstance = lume;
// Programmatic controls demo
const targetEl = document.getElementById('targetElement');
document.getElementById('progShowBtn').addEventListener('click', () => {
lume.show(targetEl);
});
document.getElementById('progHideBtn').addEventListener('click', () => {
lume.hide();
});
let counter = 1;
const shelf = document.getElementById('dynamicShelf');
const addBtn = document.getElementById('addNodeBtn');
const clearBtn = document.getElementById('clearNodesBtn');
addBtn.addEventListener('click', () => {
const tag = document.createElement('span');
tag.className = 'dynamic-tag';
tag.setAttribute('data-lume', `Dynamically bound node #${counter}`);
tag.setAttribute('data-lume-title', `Dynamic Node #${counter}`);
tag.setAttribute('data-lume-direction', counter % 2 === 0 ? 'top' : 'bottom');
tag.innerHTML = `Dynamic #${counter} <button class="remove-btn" title="Remove">×</button>`;
tag.querySelector('.remove-btn').addEventListener('click', (e) => {
e.stopPropagation();
tag.remove();
});
shelf.appendChild(tag);
counter++;
});
clearBtn.addEventListener('click', () => {
shelf.innerHTML = '';
});
</script>
</body>
</html>