|
1 | 1 | # webhook-spark |
2 | 2 |
|
3 | | -**Zero-dep sparklines, gauges, kaomoji, heatmaps, tables, histograms, social media content & posting for Discord/Slack/Telegram/Bluesky/X, LCD screens, IoT & AI agents.** |
| 3 | +**[Live Demo](https://che0md.tech/webhook-spark)** |
4 | 4 |
|
5 | | -Zero dependencies. TypeScript first. Under 25KB. |
| 5 | +**Zero-dep sparklines, gauges, kaomoji, heatmaps, tables, histograms, trees, braille charts, candlesticks, flowcharts, timelines, dot-matrix displays & social posting for Discord/Slack/Telegram/Bluesky/X, LCD screens, IoT & AI agents.** |
| 6 | + |
| 7 | +35+ functions. Zero dependencies. TypeScript first. Under 40KB. |
6 | 8 |
|
7 | 9 | ## Who is this for? |
8 | 10 |
|
@@ -321,6 +323,165 @@ const result = await postToX("Server status: all green!", { |
321 | 323 | // => { success: true, platform: "x", postUrl: "https://x.com/i/status/..." } |
322 | 324 | ``` |
323 | 325 |
|
| 326 | +### `tree(nodes, options?)` -- ASCII Tree / Hierarchy |
| 327 | + |
| 328 | +Folder structures, dependency graphs, org charts. 4 styles: `ascii`, `rounded`, `bold`, `double`. |
| 329 | + |
| 330 | +```typescript |
| 331 | +tree([ |
| 332 | + { label: "src", children: [ |
| 333 | + { label: "index.ts" }, |
| 334 | + { label: "sparkline.ts" }, |
| 335 | + ]}, |
| 336 | + { label: "package.json" }, |
| 337 | +]); |
| 338 | +// => ├── src |
| 339 | +// │ ├── index.ts |
| 340 | +// │ └── sparkline.ts |
| 341 | +// └── package.json |
| 342 | +``` |
| 343 | + |
| 344 | +### `progressBar(steps, options?)` -- Multi-Step Pipeline |
| 345 | + |
| 346 | +CI/CD pipelines, deployment status. 4 styles: `line`, `dots`, `blocks`, `arrows`. |
| 347 | + |
| 348 | +```typescript |
| 349 | +progressBar([ |
| 350 | + { label: "Build", status: "done" }, |
| 351 | + { label: "Test", status: "done" }, |
| 352 | + { label: "Deploy", status: "active" }, |
| 353 | + { label: "Monitor", status: "pending" }, |
| 354 | +]); |
| 355 | +// => ✅ Build ▸ ✅ Test ▸ 🔄 Deploy ▸ ⬜ Monitor |
| 356 | +``` |
| 357 | + |
| 358 | +### `calendarHeatmap(data, options?)` -- GitHub-Style Contribution Grid |
| 359 | + |
| 360 | +365-day activity grid with month/day labels using date-indexed entries. |
| 361 | + |
| 362 | +```typescript |
| 363 | +calendarHeatmap([ |
| 364 | + { date: "2025-01-06", value: 3 }, |
| 365 | + { date: "2025-01-07", value: 8 }, |
| 366 | + { date: "2025-01-08", value: 1 }, |
| 367 | + // ... |
| 368 | +], { showMonths: true, showDays: true }); |
| 369 | +// => Jan |
| 370 | +// Mo ░▓ |
| 371 | +// Tu ░ |
| 372 | +// ... |
| 373 | +``` |
| 374 | + |
| 375 | +### `brailleSpark(values, options?)` -- Hi-Res Braille Sparkline |
| 376 | + |
| 377 | +2x horizontal + 4x vertical resolution via Braille Unicode (U+2800-U+28FF). |
| 378 | + |
| 379 | +```typescript |
| 380 | +brailleSpark([1, 3, 5, 7, 9, 7, 5, 3, 1]); |
| 381 | +// => ⠀⠐⠠⡀⠄⠂⠈⠀ (single row braille dots) |
| 382 | + |
| 383 | +brailleSpark([1, 5, 10, 5, 1], { height: 2, filled: true }); |
| 384 | +// => Multi-row filled area braille chart |
| 385 | +``` |
| 386 | + |
| 387 | +### `candlestick(candles, options?)` -- OHLC Financial Chart |
| 388 | + |
| 389 | +Stock/crypto candlestick charts with bull/bear rendering. |
| 390 | + |
| 391 | +```typescript |
| 392 | +candlestick([ |
| 393 | + { open: 10, high: 15, low: 5, close: 12 }, |
| 394 | + { open: 12, high: 18, low: 10, close: 8 }, |
| 395 | + { open: 8, high: 14, low: 6, close: 13 }, |
| 396 | +], { height: 10 }); |
| 397 | +// => │ |
| 398 | +// █ │ │ |
| 399 | +// █ ░ █ |
| 400 | +// │ ░ █ |
| 401 | +// │ │ |
| 402 | +``` |
| 403 | + |
| 404 | +### `timeline(events, options?)` -- Gantt / Timeline Chart |
| 405 | + |
| 406 | +Project scheduling with start/duration offsets and scale labels. |
| 407 | + |
| 408 | +```typescript |
| 409 | +timeline([ |
| 410 | + { label: "Build", start: 0, duration: 5 }, |
| 411 | + { label: "Test", start: 5, duration: 5 }, |
| 412 | + { label: "Deploy", start: 10, duration: 5 }, |
| 413 | +], { unit: "days" }); |
| 414 | +// => 0 4 8 12 15 days |
| 415 | +// Build ████████░░░░░░░░░░░░ |
| 416 | +// Test ░░░░░░░░████████░░░░ |
| 417 | +// Deploy ░░░░░░░░░░░░░░░░████ |
| 418 | +``` |
| 419 | + |
| 420 | +### `boxDiagram(boxes, options?)` -- Box-and-Arrow Flowchart |
| 421 | + |
| 422 | +Linear flow diagrams. 4 border styles, horizontal or vertical. |
| 423 | + |
| 424 | +```typescript |
| 425 | +boxDiagram([ |
| 426 | + { label: "Ingest" }, |
| 427 | + { label: "Transform" }, |
| 428 | + { label: "Load" }, |
| 429 | +], { style: "rounded" }); |
| 430 | +// => ╭───────────╮ ──▶ ╭───────────╮ ──▶ ╭───────────╮ |
| 431 | +// │ Ingest │ │ Transform │ │ Load │ |
| 432 | +// ╰───────────╯ ╰───────────╯ ╰───────────╯ |
| 433 | +``` |
| 434 | + |
| 435 | +### `multiSpark(series, options?)` -- Multi-Series Sparklines |
| 436 | + |
| 437 | +Aligned labeled sparklines for comparing metrics. |
| 438 | + |
| 439 | +```typescript |
| 440 | +multiSpark([ |
| 441 | + { label: "CPU", values: [10, 30, 50, 70, 90], unit: "%" }, |
| 442 | + { label: "Memory", values: [40, 45, 50, 55, 60], unit: "%" }, |
| 443 | + { label: "Disk", values: [10, 10, 11, 11, 12], unit: "%" }, |
| 444 | +]); |
| 445 | +// => CPU ▁▃▅▇█ peak=90% |
| 446 | +// Memory ▁▂▅▇█ peak=60% |
| 447 | +// Disk ▁▁▁▁█ peak=12% |
| 448 | +``` |
| 449 | + |
| 450 | +### `diffBar(items, options?)` -- Diverging / Butterfly Bar Chart |
| 451 | + |
| 452 | +Before/after comparison with centered axis. |
| 453 | + |
| 454 | +```typescript |
| 455 | +diffBar([ |
| 456 | + { label: "CPU", before: 60, after: 85 }, |
| 457 | + { label: "Mem", before: 80, after: 75 }, |
| 458 | + { label: "Disk", before: 50, after: 50 }, |
| 459 | +]); |
| 460 | +// => CPU ███████▕█████████ 60→85 ↑42% |
| 461 | +// Mem █████████▕████████ 80→75 ↓6% |
| 462 | +// Disk ██████▕██████ 50→50 →0% |
| 463 | +``` |
| 464 | + |
| 465 | +### `matrix(text, options?)` -- LED Dot Matrix Display |
| 466 | + |
| 467 | +Big text using embedded 3x5 font tables. 3 styles: `blocks`, `dots`, `braille`. |
| 468 | + |
| 469 | +```typescript |
| 470 | +matrix("HELLO"); |
| 471 | +// => █ █ ███ █ █ ▀█▀ |
| 472 | +// █ █ █ █ █ █ █ |
| 473 | +// ███ ██ █ █ █ █ |
| 474 | +// █ █ █ █ █ █ █ |
| 475 | +// █ █ ███ ███ ███ ▀█▀ |
| 476 | + |
| 477 | +matrix("HI", { style: "dots" }); |
| 478 | +// => ● ● ●●● |
| 479 | +// ● ● ● |
| 480 | +// ●●● ●● |
| 481 | +// ● ● ● |
| 482 | +// ● ● ●●● |
| 483 | +``` |
| 484 | + |
324 | 485 | ## Use Case Gallery |
325 | 486 |
|
326 | 487 | ### IoT Greenhouse Dashboard |
@@ -426,17 +587,20 @@ const description = socialCaption([ |
426 | 587 | |---------|:---:|:---:|:---:|:---:| |
427 | 588 | | Zero deps | Yes | No (17) | No (4) | No (11) | |
428 | 589 | | Sparklines | Yes | Yes | No | No | |
| 590 | +| Braille sparklines | Yes | No | No | No | |
429 | 591 | | Gauges | Yes | Yes | No | No | |
430 | 592 | | Kaomoji | Yes | No | No | No | |
431 | 593 | | Heatmaps | Yes | Yes | No | No | |
| 594 | +| Calendar heatmap | Yes | No | No | No | |
432 | 595 | | Tables | Yes | No | Yes | No | |
433 | 596 | | Histograms | Yes | Yes | No | No | |
434 | | -| Comparisons | Yes | No | No | No | |
435 | | -| Webhooks | Yes | No | No | No | |
| 597 | +| Candlestick charts | Yes | No | No | No | |
| 598 | +| Trees / hierarchies | Yes | Yes | No | No | |
| 599 | +| Flowcharts | Yes | No | No | No | |
| 600 | +| Timelines / Gantt | Yes | No | No | No | |
| 601 | +| Dot matrix display | Yes | No | No | No | |
436 | 602 | | Social posting | Yes (X + Bluesky) | No | No | No | |
437 | | -| Thread splitter | Yes | No | No | No | |
438 | | -| #BuildInPublic | Yes | No | No | No | |
439 | | -| Bundle size | <25KB | 2.5MB | 180KB | 400KB | |
| 603 | +| Bundle size | <40KB | 2.5MB | 180KB | 400KB | |
440 | 604 | | Maintained | Yes | No | Minimal | Yes | |
441 | 605 |
|
442 | 606 | ## License |
|
0 commit comments