-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathin-page.html
More file actions
208 lines (187 loc) · 7.54 KB
/
Copy pathin-page.html
File metadata and controls
208 lines (187 loc) · 7.54 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>In your tests — snapDiff demo</title>
<link rel="preconnect" href="https://cdnjs.cloudflare.com" crossorigin />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css" crossorigin="anonymous" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Unbounded:wght@400;700;900&family=Mansalva&family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600;700&display=swap" />
<link rel="stylesheet" href="./shared.css" />
<style>
/* ── Toolbar ── */
.toolbar {
display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
padding: 14px;
background: var(--surface);
border: 2px solid var(--border);
border-radius: var(--radius);
margin-bottom: 20px;
box-shadow: var(--shadow);
}
/* ── Fixtures grid ── */
.grid {
display: grid; gap: 20px;
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.fixture {
background: var(--surface);
border: 2px solid var(--border);
border-radius: var(--radius);
padding: 18px;
}
.fixture > h2 {
margin: 0 0 10px;
font-family: var(--font-mono);
font-size: 12px;
text-transform: uppercase;
letter-spacing: 1.4px;
color: var(--text-muted);
font-weight: 700;
}
/* ───────────────────────────────────────────────
Below: the *captured* fixtures.
Don't touch — these are the visual baselines.
─────────────────────────────────────────────── */
.hero {
background: linear-gradient(135deg, #6f5cff, #2f6df6);
color: white; padding: 28px; border-radius: 12px;
box-shadow: 0 8px 24px rgba(47, 109, 246, .35);
}
.hero .badge {
display: inline-block; padding: 3px 10px; background: rgba(255,255,255,.18);
border-radius: 999px; font-size: 11px; letter-spacing: .04em;
text-transform: uppercase;
}
.hero h3 { margin: 10px 0 4px; font-size: 20px; font-family: 'DM Sans', sans-serif; }
.hero p { margin: 0; opacity: .85; font-size: 13px; }
.pricing { display: grid; gap: 8px; }
.pricing .row {
display: flex; justify-content: space-between; padding: 10px 12px;
background: #f9fafb; border-radius: 6px; border: 1px solid #e6e8ee;
color: #1a1d24;
}
.pricing .row strong { font-variant-numeric: tabular-nums; }
.pricing .row.highlight { background: #fff8e1; border-color: #f5d877; }
.avatar-row { display: flex; gap: 12px; align-items: center; }
.avatar {
width: 56px; height: 56px; border-radius: 50%;
background: conic-gradient(from 220deg, #ff8a3d, #d63d4d, #6f5cff, #2f6df6, #ff8a3d);
display: grid; place-items: center; color: white; font-weight: 700; font-size: 22px;
box-shadow: inset 0 0 0 3px white, 0 4px 12px rgba(0,0,0,.15);
}
.avatar-meta strong { display: block; color: #1a1d24; }
.avatar-meta span { opacity: .7; font-size: 12px; color: #1a1d24; }
/* Mutation styles, applied via toggle */
body.mutated .hero { background: linear-gradient(135deg, #d63d4d, #ff8a3d); }
body.mutated .hero h3::after { content: ' (sale!)'; }
body.mutated .pricing .row:nth-child(2) strong { color: #d63d4d; }
body.mutated .pricing .row.highlight { background: #ffe5d0; border-color: #ff8a3d; }
body.mutated .avatar-meta strong::after { content: ' Pro'; color: #6f5cff; }
</style>
</head>
<body>
<section class="hero-block compact">
<img src="./assets/mrsnapdom-greet.png" alt="Mr SnapDOM saluting" class="hero-mascot" width="110" height="120" />
<h1><span class="accent">02</span> <span class="accent-ink">In your tests</span></h1>
<p class="tagline">
Explicit <code>runner.test()</code> calls. Hit <em>Run</em>, toggle a mutation, and
re-run to watch snapDiff catch the drift.
</p>
</section>
<div class="section-label">Controls</div>
<main class="page-main">
<div class="toolbar">
<button id="run" class="btn btn-primary">
<i class="fas fa-play"></i> Run tests
</button>
<button id="mutate" class="btn btn-ink">
<i class="fas fa-shuffle"></i> Toggle mutation
</button>
<button id="reset" class="btn btn-danger">
<i class="fas fa-trash"></i> Clear baselines
</button>
<label class="field">
<input type="checkbox" id="includeAA" />
count anti-aliasing
</label>
<label class="field">
threshold
<input type="range" id="threshold" min="0" max="0.5" step="0.01" value="0.1" />
<span id="thresholdVal">0.10</span>
</label>
</div>
<div class="section-label" style="padding: 0; margin: 22px 0 14px;">Fixtures</div>
<div class="grid">
<div class="fixture" data-test="hero">
<h2>Hero</h2>
<div class="hero">
<span class="badge">New</span>
<h3>Ship faster</h3>
<p>Capture, diff and review — all client-side.</p>
</div>
</div>
<div class="fixture" data-test="pricing">
<h2>Pricing rows</h2>
<div class="pricing">
<div class="row"><span>Hobby</span><strong>$0</strong></div>
<div class="row highlight"><span>Pro</span><strong>$19</strong></div>
<div class="row"><span>Team</span><strong>$49</strong></div>
</div>
</div>
<div class="fixture" data-test="avatar">
<h2>Avatar</h2>
<div class="avatar-row">
<div class="avatar">JM</div>
<div class="avatar-meta">
<strong>Juan Martin</strong>
<span>zumerlab</span>
</div>
</div>
</div>
</div>
</main>
<nav class="page-nav">
<a href="./">Demos</a>
<a href="./auto.html">Auto</a>
<a href="./in-page.html" class="current">In tests</a>
<a href="./components-test.html">Components</a>
<a href="https://github.com/zumerlab/snapdiff" target="_blank" rel="noopener">GitHub</a>
<a href="https://www.npmjs.com/package/@zumer/snapdiff" target="_blank" rel="noopener">npm</a>
<a href="https://snapdom.dev/" target="_blank" rel="noopener">snapDOM ↗</a>
</nav>
<script type="module">
import { snapdom } from 'https://esm.sh/@zumer/snapdom@2.9.0'
import { createRunner, Reporter } from './lib/snapdiff.mjs'
const runner = createRunner({
snapdom,
namespace: 'demo',
threshold: 0.1,
failureRatio: 0,
snapdomOptions: { embedFonts: true },
})
runner.test('hero', () => document.querySelector('[data-test="hero"]'))
runner.test('pricing', () => document.querySelector('[data-test="pricing"]'))
runner.test('avatar', () => document.querySelector('[data-test="avatar"]'))
const reporter = new Reporter(runner, { onClose: () => {} })
document.getElementById('run').onclick = async () => {
runner.threshold = parseFloat(document.getElementById('threshold').value)
reporter.mount()
await reporter.runAndShow()
}
document.getElementById('mutate').onclick = () => {
document.body.classList.toggle('mutated')
}
document.getElementById('reset').onclick = async () => {
if (!confirm('Delete all baselines for namespace "demo"?')) return
await runner.store.clear()
alert('Baselines cleared. Run again to record fresh ones.')
}
const thr = document.getElementById('threshold')
const thrVal = document.getElementById('thresholdVal')
thr.oninput = () => thrVal.textContent = parseFloat(thr.value).toFixed(2)
</script>
</body>
</html>