| @@ -0,0 +1,401 @@ |
| 1 | <script lang="ts"> |
| 2 | import type { ChangelogEntry, ServiceChange, Rejection, ChangelogPr } from '../../utils/fetch-changelog'; |
| 3 | import { slugify } from '@utils/fetch-data'; |
| 4 | |
| 5 | export let entries: ChangelogEntry[] = []; |
| 6 | export let rejections: Rejection[] = []; |
| 7 | |
| 8 | type Filter = 'added' | 'removed' | 'modified' | 'rejected'; |
| 9 | |
| 10 | const filterDefs: { key: Filter; label: string; icon: string }[] = [ |
| 11 | { key: 'added', label: 'Additions', icon: '+' }, |
| 12 | { key: 'removed', label: 'Removals', icon: '−' }, |
| 13 | { key: 'modified', label: 'Amendments', icon: '✎' }, |
| 14 | { key: 'rejected', label: 'Rejections', icon: '✕' }, |
| 15 | ]; |
| 16 | |
| 17 | let on: Record<Filter, boolean> = { added: true, removed: true, modified: true, rejected: true }; |
| 18 | let searchQuery = ''; |
| 19 | |
| 20 | function toggle(key: Filter) { on = { ...on, [key]: !on[key] }; } |
| 21 | |
| 22 | type TimelineItem = |
| 23 | | { kind: 'entry'; date: string; sha: string; pr?: ChangelogPr | null; data: ChangelogEntry } |
| 24 | | { kind: 'rejection'; date: string; sha: string; pr: ChangelogPr; data: Rejection }; |
| 25 | |
| 26 | const svc = (e: ChangelogEntry) => { |
| 27 | const s = e.changes?.services; |
| 28 | return { added: s?.added || [], removed: s?.removed || [], modified: s?.modified || [] }; |
| 29 | }; |
| 30 | const sec = (e: ChangelogEntry) => { |
| 31 | const s = e.changes?.sections; |
| 32 | return { added: s?.added || [], removed: s?.removed || [] }; |
| 33 | }; |
| 34 | const cat = (e: ChangelogEntry) => { |
| 35 | const c = e.changes?.categories; |
| 36 | return { added: c?.added || [], removed: c?.removed || [] }; |
| 37 | }; |
| 38 | |
| 39 | function matchesFilters(item: TimelineItem, f: Record<Filter, boolean>): boolean { |
| 40 | if (item.kind === 'rejection') return f.rejected; |
| 41 | const s = svc(item.data), sc = sec(item.data), ct = cat(item.data); |
| 42 | return (f.added && (s.added.length > 0 || sc.added.length > 0 || ct.added.length > 0)) |
| 43 | || (f.removed && (s.removed.length > 0 || sc.removed.length > 0 || ct.removed.length > 0)) |
| 44 | || (f.modified && s.modified.length > 0); |
| 45 | } |
| 46 | |
| 47 | function matchesSearch(item: TimelineItem, query: string): boolean { |
| 48 | if (!query) return true; |
| 49 | const q = query.toLowerCase(); |
| 50 | if (item.kind === 'rejection') { |
| 51 | return item.data.title.toLowerCase().includes(q) |
| 52 | || (item.pr.author?.toLowerCase().includes(q) ?? false); |
| 53 | } |
| 54 | const all = [...svc(item.data).added, ...svc(item.data).removed, ...svc(item.data).modified]; |
| 55 | return all.some(c => c.name.toLowerCase().includes(q) |
| 56 | || `${c.category} ${c.section}`.toLowerCase().includes(q)) |
| 57 | || (item.pr?.author?.toLowerCase().includes(q) ?? false); |
| 58 | } |
| 59 | |
| 60 | const pl = (n: number, word: string) => `${n} ${word}${n > 1 ? 's' : ''}`; |
| 61 | |
| 62 | function summarize(entry: ChangelogEntry): string { |
| 63 | const s = svc(entry), sc = sec(entry); |
| 64 | const parts: string[] = []; |
| 65 | if (s.added.length) parts.push(pl(s.added.length, 'addition')); |
| 66 | if (s.removed.length) parts.push(pl(s.removed.length, 'removal')); |
| 67 | if (s.modified.length) parts.push(pl(s.modified.length, 'amendment')); |
| 68 | if (sc.added.length) parts.push(pl(sc.added.length, 'new section')); |
| 69 | if (sc.removed.length) parts.push(pl(sc.removed.length, 'section removal')); |
| 70 | return parts.join(', ') || 'Changes'; |
| 71 | } |
| 72 | |
| 73 | function serviceLink(s: ServiceChange, isRemoval: boolean): string { |
| 74 | const c = slugify(s.category), sc = slugify(s.section); |
| 75 | return isRemoval ? `/${c}/${sc}` : `/${c}/${sc}/${slugify(s.name)}`; |
| 76 | } |
| 77 | |
| 78 | type ChangeRow = { badge: string; cls: string; name: string; href: string; path: string; fields?: string[] }; |
| 79 | |
| 80 | function changeRows(e: ChangelogEntry): ChangeRow[] { |
| 81 | const s = svc(e), sc = sec(e), ct = cat(e); |
| 82 | return [ |
| 83 | ...s.added.map(v => ({ badge: 'Added', cls: 'add', name: v.name, href: serviceLink(v, false), path: `into ${v.category} › ${v.section}` })), |
| 84 | ...s.removed.map(v => ({ badge: 'Removed', cls: 'rem', name: v.name, href: serviceLink(v, true), path: `from ${v.category} › ${v.section}` })), |
| 85 | ...s.modified.map(v => ({ badge: 'Amended', cls: 'mod', name: v.name, href: serviceLink(v, false), path: `in ${v.category} › ${v.section}`, fields: v.fields })), |
| 86 | ...sc.added.map(v => ({ badge: 'New Section', cls: 'add', name: v.name, href: `/${slugify(v.category)}/${slugify(v.name)}` })), |
| 87 | ...sc.removed.map(v => ({ badge: 'Section Removed', cls: 'rem', name: v.name, href: '' })), |
| 88 | ...ct.added.map(v => ({ badge: 'New Category', cls: 'add', name: v, href: '' })), |
| 89 | ...ct.removed.map(v => ({ badge: 'Category Removed', cls: 'rem', name: v, href: '' })), |
| 90 | ]; |
| 91 | } |
| 92 | |
| 93 | $: allItems = [ |
| 94 | ...entries.map((e): TimelineItem => ({ kind: 'entry', date: e.date, sha: e.sha, pr: e.pr, data: e })), |
| 95 | ...rejections.map((r): TimelineItem => ({ kind: 'rejection', date: r.date, sha: `rej-${r.pr.number}`, pr: r.pr, data: r })), |
| 96 | ].sort((a, b) => b.date.localeCompare(a.date)); |
| 97 | |
| 98 | $: filtered = allItems.filter(item => matchesFilters(item, on) && matchesSearch(item, searchQuery)); |
| 99 | |
| 100 | $: grouped = filtered.reduce<Record<string, TimelineItem[]>>((acc, item) => { |
| 101 | const d = new Date(item.date + 'T00:00:00Z'); |
| 102 | const key = d.toLocaleDateString('en-US', { year: 'numeric', month: 'long', timeZone: 'UTC' }); |
| 103 | (acc[key] ??= []).push(item); |
| 104 | return acc; |
| 105 | }, {}); |
| 106 | |
| 107 | function formatDate(dateStr: string): string { |
| 108 | return new Date(dateStr + 'T00:00:00Z') |
| 109 | .toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric', timeZone: 'UTC' }); |
| 110 | } |
| 111 | </script> |
| 112 | |
| 113 | <details class="controls"> |
| 114 | <summary>Search & Filter</summary> |
| 115 | <div class="controls-body"> |
| 116 | <input class="search" type="text" placeholder="Search..." bind:value={searchQuery} /> |
| 117 | <div class="filters"> |
| 118 | {#each filterDefs as f (f.key)} |
| 119 | <button class="pill {f.key}" class:active={on[f.key]} on:click={() => toggle(f.key)}> |
| 120 | <span class="icon">{f.icon}</span>{f.label} |
| 121 | </button> |
| 122 | {/each} |
| 123 | </div> |
| 124 | </div> |
| 125 | </details> |
| 126 | |
| 127 | {#if filtered.length === 0} |
| 128 | <p class="empty">No matching changes found.</p> |
| 129 | {/if} |
| 130 | |
| 131 | {#each Object.entries(grouped) as [month, monthItems] (month)} |
| 132 | <h3 class="month-header">{month}</h3> |
| 133 | {#each monthItems as item (item.sha)} |
| 134 | <article class="entry"> |
| 135 | <time class="entry-date">{formatDate(item.date)}</time> |
| 136 | <div class="entry-body"> |
| 137 | <div class="summary"> |
| 138 | {#if item.pr?.authorAvatar} |
| 139 | <a href={`https://github.com/${item.pr.author}`} target="_blank" rel="noreferrer"> |
| 140 | <img class="avatar" src={item.pr.authorAvatar} alt="" width="20" height="20" loading="lazy" /> |
| 141 | </a> |
| 142 | {/if} |
| 143 | {#if item.pr?.author} |
| 144 | <span class="author"><a href={`https://github.com/${item.pr.author}`} target="_blank" rel="noreferrer">@{item.pr.author}</a></span> |
| 145 | {/if} |
| 146 | <span class="summary-text"> |
| 147 | {item.kind === 'rejection' ? 'Submission Reviewed' : summarize(item.data)} |
| 148 | </span> |
| 149 | {#if item.pr} |
| 150 | <a class="pr-link" href={item.pr.url} target="_blank" rel="noreferrer">#{item.pr.number}</a> |
| 151 | {/if} |
| 152 | </div> |
| 153 | |
| 154 | <div class="changes"> |
| 155 | {#if item.kind === 'rejection'} |
| 156 | <div class="change"> |
| 157 | <span class="badge rej">Rejected</span> |
| 158 | <a class="svc-name" href={item.pr.url} target="_blank" rel="noreferrer">{item.data.title}</a> |
| 159 | <span class="path">Not merged</span> |
| 160 | </div> |
| 161 | {:else} |
| 162 | {#each changeRows(item.data) as row (`${row.cls}/${row.path}/${row.name}`)} |
| 163 | <div class="change"> |
| 164 | <span class="badge {row.cls}">{row.badge}</span> |
| 165 | {#if row.href} |
| 166 | <a class="svc-name" class:removed={row.cls === 'rem'} href={row.href}>{row.name}</a> |
| 167 | {:else} |
| 168 | <strong>{row.name}</strong> |
| 169 | {/if} |
| 170 | {#if row.fields}<span class="fields">updated {row.fields.join(', ')}</span>{/if} |
| 171 | {#if row.path && !row.fields}<span class="path">{row.path}</span>{/if} |
| 172 | </div> |
| 173 | {/each} |
| 174 | {/if} |
| 175 | </div> |
| 176 | </div> |
| 177 | </article> |
| 178 | {/each} |
| 179 | {/each} |
| 180 | |
| 181 | <style lang="scss"> |
| 182 | .controls { |
| 183 | margin-bottom: 1rem; |
| 184 | |
| 185 | summary { |
| 186 | cursor: pointer; |
| 187 | width: fit-content; |
| 188 | font-family: 'Lekton', sans-serif; |
| 189 | opacity: 0.6; |
| 190 | &:hover { |
| 191 | opacity: 1; |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | .controls-body { |
| 196 | display: flex; |
| 197 | align-items: flex-end; |
| 198 | justify-content: space-between; |
| 199 | gap: 1rem; |
| 200 | margin-top: 0.5rem; |
| 201 | } |
| 202 | |
| 203 | .search { |
| 204 | width: 200px; |
| 205 | padding: 0.35rem 0.75rem; |
| 206 | border: 2px solid var(--box-outline); |
| 207 | border-radius: var(--curve-lg); |
| 208 | box-shadow: 2px 2px 0 var(--box-outline); |
| 209 | background: var(--accent-fg); |
| 210 | color: var(--foreground); |
| 211 | &:focus { |
| 212 | outline: none; |
| 213 | border-color: var(--accent); |
| 214 | box-shadow: 2px 2px 0 var(--accent); |
| 215 | } |
| 216 | &::placeholder { |
| 217 | opacity: 0.5; |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | .filters { |
| 222 | display: flex; |
| 223 | gap: 0.3rem; |
| 224 | flex-wrap: wrap; |
| 225 | } |
| 226 | |
| 227 | .pill { |
| 228 | display: flex; |
| 229 | align-items: center; |
| 230 | gap: 0.25rem; |
| 231 | padding: 0.15rem 0.5rem; |
| 232 | border: 1px solid transparent; |
| 233 | border-radius: var(--curve-md); |
| 234 | background: var(--background); |
| 235 | color: var(--foreground); |
| 236 | cursor: pointer; |
| 237 | font-family: 'Lekton', sans-serif; |
| 238 | font-size: 0.75rem; |
| 239 | opacity: 0.5; |
| 240 | transition: opacity 0.2s ease-in-out; |
| 241 | |
| 242 | .icon { |
| 243 | font-size: 0.85rem; |
| 244 | line-height: 1; |
| 245 | } |
| 246 | &.active { |
| 247 | opacity: 1; |
| 248 | border-color: currentColor; |
| 249 | } |
| 250 | &.added { |
| 251 | &.active { color: var(--changelog-add); } |
| 252 | &:hover { background: color-mix(in srgb, var(--changelog-add) 10%, transparent); } |
| 253 | } |
| 254 | &.removed { |
| 255 | &.active { color: var(--changelog-rem); } |
| 256 | &:hover { background: color-mix(in srgb, var(--changelog-rem) 10%, transparent); } |
| 257 | } |
| 258 | &.modified { |
| 259 | &.active { color: var(--changelog-mod); } |
| 260 | &:hover { background: color-mix(in srgb, var(--changelog-mod) 10%, transparent); } |
| 261 | } |
| 262 | &.rejected { |
| 263 | &.active { color: var(--changelog-rej); } |
| 264 | &:hover { background: color-mix(in srgb, var(--changelog-rej) 10%, transparent); } |
| 265 | } |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | .empty { |
| 270 | text-align: center; |
| 271 | opacity: 0.6; |
| 272 | margin: 2rem 0; |
| 273 | } |
| 274 | |
| 275 | .month-header { |
| 276 | font-size: 1.3rem; |
| 277 | margin: 1.5rem 0 0.5rem 0; |
| 278 | padding-bottom: 0.3rem; |
| 279 | border-bottom: 1px solid var(--accent-3); |
| 280 | color: var(--accent-3); |
| 281 | font-family: 'Lekton', sans-serif; |
| 282 | } |
| 283 | |
| 284 | .entry { |
| 285 | display: flex; |
| 286 | gap: 1rem; |
| 287 | padding: 0.6rem 0; |
| 288 | border-bottom: 1px solid rgba(255, 255, 255, 0.05); |
| 289 | &:last-child { |
| 290 | border-bottom: none; |
| 291 | } |
| 292 | |
| 293 | .entry-date { |
| 294 | min-width: 7rem; |
| 295 | opacity: 0.75; |
| 296 | padding-top: 0.15rem; |
| 297 | font-family: 'Lekton', sans-serif; |
| 298 | } |
| 299 | |
| 300 | .entry-body { |
| 301 | flex: 1; |
| 302 | min-width: 0; |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | .summary { |
| 307 | display: flex; |
| 308 | align-items: center; |
| 309 | gap: 0.4rem; |
| 310 | flex-wrap: wrap; |
| 311 | margin-bottom: 0.3rem; |
| 312 | font-size: 0.85rem; |
| 313 | opacity: 0.8; |
| 314 | .author a { |
| 315 | color: var(--foreground); |
| 316 | &:hover { |
| 317 | color: var(--accent); |
| 318 | } |
| 319 | } |
| 320 | .avatar { |
| 321 | border-radius: 50%; |
| 322 | } |
| 323 | .pr-link { |
| 324 | padding: 0 0.4rem; |
| 325 | border-radius: var(--curve-sm); |
| 326 | background: var(--accent-3); |
| 327 | color: var(--foreground); |
| 328 | text-decoration: none; |
| 329 | font-family: 'Lekton', sans-serif; |
| 330 | &:hover { |
| 331 | opacity: 0.85; |
| 332 | } |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | .changes { |
| 337 | display: flex; |
| 338 | flex-direction: column; |
| 339 | gap: 0.2rem; |
| 340 | .change { |
| 341 | display: flex; |
| 342 | align-items: baseline; |
| 343 | gap: 0.4rem; |
| 344 | flex-wrap: wrap; |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | .badge { |
| 349 | font-size: 0.8rem; |
| 350 | padding: 0.05rem 0.35rem; |
| 351 | border-radius: var(--curve-sm); |
| 352 | font-family: 'Lekton', sans-serif; |
| 353 | text-transform: uppercase; |
| 354 | font-weight: bold; |
| 355 | &.add { |
| 356 | background: color-mix(in srgb, var(--changelog-add) 33%, transparent); |
| 357 | color: var(--changelog-add); |
| 358 | } |
| 359 | &.rem { |
| 360 | background: color-mix(in srgb, var(--changelog-rem) 33%, transparent); |
| 361 | color: var(--changelog-rem); |
| 362 | } |
| 363 | &.mod { |
| 364 | background: color-mix(in srgb, var(--changelog-mod) 33%, transparent); |
| 365 | color: var(--changelog-mod); |
| 366 | } |
| 367 | &.rej { |
| 368 | background: color-mix(in srgb, var(--changelog-rej) 33%, transparent); |
| 369 | color: var(--changelog-rej); |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | .svc-name { |
| 374 | font-weight: 500; |
| 375 | color: var(--foreground); |
| 376 | text-decoration: none; |
| 377 | } |
| 378 | a.svc-name:hover { |
| 379 | color: var(--accent); |
| 380 | text-decoration: underline; |
| 381 | } |
| 382 | |
| 383 | .path, |
| 384 | .fields { |
| 385 | font-size: 0.8rem; |
| 386 | opacity: 0.6; |
| 387 | } |
| 388 | .fields { |
| 389 | font-style: italic; |
| 390 | } |
| 391 | |
| 392 | @media (max-width: 600px) { |
| 393 | .entry { |
| 394 | flex-direction: column; |
| 395 | gap: 0.2rem; |
| 396 | .entry-date { |
| 397 | min-width: unset; |
| 398 | } |
| 399 | } |
| 400 | } |
| 401 | </style> |