diff --git a/app/api/streak/route.ts b/app/api/streak/route.ts index 9bf33b2c2..4fbab8823 100644 --- a/app/api/streak/route.ts +++ b/app/api/streak/route.ts @@ -91,6 +91,7 @@ export async function GET(request: Request) { gradient, tz: tzParam, disable_particles, + glow, } = parseResult.data; const themeName = theme || 'dark'; @@ -159,6 +160,7 @@ export async function GET(request: Request) { shading, gradient, disable_particles, + glow, }; let calendar; diff --git a/lib/svg/generator.test.ts b/lib/svg/generator.test.ts index eb43cb4a7..e7e595396 100644 --- a/lib/svg/generator.test.ts +++ b/lib/svg/generator.test.ts @@ -4,6 +4,7 @@ import { generateMonthlySVG, generateNotFoundSVG, generateRateLimitSVG, + generateHeatmapSVG, particleCount, escapeXML, getSizeScale, @@ -1443,4 +1444,58 @@ describe('Radar Scan Line Animation Alignment', () => { const geometryLong = extractGeometry(svgLong); expect(geometryLong).toEqual(geometryBaseline); }); + + describe('glow parameter', () => { + const mockStats: StreakStats = { + currentStreak: 5, + longestStreak: 10, + totalContributions: 100, + todayDate: '2024-06-12', + }; + const mockCalendar = { + weeks: [ + { + contributionDays: [ + { contributionCount: 0, date: '2024-06-10' }, + { contributionCount: 5, date: '2024-06-11' }, + { contributionCount: 15, date: '2024-06-12' }, + ], + }, + ], + } as ContributionCalendar; + + it('renders glow filter and attributes by default', () => { + const svg = generateSVG(mockStats, { user: 'avi' } as unknown as BadgeParams, mockCalendar); + expect(svg).toContain(' { + const svg = generateSVG( + mockStats, + { user: 'avi', glow: false } as unknown as BadgeParams, + mockCalendar + ); + expect(svg).not.toContain(' { + const svgWithGlow = generateHeatmapSVG( + mockStats, + { user: 'avi', view: 'heatmap' } as unknown as BadgeParams, + mockCalendar + ); + expect(svgWithGlow).toContain('` + : ''; + return ` - + ${filterGlow} ${gradients} `; } @@ -172,15 +177,16 @@ function renderStatsSection( params: BadgeParams ): string { const totalLabel = params.mode === 'loc' ? 'TOTAL LINES OF CODE' : labels.ANNUAL_SYNC_TOTAL; + const glowAttr = params.glow !== false ? ' filter="url(#glow)"' : ''; return ` ${labels.CURRENT_STREAK} - ${stats.currentStreak} + ${stats.currentStreak} ${totalLabel} - ${stats.totalContributions} + ${stats.totalContributions} ${labels.PEAK_STREAK} @@ -907,6 +913,16 @@ export function generateWrappedSVG( ? 'class="cp-accent-stroke" stroke-opacity="0.15" stroke-width="1.5"' : borderAttr; + const filterGlow = + params.glow !== false + ? ` + + + ` + : ''; + + const glowAttr = params.glow !== false ? ' filter="url(#glow)"' : ''; + return ` ${safeUser}'s GitHub Wrapped ${year} - - - - + ${filterGlow} - ${stats.totalContributions} + ${stats.totalContributions} TOTAL CONTRIBUTIONS @@ -1155,7 +1168,8 @@ function renderHeatmapGrid( sf: number, todayDate: string, mode: 'commits' | 'loc' = 'commits', - isAutoTheme: boolean = false + isAutoTheme: boolean = false, + glow: boolean = true ): string { const weeks = calendar.weeks.slice(-14); const cellSize = Math.round(HEATMAP_CELL_SIZE * sf); @@ -1203,7 +1217,7 @@ function renderHeatmapGrid( const fillAttr = isAutoTheme ? 'fill="var(--cp-accent)"' : `fill="${accent}"`; // Glow on high-intensity cells - const filterAttr = intensity === 4 ? ' filter="url(#hm-glow)"' : ''; + const filterAttr = intensity === 4 && glow !== false ? ' filter="url(#hm-glow)"' : ''; cells += ` + + + ` + : ''; + return ` CommitPulse Heatmap for ${safeUser} ${safeUser} has ${stats.totalContributions} ${unit} and a longest streak of ${stats.longestStreak} days. - - - - + ${filterGlow}