@rsalianto/git-heatmap-vanilla 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +92 -0
  2. package/package.json +5 -2
package/README.md ADDED
@@ -0,0 +1,92 @@
1
+ # @rsalianto/git-heatmap-vanilla
2
+
3
+ Web Component (`<git-heatmap>`) for displaying GitHub/GitLab contribution heatmaps. No framework required.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @rsalianto/git-heatmap-vanilla @rsalianto/git-heatmap-core
9
+ ```
10
+
11
+ Or via CDN:
12
+
13
+ ```html
14
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@rsalianto/git-heatmap-vanilla/dist/index.mjs"></script>
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```html
20
+ <git-heatmap api-url="/api/contributions"></git-heatmap>
21
+
22
+ <script type="module">
23
+ import "@rsalianto/git-heatmap-vanilla";
24
+ </script>
25
+ ```
26
+
27
+ ### Pass data via JavaScript
28
+
29
+ ```js
30
+ import "@rsalianto/git-heatmap-vanilla";
31
+ import { normalizeManual } from "@rsalianto/git-heatmap-core";
32
+
33
+ const el = document.querySelector("git-heatmap");
34
+ el.data = normalizeManual([
35
+ { date: "2024-06-01", count: 5 },
36
+ { date: "2024-06-02", count: 0 },
37
+ ]);
38
+ ```
39
+
40
+ ### Custom fetch function
41
+
42
+ ```js
43
+ const el = document.querySelector("git-heatmap");
44
+ el.fetchData = () => fetch("/api/contributions").then(r => r.json());
45
+ ```
46
+
47
+ ## Attributes
48
+
49
+ | Attribute | Type | Default | Description |
50
+ |---|---|---|---|
51
+ | `api-url` | `string` | — | Endpoint returning `HeatmapData` JSON |
52
+ | `cell-size` | `number` | `10` | Cell size in px |
53
+ | `cell-gap` | `number` | `3` | Gap between cells in px |
54
+ | `cell-radius` | `number` | `2` | Cell border radius in px |
55
+ | `show-total` | `"true"/"false"` | `"true"` | Show total contributions |
56
+ | `show-legend` | `"true"/"false"` | `"true"` | Show Less/More legend |
57
+ | `show-month-labels` | `"true"/"false"` | `"true"` | Show month labels |
58
+ | `show-day-labels` | `"true"/"false"` | `"true"` | Show Mon/Wed/Fri labels |
59
+ | `label` | `string` | `"Contribution heatmap"` | Accessible label |
60
+
61
+ ## Properties (JS only)
62
+
63
+ | Property | Type | Description |
64
+ |---|---|---|
65
+ | `data` | `HeatmapData` | Set data directly (skips fetching) |
66
+ | `fetchData` | `() => Promise<HeatmapData>` | Custom fetch function |
67
+
68
+ ## Events
69
+
70
+ ```js
71
+ document.querySelector("git-heatmap").addEventListener("day-click", (e) => {
72
+ console.log(e.detail); // { date: "2024-06-01", count: 5 }
73
+ });
74
+ ```
75
+
76
+ ## Theming via CSS variables
77
+
78
+ ```css
79
+ git-heatmap {
80
+ --ghm-color-l0: #161b22;
81
+ --ghm-color-l1: #0e4429;
82
+ --ghm-color-l2: #006d32;
83
+ --ghm-color-l3: #26a641;
84
+ --ghm-color-l4: #39d353;
85
+ --ghm-text: rgba(255,255,255,0.5);
86
+ }
87
+ ```
88
+
89
+ ## Related packages
90
+
91
+ - [`@rsalianto/git-heatmap-core`](https://www.npmjs.com/package/@rsalianto/git-heatmap-core) — Core utilities
92
+ - [`@rsalianto/git-heatmap-react`](https://www.npmjs.com/package/@rsalianto/git-heatmap-react) — React component
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsalianto/git-heatmap-vanilla",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Vanilla JS Web Component for git contribution heatmap",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
@@ -13,7 +13,10 @@
13
13
  "require": "./dist/index.js"
14
14
  }
15
15
  },
16
- "files": ["dist", "README.md"],
16
+ "files": [
17
+ "dist",
18
+ "README.md"
19
+ ],
17
20
  "scripts": {
18
21
  "build": "tsup",
19
22
  "dev": "tsup --watch",