[dyad] Added counter for missing alt tags - wrote 1 file(s)
This commit is contained in:
@@ -15,6 +15,8 @@ export function ImageAltDisplay({ images }: ImageAltDisplayProps) {
|
|||||||
const [showMissingOnly, setShowMissingOnly] = useState(false);
|
const [showMissingOnly, setShowMissingOnly] = useState(false);
|
||||||
const [imageErrors, setImageErrors] = useState<Record<string, boolean>>({});
|
const [imageErrors, setImageErrors] = useState<Record<string, boolean>>({});
|
||||||
|
|
||||||
|
const missingAltCount = images.filter((img) => !img.alt).length;
|
||||||
|
|
||||||
const filteredImages = showMissingOnly
|
const filteredImages = showMissingOnly
|
||||||
? images.filter((img) => !img.alt)
|
? images.filter((img) => !img.alt)
|
||||||
: images;
|
: images;
|
||||||
@@ -25,15 +27,27 @@ export function ImageAltDisplay({ images }: ImageAltDisplayProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
|
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 p-4 bg-muted/50 rounded-lg">
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
id="missing-alt"
|
id="missing-alt"
|
||||||
checked={showMissingOnly}
|
checked={showMissingOnly}
|
||||||
onCheckedChange={(checked) => setShowMissingOnly(!!checked)}
|
onCheckedChange={(checked) => setShowMissingOnly(!!checked)}
|
||||||
/>
|
/>
|
||||||
<Label htmlFor="missing-alt">
|
<Label htmlFor="missing-alt">Show only missing alt text</Label>
|
||||||
Show only images with missing alt text
|
</div>
|
||||||
</Label>
|
<div>
|
||||||
|
{missingAltCount > 0 ? (
|
||||||
|
<p className="text-sm font-medium text-destructive">
|
||||||
|
<span className="font-bold">{missingAltCount}</span> of{" "}
|
||||||
|
{images.length} images are missing alt text.
|
||||||
|
</p>
|
||||||
|
) : (
|
||||||
|
<p className="text-sm font-medium text-green-600">
|
||||||
|
Great! All {images.length} images have alt text.
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
{filteredImages.map((image, index) => (
|
{filteredImages.map((image, index) => (
|
||||||
|
|||||||
Reference in New Issue
Block a user