Skip to content

Commit 4b1f34e

Browse files
committed
Add badge for images with alt text, match CLI sorting to panel view, prettier focus outlines
1 parent a78f6ef commit 4b1f34e

File tree

5 files changed

+103
-51
lines changed

5 files changed

+103
-51
lines changed

commands/generate.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ private function collectAllImages(array $languages): array
182182
$imagesByHash[$hash] = [
183183
'instances' => [],
184184
'needsProcessing' => false,
185+
'firstOrder' => $totalScanned, // Track order of first occurrence
185186
];
186187
}
187188

@@ -265,6 +266,11 @@ private function processImages(array $imagesByHash, array $languages): void
265266
$errors = 0;
266267
$uniqueImagesProcessed = 0;
267268

269+
// Sort hash groups by first occurrence order to match panel view
270+
uasort($imagesByHash, function ($a, $b) {
271+
return $a['firstOrder'] - $b['firstOrder'];
272+
});
273+
268274
// Process by language to avoid immutable object issues
269275
foreach ($languages as $language) {
270276
$languageCode = $language?->code();

index.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,19 @@
8282
}
8383

8484
$totalImages = count($allImages);
85+
86+
// Calculate totals for header badges
87+
$totalWithAltText = 0;
88+
$totalReviewed = 0;
89+
foreach ($allImages as $imageData) {
90+
if (!empty($imageData['alt']) && trim($imageData['alt']) !== '') {
91+
$totalWithAltText++;
92+
}
93+
if ($imageData['alt_reviewed']) {
94+
$totalReviewed++;
95+
}
96+
}
97+
8598
$totalPages = ceil($totalImages / $limit);
8699
$offset = ($page - 1) * $limit;
87100
$paginatedImages = array_slice($allImages, $offset, $limit);
@@ -95,6 +108,11 @@
95108
'limit' => $limit,
96109
'start' => $offset + 1,
97110
'end' => min($offset + $limit, $totalImages)
111+
],
112+
'totals' => [
113+
'withAltText' => $totalWithAltText,
114+
'reviewed' => $totalReviewed,
115+
'total' => $totalImages
98116
]
99117
];
100118
}

0 commit comments

Comments
 (0)