-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
343 lines (310 loc) · 13.2 KB
/
index.html
File metadata and controls
343 lines (310 loc) · 13.2 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>featuredrop — Vanilla JS Example</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #0f172a; color: #e2e8f0; }
.layout { display: flex; min-height: 100vh; }
/* Sidebar */
.sidebar { width: 260px; background: #1e293b; padding: 20px 0; border-right: 1px solid #334155; display: flex; flex-direction: column; }
.sidebar h2 { padding: 0 20px 16px; font-size: 14px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; }
.nav-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 20px; color: #cbd5e1; cursor: pointer; transition: background 0.15s; }
.nav-item:hover { background: #334155; }
.nav-item.active { background: #334155; color: #f8fafc; }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 9999px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.badge-new { color: #b45309; background: rgba(245, 158, 11, 0.15); }
.badge-type { font-size: 9px; padding: 1px 6px; }
.badge-feature { color: #16a34a; background: rgba(34, 197, 94, 0.12); }
.badge-improvement { color: #2563eb; background: rgba(59, 130, 246, 0.12); }
.badge-bug-fix { color: #dc2626; background: rgba(239, 68, 68, 0.12); }
/* Main content */
.main { flex: 1; padding: 40px; max-width: 800px; }
.main h1 { font-size: 24px; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; }
.main > p { color: #94a3b8; margin-bottom: 24px; }
/* Filters */
.filters { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-btn { background: #1e293b; color: #94a3b8; border: 1px solid #334155; padding: 6px 14px; border-radius: 9999px; cursor: pointer; font-size: 13px; transition: all 0.15s; }
.filter-btn:hover { border-color: #475569; color: #e2e8f0; }
.filter-btn.active { background: #f59e0b; color: #0f172a; border-color: #f59e0b; font-weight: 600; }
/* Feature cards */
.feature-card { background: #1e293b; border: 1px solid #334155; border-radius: 10px; padding: 16px; margin-bottom: 12px; transition: border-color 0.15s; }
.feature-card:hover { border-color: #475569; }
.feature-card-header { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.feature-card h3 { font-size: 16px; margin-bottom: 4px; }
.feature-card p { font-size: 14px; color: #94a3b8; line-height: 1.5; }
.feature-card-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.feature-card-date { font-size: 12px; color: #64748b; }
.dismiss-btn { background: none; color: #64748b; border: 1px solid #334155; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; transition: all 0.15s; }
.dismiss-btn:hover { color: #e2e8f0; border-color: #475569; }
/* Count badge */
.count-badge { background: #f59e0b; color: #0f172a; font-size: 12px; font-weight: 700; min-width: 22px; height: 22px; border-radius: 9999px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; }
/* Actions */
.actions { display: flex; gap: 8px; margin-top: 20px; }
button.primary { background: #3b82f6; color: white; border: none; padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: background 0.15s; }
button.primary:hover { background: #2563eb; }
button.secondary { background: transparent; color: #94a3b8; border: 1px solid #334155; padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 14px; transition: all 0.15s; }
button.secondary:hover { color: #e2e8f0; border-color: #475569; }
.empty-state { text-align: center; padding: 48px 20px; color: #64748b; }
.empty-state p { font-size: 15px; }
</style>
</head>
<body>
<div class="layout">
<nav class="sidebar">
<h2>Navigation</h2>
<div id="nav-items"></div>
</nav>
<main class="main">
<h1>What's New <span id="count-badge" style="display:none"></span></h1>
<p>Features that are currently showing as "New" for you.</p>
<div id="filters" class="filters"></div>
<div id="features"></div>
<div id="actions" class="actions" style="display:none">
<button class="primary" id="dismiss-all">Mark all as seen</button>
<button class="secondary" id="reset-all">Reset state</button>
</div>
</main>
</div>
<script type="module">
// ── Import from featuredrop via CDN ──
import {
createManifest,
getNewFeatures,
isNew,
MemoryAdapter,
} from 'https://esm.sh/featuredrop@3'
// ── Simple localStorage persistence (lightweight, no adapter needed) ──
const STORAGE_KEY = 'featuredrop-vanilla-demo'
function loadState() {
try {
const raw = localStorage.getItem(STORAGE_KEY)
return raw ? JSON.parse(raw) : { watermark: null, dismissedIds: [] }
} catch {
return { watermark: null, dismissedIds: [] }
}
}
function saveState(state) {
try {
localStorage.setItem(STORAGE_KEY, JSON.stringify(state))
} catch { /* ignore */ }
}
// Build a MemoryAdapter from persisted state
function buildAdapter() {
const state = loadState()
return new MemoryAdapter({
watermark: state.watermark,
dismissed: new Set(state.dismissedIds),
})
}
// ── Feature manifest ──
const features = createManifest([
{
id: 'ai-journal',
label: 'AI Decision Journal',
description: 'Track decisions with AI-powered insights and retrospectives. Get recommendations based on past outcomes.',
releasedAt: '2026-02-20T00:00:00Z',
showNewUntil: '2026-04-20T00:00:00Z',
sidebarKey: '/journal',
category: 'ai',
type: 'feature',
},
{
id: 'analytics-v2',
label: 'Analytics Dashboard v2',
description: 'Redesigned analytics with real-time charts, custom date ranges, and one-click CSV export.',
releasedAt: '2026-02-25T00:00:00Z',
showNewUntil: '2026-04-25T00:00:00Z',
sidebarKey: '/analytics',
category: 'core',
type: 'improvement',
},
{
id: 'team-billing',
label: 'Team Billing',
description: 'Manage billing for your entire team from one place. Includes usage breakdown per seat.',
releasedAt: '2026-02-28T00:00:00Z',
showNewUntil: '2026-04-28T00:00:00Z',
sidebarKey: '/billing',
category: 'billing',
type: 'feature',
},
{
id: 'dark-mode-fix',
label: 'Dark Mode Contrast Fix',
description: 'Fixed low-contrast text in sidebar navigation and dropdown menus in dark mode.',
releasedAt: '2026-02-26T00:00:00Z',
showNewUntil: '2026-04-26T00:00:00Z',
sidebarKey: '/settings',
category: 'core',
type: 'bug-fix',
},
{
id: 'api-webhooks',
label: 'Webhook Events API',
description: 'Subscribe to real-time events via webhooks. Supports feature releases, user actions, and billing events.',
releasedAt: '2026-02-22T00:00:00Z',
showNewUntil: '2026-04-22T00:00:00Z',
sidebarKey: '/settings',
category: 'api',
type: 'feature',
},
])
const NAV_ITEMS = [
{ key: '/dashboard', label: 'Dashboard' },
{ key: '/journal', label: 'Decision Journal' },
{ key: '/analytics', label: 'Analytics' },
{ key: '/billing', label: 'Billing' },
{ key: '/settings', label: 'Settings' },
]
const CATEGORIES = [
{ key: 'all', label: 'All' },
{ key: 'core', label: 'Core' },
{ key: 'ai', label: 'AI' },
{ key: 'billing', label: 'Billing' },
{ key: 'api', label: 'API' },
]
let activeCategory = 'all'
// ── Helpers ──
function getVisibleFeatures() {
const adapter = buildAdapter()
const newFeatures = getNewFeatures(features, adapter)
if (activeCategory === 'all') return newFeatures
return newFeatures.filter(f => f.category === activeCategory)
}
function isFeatureNew(sidebarKey) {
const adapter = buildAdapter()
const feature = features.find(f => f.sidebarKey === sidebarKey)
if (!feature) return false
const watermark = adapter.getWatermark()
const dismissed = adapter.getDismissedIds()
return isNew(feature, watermark, dismissed)
}
function getAllNewCount() {
const adapter = buildAdapter()
return getNewFeatures(features, adapter).length
}
function typeBadgeClass(type) {
if (type === 'feature') return 'badge-feature'
if (type === 'improvement') return 'badge-improvement'
if (type === 'bug-fix') return 'badge-bug-fix'
return ''
}
function formatDate(dateStr) {
return new Date(dateStr).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })
}
// ── Render ──
function render() {
const visibleFeatures = getVisibleFeatures()
const totalNew = getAllNewCount()
// Sidebar nav
const navEl = document.getElementById('nav-items')
navEl.innerHTML = NAV_ITEMS.map(item => `
<div class="nav-item" data-key="${item.key}">
<span>${item.label}</span>
${isFeatureNew(item.key) ? '<span class="badge badge-new">New</span>' : ''}
</div>
`).join('')
// Count badge
const countEl = document.getElementById('count-badge')
if (totalNew > 0) {
countEl.style.display = 'inline-flex'
countEl.className = 'count-badge'
countEl.textContent = totalNew
} else {
countEl.style.display = 'none'
}
// Category filters
const filtersEl = document.getElementById('filters')
const adapter = buildAdapter()
filtersEl.innerHTML = CATEGORIES.map(cat => {
const allNew = getNewFeatures(features, adapter)
const count = cat.key === 'all'
? allNew.length
: allNew.filter(f => f.category === cat.key).length
return `
<button class="filter-btn ${activeCategory === cat.key ? 'active' : ''}" data-category="${cat.key}">
${cat.label}${count > 0 ? ` (${count})` : ''}
</button>
`
}).join('')
// Feature cards
const featuresEl = document.getElementById('features')
if (visibleFeatures.length === 0) {
featuresEl.innerHTML = '<div class="empty-state"><p>No new features in this category.</p></div>'
} else {
featuresEl.innerHTML = visibleFeatures.map(f => `
<div class="feature-card">
<div class="feature-card-header">
<div>
<h3>${f.label}</h3>
<p>${f.description}</p>
</div>
<button class="dismiss-btn" data-id="${f.id}">Dismiss</button>
</div>
<div class="feature-card-meta">
${f.type ? `<span class="badge badge-type ${typeBadgeClass(f.type)}">${f.type.replace('-', ' ')}</span>` : ''}
<span class="feature-card-date">${formatDate(f.releasedAt)}</span>
</div>
</div>
`).join('')
}
// Action buttons
const actionsEl = document.getElementById('actions')
actionsEl.style.display = totalNew > 0 ? 'flex' : 'none'
}
// ── Events ──
// Dismiss all — set watermark to now
document.getElementById('dismiss-all').addEventListener('click', () => {
saveState({ watermark: new Date().toISOString(), dismissedIds: [] })
render()
})
// Reset state
document.getElementById('reset-all').addEventListener('click', () => {
saveState({ watermark: null, dismissedIds: [] })
render()
})
// Dismiss individual feature
document.getElementById('features').addEventListener('click', (e) => {
const btn = e.target.closest('.dismiss-btn')
if (!btn) return
const id = btn.dataset.id
const state = loadState()
if (!state.dismissedIds.includes(id)) {
state.dismissedIds.push(id)
}
saveState(state)
render()
})
// Sidebar nav click — dismiss that feature
document.getElementById('nav-items').addEventListener('click', (e) => {
const navItem = e.target.closest('.nav-item')
if (!navItem) return
const key = navItem.dataset.key
const adapter = buildAdapter()
const watermark = adapter.getWatermark()
const dismissed = adapter.getDismissedIds()
const feature = features.find(f => f.sidebarKey === key)
if (feature && isNew(feature, watermark, dismissed)) {
const state = loadState()
if (!state.dismissedIds.includes(feature.id)) {
state.dismissedIds.push(feature.id)
}
saveState(state)
render()
}
})
// Category filters
document.getElementById('filters').addEventListener('click', (e) => {
const btn = e.target.closest('.filter-btn')
if (!btn) return
activeCategory = btn.dataset.category
render()
})
// ── Initial render ──
render()
</script>
</body>
</html>