Skip to content

Commit a090443

Browse files
committed
UI: Revamp summary cards and data table label
- "Total lines" → "Total size" showing LoC count and commit count - Data table label now shows days and commits: "Data table (77 days, data from N commits)" - Average growth card now shows both 90d and 30d rates, arrow reflects 30d vs 90d trend - Removed `repoSizeBytes` prop from `ResultsSummary`
1 parent 83b228c commit a090443

2 files changed

Lines changed: 36 additions & 33 deletions

File tree

src/lib/components/ResultsSummary.svelte

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,25 @@
55
interface Props {
66
days: DayStats[]
77
detectedLanguages: string[]
8-
repoSizeBytes?: number | null
98
onHighlightDate?: (date: string | null) => void
109
}
1110
12-
let { days, repoSizeBytes, onHighlightDate }: Props = $props()
11+
let { days, onHighlightDate }: Props = $props()
1312
14-
const formattedRepoSize = $derived.by(() => {
15-
if (repoSizeBytes == null || repoSizeBytes <= 0) return null
16-
return `${(repoSizeBytes / (1024 * 1024)).toFixed(1)} MB`
17-
})
18-
19-
// --- Total lines ---
13+
// --- Total size ---
2014
const totalLines = $derived(days.length > 0 ? days[days.length - 1].total : 0)
2115
2216
const formattedTotal = $derived(totalLines.toLocaleString('en-US').replace(/,/g, '\u2009'))
2317
18+
/** Count commits from days that have actual commits (not gap-filled) */
19+
const totalCommits = $derived(
20+
days
21+
.filter((d) => d.comments.length === 0 || d.comments[0] !== '-')
22+
.reduce((sum, d) => sum + d.comments.length, 0),
23+
)
24+
25+
const formattedCommits = $derived(totalCommits.toLocaleString('en-US').replace(/,/g, '\u2009'))
26+
2427
// --- Prod / test split ---
2528
const prodTestSplit = $derived.by(() => {
2629
if (days.length === 0) return { prod: 0, test: 0, prodPct: 0, testPct: 0 }
@@ -73,10 +76,10 @@
7376
return Math.round((last.total - first.total) / daysBetween)
7477
})
7578
76-
const avgGrowthLast90 = $derived.by(() => {
79+
const computeAvgGrowthForLastNDays = (n: number): number => {
7780
if (days.length < 2) return 0
7881
const lastDate = new Date(days[days.length - 1].date)
79-
const cutoffStr = new Date(lastDate.getTime() - 90 * 24 * 60 * 60 * 1000).toISOString().slice(0, 10)
82+
const cutoffStr = new Date(lastDate.getTime() - n * 24 * 60 * 60 * 1000).toISOString().slice(0, 10)
8083
8184
// Find the first day at or after the cutoff
8285
let startIdx = 0
@@ -94,15 +97,18 @@
9497
(new Date(endDay.date).getTime() - new Date(startDay.date).getTime()) / (1000 * 60 * 60 * 24),
9598
)
9699
return Math.round((endDay.total - startDay.total) / daysBetween)
97-
})
100+
}
98101
99-
/** Show arrow only when the difference is significant (>20%) */
102+
const avgGrowthLast90 = $derived(computeAvgGrowthForLastNDays(90))
103+
const avgGrowthLast30 = $derived(computeAvgGrowthForLastNDays(30))
104+
105+
/** Show arrow only when the 30d growth differs significantly (>20%) from the 90d growth */
100106
const growthTrend = $derived.by(() => {
101-
if (avgDailyGrowth === 0 && avgGrowthLast90 === 0) return 'neutral' as const
102-
const base = Math.max(Math.abs(avgDailyGrowth), 1)
103-
const ratio = Math.abs(avgGrowthLast90 - avgDailyGrowth) / base
107+
if (avgGrowthLast90 === 0 && avgGrowthLast30 === 0) return 'neutral' as const
108+
const base = Math.max(Math.abs(avgGrowthLast90), 1)
109+
const ratio = Math.abs(avgGrowthLast30 - avgGrowthLast90) / base
104110
if (ratio <= 0.2) return 'neutral' as const
105-
return avgGrowthLast90 > avgDailyGrowth ? ('up' as const) : ('down' as const)
111+
return avgGrowthLast30 > avgGrowthLast90 ? ('up' as const) : ('down' as const)
106112
})
107113
108114
// --- Age ---
@@ -260,29 +266,23 @@
260266
role="region"
261267
aria-label="Summary statistics"
262268
>
263-
<!-- Total lines -->
269+
<!-- Total size -->
264270
<div class="strata-card p-4">
265271
<p
266272
class="text-foreground-tertiary"
267273
style="font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.05em; text-transform: uppercase;"
268274
>
269-
Total lines
275+
Total size
270276
</p>
271277
<p
272278
class="mt-2 text-foreground"
273279
style="font-family: var(--font-mono); font-size: 1.125rem; font-weight: 500; letter-spacing: -0.01em;"
274280
>
275-
{formattedTotal}
281+
LoC: {formattedTotal}
282+
</p>
283+
<p class="mt-1 text-foreground-secondary" style="font-family: var(--font-mono); font-size: 0.75rem;">
284+
{totalCommits === 1 ? 'commit' : 'commits'}: {formattedCommits}
276285
</p>
277-
{#if formattedRepoSize}
278-
<p
279-
class="mt-1 text-foreground-secondary"
280-
style="font-family: var(--font-mono); font-size: 0.75rem;"
281-
title="It includes history"
282-
>
283-
Repo size: {formattedRepoSize}
284-
</p>
285-
{/if}
286286
</div>
287287

288288
<!-- Prod / test split -->
@@ -355,14 +355,16 @@
355355
class="text-foreground-secondary"
356356
style="font-family: var(--font-mono); font-size: 0.75rem; white-space: nowrap;"
357357
>
358-
Last 90d: {avgGrowthLast90 >= 0 ? '+' : ''}{formatNumber(avgGrowthLast90)}/day
358+
Last 90d: {avgGrowthLast90 >= 0 ? '+' : ''}{formatNumber(avgGrowthLast90)}/d, 30d: {avgGrowthLast30 >= 0
359+
? '+'
360+
: ''}{formatNumber(avgGrowthLast30)}/d
359361
</p>
360362
{#if growthTrend !== 'neutral'}
361363
<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" style="flex-shrink: 0;">
362364
<title
363365
>{growthTrend === 'up'
364-
? 'Recent growth is higher than the average'
365-
: 'Recent growth is lower than the average'}</title
366+
? '30-day growth is higher than the 90-day average'
367+
: '30-day growth is lower than the 90-day average'}</title
366368
>
367369
{#if growthTrend === 'up'}
368370
<path

src/routes/+page.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@
441441
442442
/** Only days with actual commits (excludes gap-filled carry-forward days) */
443443
const commitDays = $derived(displayDays.filter((d) => d.comments.length === 0 || d.comments[0] !== '-'))
444+
const totalCommitCount = $derived(commitDays.reduce((sum, d) => sum + d.comments.length, 0))
444445
445446
const displayRepoSlug = $derived.by(() => {
446447
const input = result?.repoUrl ?? lastRepoInput
@@ -758,7 +759,6 @@
758759
<ResultsSummary
759760
days={displayDays}
760761
detectedLanguages={displayLanguages}
761-
{repoSizeBytes}
762762
onHighlightDate={(d) => (chartHighlightDate = d)}
763763
/>
764764

@@ -778,7 +778,8 @@
778778
style="font-family: var(--font-mono); font-size: 0.875rem; letter-spacing: 0.02em; transition-duration: var(--duration-fast);"
779779
>
780780
Data table ({commitDays.length}
781-
{commitDays.length === 1 ? 'commit' : 'commits'})
781+
{commitDays.length === 1 ? 'day' : 'days'}, data from {totalCommitCount}
782+
{totalCommitCount === 1 ? 'commit' : 'commits'})
782783
</summary>
783784
<div class="mt-4">
784785
<ResultsTable

0 commit comments

Comments
 (0)