@git-stats-components/vue 1.0.0 → 1.0.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.
- package/README.md +272 -0
- package/package.json +15 -3
package/README.md
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# @git-stats-components/vue
|
|
2
|
+
|
|
3
|
+
Beautiful GitHub/GitLab/Bitbucket contribution graphs for Vue 3.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @git-stats-components/vue
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```vue
|
|
14
|
+
<script setup>
|
|
15
|
+
import { ContributionGraph, StatsBreakdown } from '@git-stats-components/vue'
|
|
16
|
+
import '@git-stats-components/vue/style.css'
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<div>
|
|
21
|
+
<ContributionGraph data-url="/data/git-stats.json" color-scheme="green" />
|
|
22
|
+
<StatsBreakdown data-url="/data/git-stats.json" />
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Components
|
|
28
|
+
|
|
29
|
+
### ContributionGraph
|
|
30
|
+
|
|
31
|
+
GitHub-style contribution heatmap.
|
|
32
|
+
|
|
33
|
+
**Props:**
|
|
34
|
+
|
|
35
|
+
- `dataUrl` (string) - Path to stats JSON file (default: `/data/git-stats.json`)
|
|
36
|
+
- `profileIndex` (number) - Which profile to display (default: 0)
|
|
37
|
+
- `colorScheme` ('green' | 'blue' | 'purple' | 'orange') - Color theme (default: 'green')
|
|
38
|
+
- `showSettings` (boolean) - Show color scheme dropdown (default: true)
|
|
39
|
+
- `cacheTTL` (number) - Cache duration in milliseconds
|
|
40
|
+
|
|
41
|
+
**Events:**
|
|
42
|
+
|
|
43
|
+
- `@day-click` - Emitted when a day is clicked (`{ date: string, count: number }`)
|
|
44
|
+
- `@color-scheme-change` - Emitted when color scheme changes
|
|
45
|
+
|
|
46
|
+
**Example:**
|
|
47
|
+
|
|
48
|
+
```vue
|
|
49
|
+
<ContributionGraph
|
|
50
|
+
data-url="/data/git-stats.json"
|
|
51
|
+
:profile-index="0"
|
|
52
|
+
color-scheme="blue"
|
|
53
|
+
:show-settings="true"
|
|
54
|
+
@day-click="handleDayClick"
|
|
55
|
+
@color-scheme-change="handleColorChange"
|
|
56
|
+
/>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### StatsBreakdown
|
|
60
|
+
|
|
61
|
+
Project and commit count statistics.
|
|
62
|
+
|
|
63
|
+
**Props:**
|
|
64
|
+
|
|
65
|
+
- `dataUrl` (string) - Path to stats JSON file
|
|
66
|
+
- `profileIndexes` (number[]) - Which profiles to aggregate (default: [])
|
|
67
|
+
- `experienceData` (ExperienceEntry[]) - Work experience for years calculation
|
|
68
|
+
- `showCustomStat` (boolean) - Show custom stat (default: true)
|
|
69
|
+
- `customStatCalculator` (function) - Custom stat calculation function
|
|
70
|
+
|
|
71
|
+
**Slots:**
|
|
72
|
+
|
|
73
|
+
- `icon-experience` - Custom icon for experience stat
|
|
74
|
+
- `icon-projects` - Custom icon for projects stat
|
|
75
|
+
- `icon-commits` - Custom icon for commits stat
|
|
76
|
+
- `icon-custom` - Custom icon for custom stat
|
|
77
|
+
- `custom-stat-label` - Custom label for custom stat
|
|
78
|
+
|
|
79
|
+
**Example:**
|
|
80
|
+
|
|
81
|
+
```vue
|
|
82
|
+
<script setup>
|
|
83
|
+
const experienceData = [
|
|
84
|
+
{
|
|
85
|
+
startDate: '2020-01-01',
|
|
86
|
+
endDate: null, // current
|
|
87
|
+
skills: ['JavaScript', 'Vue', 'TypeScript']
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
|
|
91
|
+
function calculatePizzas({ projects, commits, years }) {
|
|
92
|
+
return (projects * 2 + commits * 0.5 + years * 100).toFixed(0)
|
|
93
|
+
}
|
|
94
|
+
</script>
|
|
95
|
+
|
|
96
|
+
<template>
|
|
97
|
+
<StatsBreakdown
|
|
98
|
+
data-url="/data/git-stats.json"
|
|
99
|
+
:experience-data="experienceData"
|
|
100
|
+
:show-custom-stat="true"
|
|
101
|
+
:custom-stat-calculator="calculatePizzas"
|
|
102
|
+
>
|
|
103
|
+
<template #icon-custom>🍕</template>
|
|
104
|
+
<template #custom-stat-label>Pizzas Ordered</template>
|
|
105
|
+
</StatsBreakdown>
|
|
106
|
+
</template>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Using the Composable
|
|
110
|
+
|
|
111
|
+
```vue
|
|
112
|
+
<script setup>
|
|
113
|
+
import { useGitStats } from '@git-stats-components/vue'
|
|
114
|
+
|
|
115
|
+
const { data, loading, error, dataSourceText, lastUpdatedText, isDummy } = useGitStats({
|
|
116
|
+
dataUrl: '/data/git-stats.json',
|
|
117
|
+
cacheTTL: 3600000, // 1 hour
|
|
118
|
+
useStaleCache: true
|
|
119
|
+
})
|
|
120
|
+
</script>
|
|
121
|
+
|
|
122
|
+
<template>
|
|
123
|
+
<div v-if="loading">Loading...</div>
|
|
124
|
+
<div v-else-if="error">Error: {{ error.message }}</div>
|
|
125
|
+
<div v-else>
|
|
126
|
+
<p>{{ dataSourceText }}</p>
|
|
127
|
+
<p>{{ lastUpdatedText }}</p>
|
|
128
|
+
<pre>{{ JSON.stringify(data, null, 2) }}</pre>
|
|
129
|
+
</div>
|
|
130
|
+
</template>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## TypeScript Support
|
|
134
|
+
|
|
135
|
+
Full TypeScript support with exported types:
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
import type {
|
|
139
|
+
GitStatsData,
|
|
140
|
+
ColorScheme,
|
|
141
|
+
Platform,
|
|
142
|
+
ExperienceEntry,
|
|
143
|
+
CustomStatCalculator
|
|
144
|
+
} from '@git-stats-components/vue'
|
|
145
|
+
|
|
146
|
+
const colorScheme: ColorScheme = 'green'
|
|
147
|
+
|
|
148
|
+
const experienceData: ExperienceEntry[] = [
|
|
149
|
+
{
|
|
150
|
+
startDate: '2020-01-01',
|
|
151
|
+
endDate: null,
|
|
152
|
+
skills: ['JavaScript', 'Vue', 'TypeScript']
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
|
|
156
|
+
const customCalculator: CustomStatCalculator = ({ projects, commits, years }) => {
|
|
157
|
+
return (projects * 2 + commits * 0.5).toFixed(0)
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Plugin Usage
|
|
162
|
+
|
|
163
|
+
Register globally in your Vue app:
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
import { createApp } from 'vue'
|
|
167
|
+
import VueGitStats from '@git-stats-components/vue'
|
|
168
|
+
import '@git-stats-components/vue/style.css'
|
|
169
|
+
import App from './App.vue'
|
|
170
|
+
|
|
171
|
+
const app = createApp(App)
|
|
172
|
+
app.use(VueGitStats)
|
|
173
|
+
app.mount('#app')
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Then use without imports:
|
|
177
|
+
|
|
178
|
+
```vue
|
|
179
|
+
<template>
|
|
180
|
+
<ContributionGraph data-url="/data/git-stats.json" />
|
|
181
|
+
<StatsBreakdown data-url="/data/git-stats.json" />
|
|
182
|
+
</template>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Nuxt 3 Usage
|
|
186
|
+
|
|
187
|
+
```vue
|
|
188
|
+
<!-- pages/index.vue -->
|
|
189
|
+
<script setup lang="ts">
|
|
190
|
+
import { ContributionGraph, StatsBreakdown } from '@git-stats-components/vue'
|
|
191
|
+
import '@git-stats-components/vue/style.css'
|
|
192
|
+
|
|
193
|
+
const experienceData = [
|
|
194
|
+
{
|
|
195
|
+
startDate: '2020-01-01',
|
|
196
|
+
endDate: null,
|
|
197
|
+
skills: ['JavaScript', 'Vue', 'Nuxt']
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
</script>
|
|
201
|
+
|
|
202
|
+
<template>
|
|
203
|
+
<div>
|
|
204
|
+
<ContributionGraph data-url="/data/git-stats.json" />
|
|
205
|
+
<StatsBreakdown data-url="/data/git-stats.json" :experience-data="experienceData" />
|
|
206
|
+
</div>
|
|
207
|
+
</template>
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Custom Styling
|
|
211
|
+
|
|
212
|
+
Override CSS variables:
|
|
213
|
+
|
|
214
|
+
```css
|
|
215
|
+
.git-contribution-graph {
|
|
216
|
+
--graph-bg: #0d1117;
|
|
217
|
+
--graph-text: #e6edf3;
|
|
218
|
+
--graph-border: #30363d;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/* Or target specific classes */
|
|
222
|
+
.contribution-day.level-4.green {
|
|
223
|
+
background-color: #00ff00 !important;
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Data Setup
|
|
228
|
+
|
|
229
|
+
## Quick Setup
|
|
230
|
+
|
|
231
|
+
### 1. Initialize in your project
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
npx @git-stats-components/vue init
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
This creates:
|
|
238
|
+
- `git-stats.config.js` - Configuration file
|
|
239
|
+
- `.github/workflows/update-git-stats.yml` - GitHub Action workflow
|
|
240
|
+
- `public/data/` - Directory for stats data
|
|
241
|
+
|
|
242
|
+
### 2. Configure your profiles
|
|
243
|
+
|
|
244
|
+
Edit `git-stats.config.js`:
|
|
245
|
+
|
|
246
|
+
```javascript
|
|
247
|
+
export default {
|
|
248
|
+
profiles: [
|
|
249
|
+
{
|
|
250
|
+
username: 'your-github-username',
|
|
251
|
+
platform: 'github',
|
|
252
|
+
tokenSecret: 'GITHUB_TOKEN'
|
|
253
|
+
}
|
|
254
|
+
],
|
|
255
|
+
dataPath: 'public/data/git-stats.json',
|
|
256
|
+
schedule: '0 2 * * *' // Daily at 2 AM UTC
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### 3. Add GitHub Secrets
|
|
261
|
+
|
|
262
|
+
Go to **Settings → Secrets and variables → Actions** and add your tokens.
|
|
263
|
+
|
|
264
|
+
### 4. Done!
|
|
265
|
+
|
|
266
|
+
The GitHub Action will fetch your stats daily and save them to the JSON file. Your components will load this data automatically.
|
|
267
|
+
|
|
268
|
+
For more details, see the main [git-stats-components](https://github.com/derekjj/git-stats-components) repository.
|
|
269
|
+
|
|
270
|
+
## License
|
|
271
|
+
|
|
272
|
+
MIT © Derek Johnston
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@git-stats-components/vue",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Beautiful GitHub/GitLab/Bitbucket contribution graphs for Vue 3",
|
|
5
5
|
"author": "Derek Johnston",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
"./style.css": "./dist/style.css"
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
|
-
"dist"
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md",
|
|
22
|
+
"LICENSE"
|
|
21
23
|
],
|
|
22
24
|
"keywords": [
|
|
23
25
|
"vue",
|
|
@@ -27,8 +29,18 @@
|
|
|
27
29
|
"bitbucket",
|
|
28
30
|
"contributions",
|
|
29
31
|
"stats",
|
|
30
|
-
"component"
|
|
32
|
+
"component",
|
|
33
|
+
"git-stats"
|
|
31
34
|
],
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/derekjj/git-stats-components.git",
|
|
38
|
+
"directory": "packages/vue"
|
|
39
|
+
},
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/derekjj/git-stats-components/issues"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/derekjj/git-stats-components/tree/main/packages/vue#readme",
|
|
32
44
|
"scripts": {
|
|
33
45
|
"build": "vite build",
|
|
34
46
|
"dev": "vite build --watch",
|