|
1 | 1 | export type HexColor = string & { __brand: 'HexColor' }; |
2 | 2 |
|
| 3 | +/** |
| 4 | + * Processed streak statistics calculated from the user's GitHub contribution data. |
| 5 | + */ |
3 | 6 | export interface StreakStats { |
| 7 | + /** The user's current active streak in days. Resets to 0 if no contributions today or yesterday. */ |
4 | 8 | currentStreak: number; |
| 9 | + |
| 10 | + /** The user's all-time longest streak in days. */ |
5 | 11 | longestStreak: number; |
| 12 | + |
| 13 | + /** Total number of contributions in the queried period. */ |
6 | 14 | totalContributions: number; |
7 | | - todayDate: string; // local calendar date used as "today" (YYYY-MM-DD) |
| 15 | + |
| 16 | + /** Local calendar date used as "today" for streak calculation (format: YYYY-MM-DD). */ |
| 17 | + todayDate: string; |
8 | 18 | } |
9 | 19 |
|
| 20 | +/** |
| 21 | + * Resolved color palette for a badge theme after URL parameter overrides have been applied. |
| 22 | + */ |
10 | 23 | export interface BadgeTheme { |
| 24 | + /** Background fill color as a hex string WITHOUT the leading '#' (e.g. '0d1117'). */ |
11 | 25 | bg: HexColor; |
| 26 | + |
| 27 | + /** Label and stat text color as a hex string WITHOUT the leading '#' (e.g. 'ffffff'). */ |
12 | 28 | text: HexColor; |
| 29 | + |
| 30 | + /** Tower and glow accent color as a hex string WITHOUT the leading '#' (e.g. '58a6ff'). */ |
13 | 31 | accent: HexColor; |
14 | 32 | } |
15 | 33 |
|
| 34 | +/** |
| 35 | + * Represents a single day's contribution data returned from the GitHub GraphQL API. |
| 36 | + */ |
16 | 37 | export interface ContributionDay { |
| 38 | + /** Number of contributions made on this day. */ |
17 | 39 | contributionCount: number; |
| 40 | + |
| 41 | + /** Calendar date of this contribution entry (format: YYYY-MM-DD). */ |
18 | 42 | date: string; |
19 | 43 | } |
20 | 44 |
|
| 45 | +/** |
| 46 | + * Represents a single week's worth of contribution days. |
| 47 | + */ |
21 | 48 | export interface ContributionWeek { |
| 49 | + /** Array of contribution day entries for this week, ordered Sunday to Saturday. */ |
22 | 50 | contributionDays: ContributionDay[]; |
23 | 51 | } |
24 | 52 |
|
| 53 | +/** |
| 54 | + * Full contribution calendar returned from the GitHub GraphQL API. |
| 55 | + */ |
25 | 56 | export interface ContributionCalendar { |
| 57 | + /** Total number of contributions across all weeks in this calendar. */ |
26 | 58 | totalContributions: number; |
| 59 | + |
| 60 | + /** Array of weekly contribution data covering the queried date range. */ |
27 | 61 | weeks: ContributionWeek[]; |
28 | 62 | } |
29 | 63 |
|
| 64 | +/** |
| 65 | + * Month-over-month contribution statistics used by the monthly view. |
| 66 | + */ |
30 | 67 | export interface MonthlyStats { |
| 68 | + /** Total number of contributions in the current calendar month. */ |
31 | 69 | currentMonthTotal: number; |
| 70 | + |
| 71 | + /** Total number of contributions in the previous calendar month. */ |
32 | 72 | previousMonthTotal: number; |
| 73 | + |
| 74 | + /** Percentage change in contributions compared to the previous month (can be negative). */ |
33 | 75 | deltaPercentage: number; |
| 76 | + |
| 77 | + /** Absolute change in contribution count compared to the previous month (can be negative). */ |
34 | 78 | deltaAbsolute: number; |
| 79 | + |
| 80 | + /** Human-readable name of the current month (e.g. 'January', 'February'). */ |
35 | 81 | currentMonthName: string; |
36 | 82 | } |
37 | 83 |
|
| 84 | +/** |
| 85 | + * Parameters accepted by the /api/streak endpoint. |
| 86 | + * All fields except `user` are optional; URL parameters override theme defaults. |
| 87 | + */ |
38 | 88 | export interface BadgeParams { |
| 89 | + /** GitHub username whose contribution data will be fetched and rendered. Required. */ |
39 | 90 | user: string; |
| 91 | + |
| 92 | + /** Number of grace days before a streak resets (handles timezone edge cases). Defaults to 1. */ |
| 93 | + grace?: number; |
| 94 | + |
| 95 | + /** Background fill color as a hex string WITHOUT the leading '#'. Overrides theme default. */ |
40 | 96 | bg: HexColor; |
| 97 | + |
| 98 | + /** Label and stat text color as a hex string WITHOUT the leading '#'. Overrides theme default. */ |
41 | 99 | text: HexColor; |
| 100 | + |
| 101 | + /** Tower and glow accent color as a hex string WITHOUT the leading '#'. Overrides theme default. */ |
42 | 102 | accent: HexColor; |
| 103 | + |
| 104 | + /** Duration of the radar scan line animation (e.g. '4s', '8s', '12s'). Defaults to '8s'. */ |
43 | 105 | speed: string; |
| 106 | + |
| 107 | + /** Tower height scaling algorithm. 'linear' scales proportionally; 'log' uses logarithmic scale for high contributors. Defaults to 'linear'. */ |
44 | 108 | scale: 'linear' | 'log'; |
| 109 | + |
| 110 | + /** Font family override for badge typography (e.g. 'monospace'). Defaults to theme font. */ |
45 | 111 | font?: string; |
| 112 | + |
| 113 | + /** Border corner radius in pixels. Defaults to 8. */ |
46 | 114 | radius?: number; |
| 115 | + |
| 116 | + /** When true, automatically selects a theme based on the viewer's system color scheme. */ |
47 | 117 | autoTheme?: boolean; |
| 118 | + |
| 119 | + /** When true, hides the username title from the badge. */ |
48 | 120 | hide_title?: boolean; |
| 121 | + |
| 122 | + /** When true, renders the badge without a background card. */ |
49 | 123 | hideBackground?: boolean; |
| 124 | + |
| 125 | + /** When true, hides the streak and contribution stat numbers from the badge. */ |
50 | 126 | hide_stats?: boolean; |
| 127 | + |
| 128 | + /** Language/locale code for stat labels (e.g. 'en', 'fr', 'ja'). Defaults to 'en'. */ |
51 | 129 | lang?: string; |
| 130 | + |
| 131 | + /** Badge layout variant. 'default' shows the isometric monolith; 'monthly' shows month-over-month stats. */ |
52 | 132 | view?: 'default' | 'monthly'; |
| 133 | + |
| 134 | + /** Format for the monthly delta indicator. 'percent' shows %, 'absolute' shows raw count, 'both' shows both. */ |
53 | 135 | delta_format?: 'percent' | 'absolute' | 'both'; |
| 136 | + |
| 137 | + /** Custom width of the badge in pixels. Defaults to theme preset. */ |
54 | 138 | width?: number; |
| 139 | + |
| 140 | + /** Custom height of the badge in pixels. Defaults to theme preset. */ |
55 | 141 | height?: number; |
| 142 | + |
| 143 | + /** Preset size of the badge. 'small', 'medium', or 'large'. Overrides width and height. */ |
56 | 144 | size?: 'small' | 'medium' | 'large'; |
57 | | - grace?: number; |
58 | 145 | } |
0 commit comments