mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
feat(gif-tools): SOTA upgrade with 6 processing modes (#52)
* feat(find-duplicates): upgrade to 128-bit dHash with metadata and thumbnails * feat(find-duplicates): add custom-results display mode and duplicate store * feat(find-duplicates): add results overview grid and detail comparison view * feat(find-duplicates): overhaul settings with sensitivity presets and download actions * feat(find-duplicates): update i18n description * chore: replace jsqr with zxing-wasm for barcode reading * feat(barcode-read): rewrite backend with zxing-wasm for all barcode types * feat(barcode-read): rewrite frontend with multi-file, results table, progress, export - Multi-file sequential processing with per-file progress - Structured results table with type badges and copy per-result - Copy All and Export CSV functionality - Thorough scan toggle (maps to tryHarder in zxing-wasm) - Before/after view shows annotated image with bounding boxes - Updated tool description in constants and i18n * feat(stitch): update tool name and description for redesign * feat(stitch): add grid layout, alignment, border, radius, quality, and new resize modes * feat(stitch): redesign settings UI with grid, alignment, border, radius, quality * test(stitch): add stitch to e2e tool navigation suite * feat(vectorize): redesign with dual-engine backend and preset-driven UI - Backend: potrace for B&W, VTracer (@neplex/vectorizer) for full-color vectorization - Frontend: 5 presets (logo, illustration, photo, sketch, custom) - Settings: color precision, gradient step, detail, smoothing, corner threshold, invert - Updated OpenAPI spec and i18n description * feat(border): redesign with presets, shadow, padding color, swatches - Add 8 one-click presets (Clean White, Gallery Black, Shadow, Rounded, Polaroid, Vintage, Minimal, Cinematic) - Implement proper shadow rendering with blur, offset X/Y, color, opacity - Add padding color control (was hardcoded white) - Add color swatches for quick color selection - Wrap in form for Enter key submission - Add smart validation (requires at least one effect active) - Align frontend/backend slider ranges - Organize UI with sections and collapsible shadow toggle * feat(split): overhaul image splitting with live grid overlay and tile preview - Add interactive-split display mode with SplitCanvas component - Live SVG grid overlay on uploaded image showing split boundaries - Two split modes: Grid (NxM) and Tile Size (px dimensions) - 9 grid presets (2x1, 1x2, 2x2, 3x1, 1x3, 3x3, 2x3, 3x2, 4x4) - Output format selection (original/PNG/JPG/WebP) with quality slider - Post-split tile preview thumbnails with individual download - Download All as ZIP button - HEIC/HEIF preview with loading spinner - Backend: tile-size mode, output format conversion, quality control - Zustand store for split state management * feat(split): rewrite backend and frontend settings Backend: tile-size mode, output format conversion, quality control. Frontend: split modes, presets, format selector, tile preview grid. * feat(border): add live CSS preview and remove before/after slider - Add imageWrapperStyle prop to ImageViewer for live border preview - Add onImageStyle callback through tool-page to settings components - Change border displayMode to no-comparison (no slider) - BorderControls sends live CSS styles (border, padding, radius, shadow) - Preview updates instantly as user adjusts sliders or clicks presets * fix: repair i18n file corrupted by formatter during merge conflict resolution * feat(border): enable live CSS preview in right pane as settings change * fix(border): keep CSS preview visible after processing for WYSIWYG consistency * chore(gif-tools): scaffold for SOTA upgrade - Add animated GIF test fixture (3 frames, 100x100) - Update tool description to reflect new capabilities - Add fflate dependency to API for ZIP creation * feat(gif-tools): rewrite backend with 6 processing modes Modes: resize (with percentage), optimize (colors/dither/effort), speed (delay manipulation), reverse (frame reorder), extract (single/range/all with ZIP), rotate (90/180/270 + flip). Adds /api/v1/tools/gif-tools/info metadata endpoint. * test(gif-tools): add integration tests for all 6 modes Tests metadata endpoint, resize (pixel + percentage), optimize, speed, reverse, extract (single/range/all), and rotate (angle + flip). Fix animated.gif fixture to be a real 3-frame animation (was a single 100x300 frame). Fix reverse and rotate modes to process frames individually and reassemble via GIF binary concatenation, since Sharp 0.33.x loses page-height metadata when reconstructing from raw pixel data. * feat(gif-tools): rewrite frontend with tabbed 6-mode UI - useGifInfo hook for metadata (frame count, dimensions, duration) - Info bar showing GIF properties - 3x2 mode grid: Resize, Optimize, Speed, Reverse, Extract, Rotate - Animation modes disabled for static images - Loop control (infinite/once/custom) - Batch processing support * test(gif-tools): add to representative tools in e2e suite --------- Co-authored-by: Siddharth Kumar Sah <siddharth123sk@gmail.com>
This commit is contained in:
co-authored by
Siddharth Kumar Sah
parent
4e99150a08
commit
a1e11dff74
@@ -1,114 +1,374 @@
|
||||
import { Download, Loader2 } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { Download, Loader2, PackageOpen } from "lucide-react";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { CollapsibleSection } from "@/components/common/collapsible-section";
|
||||
import { formatHeaders } from "@/lib/api";
|
||||
import { useFileStore } from "@/stores/file-store";
|
||||
import type { SplitMode } from "@/stores/split-store";
|
||||
import { useSplitStore } from "@/stores/split-store";
|
||||
|
||||
const MODES: Array<{ id: SplitMode; label: string }> = [
|
||||
{ id: "grid", label: "Grid" },
|
||||
{ id: "tile-size", label: "Tile Size" },
|
||||
];
|
||||
|
||||
const PRESETS = [
|
||||
{ label: "2x1", c: 2, r: 1, desc: "Horizontal half" },
|
||||
{ label: "1x2", c: 1, r: 2, desc: "Vertical half" },
|
||||
{ label: "2x2", c: 2, r: 2, desc: "Quarters" },
|
||||
{ label: "3x1", c: 3, r: 1, desc: "Horizontal strip" },
|
||||
{ label: "1x3", c: 1, r: 3, desc: "Vertical strip" },
|
||||
{ label: "3x3", c: 3, r: 3, desc: "9-tile grid" },
|
||||
{ label: "2x3", c: 2, r: 3, desc: "6-tile portrait" },
|
||||
{ label: "3x2", c: 3, r: 2, desc: "6-tile landscape" },
|
||||
{ label: "4x4", c: 4, r: 4, desc: "16-tile grid" },
|
||||
];
|
||||
|
||||
const OUTPUT_FORMATS = [
|
||||
{ value: "original", label: "Keep Original" },
|
||||
{ value: "png", label: "PNG" },
|
||||
{ value: "jpg", label: "JPG" },
|
||||
{ value: "webp", label: "WebP" },
|
||||
] as const;
|
||||
|
||||
const LOSSY_FORMATS = new Set(["jpg", "webp"]);
|
||||
|
||||
export function SplitSettings() {
|
||||
const { files, processing, error, setProcessing, setError } = useFileStore();
|
||||
const [columns, setColumns] = useState(2);
|
||||
const [rows, setRows] = useState(2);
|
||||
const [downloadReady, setDownloadReady] = useState(false);
|
||||
const { files, processing: fileStoreProcessing } = useFileStore();
|
||||
const {
|
||||
mode,
|
||||
columns,
|
||||
rows,
|
||||
tileWidth,
|
||||
tileHeight,
|
||||
outputFormat,
|
||||
quality,
|
||||
imageDimensions,
|
||||
processing,
|
||||
error,
|
||||
tiles,
|
||||
zipBlobUrl,
|
||||
setMode,
|
||||
setColumns,
|
||||
setRows,
|
||||
setTileWidth,
|
||||
setTileHeight,
|
||||
setOutputFormat,
|
||||
setQuality,
|
||||
setProcessing,
|
||||
setError,
|
||||
setTiles,
|
||||
setZipBlobUrl,
|
||||
applyPreset,
|
||||
getEffectiveGrid,
|
||||
getComputedTileDimensions,
|
||||
} = useSplitStore();
|
||||
|
||||
const handleProcess = async () => {
|
||||
const [downloadingIndex, setDownloadingIndex] = useState<number | null>(null);
|
||||
|
||||
const hasFile = files.length > 0;
|
||||
const grid = getEffectiveGrid();
|
||||
const tileCount = grid.columns * grid.rows;
|
||||
const tileDims = getComputedTileDimensions();
|
||||
const isLossy = LOSSY_FORMATS.has(outputFormat);
|
||||
const hasTiles = tiles.length > 0;
|
||||
|
||||
const tileWarning =
|
||||
tileDims && (tileDims.width < 50 || tileDims.height < 50)
|
||||
? `Tiles will be very small (${tileDims.width}x${tileDims.height}px)`
|
||||
: null;
|
||||
|
||||
useEffect(() => {
|
||||
setTiles([]);
|
||||
setZipBlobUrl(null);
|
||||
setError(null);
|
||||
}, [files, setTiles, setZipBlobUrl, setError]);
|
||||
|
||||
const handleProcess = useCallback(async () => {
|
||||
if (files.length === 0) return;
|
||||
|
||||
setProcessing(true);
|
||||
setError(null);
|
||||
setDownloadReady(false);
|
||||
setTiles([]);
|
||||
setZipBlobUrl(null);
|
||||
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append("file", files[0]);
|
||||
formData.append("settings", JSON.stringify({ columns, rows }));
|
||||
const effectiveGrid = getEffectiveGrid();
|
||||
const settings: Record<string, unknown> = {
|
||||
columns: effectiveGrid.columns,
|
||||
rows: effectiveGrid.rows,
|
||||
outputFormat,
|
||||
};
|
||||
if (mode === "tile-size") {
|
||||
settings.tileWidth = tileWidth;
|
||||
settings.tileHeight = tileHeight;
|
||||
}
|
||||
if (LOSSY_FORMATS.has(outputFormat)) {
|
||||
settings.quality = quality;
|
||||
}
|
||||
formData.append("settings", JSON.stringify(settings));
|
||||
|
||||
const res = await fetch("/api/v1/tools/split", {
|
||||
method: "POST",
|
||||
headers: formatHeaders(),
|
||||
body: formData,
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const text = await res.text();
|
||||
throw new Error(text || `Failed: ${res.status}`);
|
||||
}
|
||||
|
||||
// Download the ZIP
|
||||
const blob = await res.blob();
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = `split-${columns}x${rows}.zip`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
setDownloadReady(true);
|
||||
setZipBlobUrl(url);
|
||||
|
||||
const JSZip = (await import("jszip")).default;
|
||||
const zip = await JSZip.loadAsync(blob);
|
||||
const tileEntries: Array<{ row: number; col: number; blobUrl: string | null }> = [];
|
||||
|
||||
const fileNames = Object.keys(zip.files).filter((n) => !zip.files[n].dir);
|
||||
fileNames.sort();
|
||||
|
||||
for (const name of fileNames) {
|
||||
const fileData = await zip.files[name].async("blob");
|
||||
const tileBlobUrl = URL.createObjectURL(fileData);
|
||||
const match = name.match(/_r(\d+)_c(\d+)/);
|
||||
const row = match ? Number.parseInt(match[1], 10) : 0;
|
||||
const col = match ? Number.parseInt(match[2], 10) : 0;
|
||||
tileEntries.push({ row, col, blobUrl: tileBlobUrl });
|
||||
}
|
||||
|
||||
tileEntries.sort((a, b) => a.row - b.row || a.col - b.col);
|
||||
setTiles(
|
||||
tileEntries.map((t, i) => ({
|
||||
row: t.row,
|
||||
col: t.col,
|
||||
label: `${i + 1}`,
|
||||
width: 0,
|
||||
height: 0,
|
||||
blobUrl: t.blobUrl,
|
||||
})),
|
||||
);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : "Split failed");
|
||||
} finally {
|
||||
setProcessing(false);
|
||||
}
|
||||
};
|
||||
}, [
|
||||
files,
|
||||
mode,
|
||||
outputFormat,
|
||||
quality,
|
||||
tileWidth,
|
||||
tileHeight,
|
||||
getEffectiveGrid,
|
||||
setProcessing,
|
||||
setError,
|
||||
setTiles,
|
||||
setZipBlobUrl,
|
||||
]);
|
||||
|
||||
const hasFile = files.length > 0;
|
||||
const presets = [
|
||||
{ label: "2x2", c: 2, r: 2 },
|
||||
{ label: "3x3", c: 3, r: 3 },
|
||||
{ label: "1x3", c: 1, r: 3 },
|
||||
{ label: "3x1", c: 3, r: 1 },
|
||||
{ label: "4x4", c: 4, r: 4 },
|
||||
];
|
||||
const handleDownloadZip = useCallback(() => {
|
||||
if (!zipBlobUrl) return;
|
||||
const a = document.createElement("a");
|
||||
a.href = zipBlobUrl;
|
||||
const baseName = files[0]?.name?.replace(/\.[^.]+$/, "") ?? "split";
|
||||
a.download = `${baseName}-${grid.columns}x${grid.rows}.zip`;
|
||||
a.click();
|
||||
}, [zipBlobUrl, files, grid]);
|
||||
|
||||
const handleDownloadTile = useCallback(
|
||||
(index: number) => {
|
||||
const tile = tiles[index];
|
||||
if (!tile?.blobUrl) return;
|
||||
setDownloadingIndex(index);
|
||||
const a = document.createElement("a");
|
||||
a.href = tile.blobUrl;
|
||||
const baseName = files[0]?.name?.replace(/\.[^.]+$/, "") ?? "tile";
|
||||
const ext =
|
||||
outputFormat === "original" ? (files[0]?.name?.split(".").pop() ?? "png") : outputFormat;
|
||||
a.download = `${baseName}_r${tile.row}_c${tile.col}.${ext}`;
|
||||
a.click();
|
||||
setTimeout(() => setDownloadingIndex(null), 500);
|
||||
},
|
||||
[tiles, files, outputFormat],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<p className="text-xs text-muted-foreground">Grid Presets</p>
|
||||
<div className="flex gap-1 mt-1 flex-wrap">
|
||||
{presets.map((p) => (
|
||||
<p className="text-xs text-muted-foreground mb-1.5">Split Mode</p>
|
||||
<div className="flex gap-1">
|
||||
{MODES.map((m) => (
|
||||
<button
|
||||
key={p.label}
|
||||
key={m.id}
|
||||
type="button"
|
||||
onClick={() => {
|
||||
setColumns(p.c);
|
||||
setRows(p.r);
|
||||
}}
|
||||
className={`text-xs px-2 py-1 rounded ${columns === p.c && rows === p.r ? "bg-primary text-primary-foreground" : "bg-muted text-muted-foreground"}`}
|
||||
onClick={() => setMode(m.id)}
|
||||
className={`flex-1 text-xs px-3 py-1.5 rounded-lg transition-colors ${
|
||||
mode === m.id
|
||||
? "bg-primary text-primary-foreground"
|
||||
: "bg-muted text-muted-foreground hover:text-foreground"
|
||||
}`}
|
||||
>
|
||||
{p.label}
|
||||
{m.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2">
|
||||
<div className="flex-1">
|
||||
<label htmlFor="split-columns" className="text-xs text-muted-foreground">
|
||||
Columns
|
||||
</label>
|
||||
<input
|
||||
id="split-columns"
|
||||
type="number"
|
||||
value={columns}
|
||||
onChange={(e) => setColumns(Math.max(1, Number(e.target.value)))}
|
||||
min={1}
|
||||
max={10}
|
||||
className="w-full mt-0.5 px-2 py-1.5 rounded border border-border bg-background text-sm text-foreground"
|
||||
/>
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<label htmlFor="split-rows" className="text-xs text-muted-foreground">
|
||||
Rows
|
||||
</label>
|
||||
<input
|
||||
id="split-rows"
|
||||
type="number"
|
||||
value={rows}
|
||||
onChange={(e) => setRows(Math.max(1, Number(e.target.value)))}
|
||||
min={1}
|
||||
max={10}
|
||||
className="w-full mt-0.5 px-2 py-1.5 rounded border border-border bg-background text-sm text-foreground"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{mode === "grid" && (
|
||||
<>
|
||||
<div>
|
||||
<p className="text-xs text-muted-foreground mb-1.5">Presets</p>
|
||||
<div className="grid grid-cols-3 gap-1">
|
||||
{PRESETS.map((p) => (
|
||||
<button
|
||||
key={p.label}
|
||||
type="button"
|
||||
onClick={() => applyPreset(p.c, p.r)}
|
||||
title={p.desc}
|
||||
className={`text-xs px-2 py-1.5 rounded-lg transition-colors ${
|
||||
columns === p.c && rows === p.r
|
||||
? "bg-primary text-primary-foreground"
|
||||
: "bg-muted text-muted-foreground hover:text-foreground"
|
||||
}`}
|
||||
>
|
||||
{p.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<div className="flex-1">
|
||||
<label htmlFor="split-columns" className="text-xs text-muted-foreground">
|
||||
Columns
|
||||
</label>
|
||||
<input
|
||||
id="split-columns"
|
||||
type="number"
|
||||
value={columns}
|
||||
onChange={(e) => setColumns(Number(e.target.value))}
|
||||
min={1}
|
||||
max={20}
|
||||
className="w-full mt-0.5 px-2 py-1.5 rounded border border-border bg-background text-sm text-foreground tabular-nums"
|
||||
/>
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<label htmlFor="split-rows" className="text-xs text-muted-foreground">
|
||||
Rows
|
||||
</label>
|
||||
<input
|
||||
id="split-rows"
|
||||
type="number"
|
||||
value={rows}
|
||||
onChange={(e) => setRows(Number(e.target.value))}
|
||||
min={1}
|
||||
max={20}
|
||||
className="w-full mt-0.5 px-2 py-1.5 rounded border border-border bg-background text-sm text-foreground tabular-nums"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
<p className="text-xs text-muted-foreground">Will produce {columns * rows} parts</p>
|
||||
{mode === "tile-size" && (
|
||||
<div className="space-y-3">
|
||||
<div className="flex gap-2">
|
||||
<div className="flex-1">
|
||||
<label htmlFor="split-tile-w" className="text-xs text-muted-foreground">
|
||||
Tile Width (px)
|
||||
</label>
|
||||
<input
|
||||
id="split-tile-w"
|
||||
type="number"
|
||||
value={tileWidth}
|
||||
onChange={(e) => setTileWidth(Number(e.target.value))}
|
||||
min={10}
|
||||
max={imageDimensions?.width ?? 10000}
|
||||
className="w-full mt-0.5 px-2 py-1.5 rounded border border-border bg-background text-sm text-foreground tabular-nums"
|
||||
/>
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<label htmlFor="split-tile-h" className="text-xs text-muted-foreground">
|
||||
Tile Height (px)
|
||||
</label>
|
||||
<input
|
||||
id="split-tile-h"
|
||||
type="number"
|
||||
value={tileHeight}
|
||||
onChange={(e) => setTileHeight(Number(e.target.value))}
|
||||
min={10}
|
||||
max={imageDimensions?.height ?? 10000}
|
||||
className="w-full mt-0.5 px-2 py-1.5 rounded border border-border bg-background text-sm text-foreground tabular-nums"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{imageDimensions && (
|
||||
<p className="text-[11px] text-muted-foreground">
|
||||
Image: {imageDimensions.width}x{imageDimensions.height}px. Grid: {grid.columns}x
|
||||
{grid.rows} = {tileCount} tiles
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{mode === "grid" && (
|
||||
<div className="flex items-center justify-between text-xs text-muted-foreground">
|
||||
<span>
|
||||
{grid.columns}x{grid.rows} = {tileCount} tiles
|
||||
</span>
|
||||
{tileDims && (
|
||||
<span className="tabular-nums">
|
||||
~{tileDims.width}x{tileDims.height}px each
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{tileWarning && <p className="text-[11px] text-amber-500">{tileWarning}</p>}
|
||||
|
||||
<CollapsibleSection
|
||||
title="Output Format"
|
||||
badge={outputFormat === "original" ? "Auto" : outputFormat.toUpperCase()}
|
||||
>
|
||||
<div className="space-y-3 pt-1">
|
||||
<div className="grid grid-cols-2 gap-1">
|
||||
{OUTPUT_FORMATS.map((f) => (
|
||||
<button
|
||||
key={f.value}
|
||||
type="button"
|
||||
onClick={() => setOutputFormat(f.value as typeof outputFormat)}
|
||||
className={`text-xs px-2 py-1.5 rounded-lg transition-colors ${
|
||||
outputFormat === f.value
|
||||
? "bg-primary text-primary-foreground"
|
||||
: "bg-muted text-muted-foreground hover:text-foreground"
|
||||
}`}
|
||||
>
|
||||
{f.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
{isLossy && (
|
||||
<div>
|
||||
<div className="flex justify-between items-center">
|
||||
<label htmlFor="split-quality" className="text-xs text-muted-foreground">
|
||||
Quality
|
||||
</label>
|
||||
<span className="text-xs font-mono text-foreground">{quality}</span>
|
||||
</div>
|
||||
<input
|
||||
id="split-quality"
|
||||
type="range"
|
||||
min={1}
|
||||
max={100}
|
||||
value={quality}
|
||||
onChange={(e) => setQuality(Number(e.target.value))}
|
||||
className="w-full mt-1"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CollapsibleSection>
|
||||
|
||||
{error && <p className="text-xs text-red-500">{error}</p>}
|
||||
|
||||
@@ -116,17 +376,57 @@ export function SplitSettings() {
|
||||
type="button"
|
||||
data-testid="split-submit"
|
||||
onClick={handleProcess}
|
||||
disabled={!hasFile || processing}
|
||||
disabled={!hasFile || processing || fileStoreProcessing}
|
||||
className="w-full py-2.5 rounded-lg bg-primary text-primary-foreground font-medium disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2"
|
||||
>
|
||||
{processing && <Loader2 className="h-4 w-4 animate-spin" />}
|
||||
{processing ? "Splitting..." : "Split Image"}
|
||||
{processing ? "Splitting..." : `Split into ${tileCount} Tiles`}
|
||||
</button>
|
||||
|
||||
{downloadReady && (
|
||||
<p className="text-xs text-green-600 flex items-center gap-1">
|
||||
<Download className="h-3 w-3" /> ZIP downloaded successfully
|
||||
</p>
|
||||
{hasTiles && (
|
||||
<div className="space-y-3 border-t border-border pt-3">
|
||||
<p className="text-xs font-medium text-foreground">{tiles.length} Tiles Generated</p>
|
||||
<div
|
||||
className="grid gap-1"
|
||||
style={{ gridTemplateColumns: `repeat(${grid.columns}, 1fr)` }}
|
||||
>
|
||||
{tiles.map((tile, i) => (
|
||||
<button
|
||||
key={tile.label}
|
||||
type="button"
|
||||
onClick={() => handleDownloadTile(i)}
|
||||
className="group relative aspect-square rounded border border-border overflow-hidden hover:border-primary transition-colors bg-muted"
|
||||
title={`Download tile ${tile.label}`}
|
||||
>
|
||||
{tile.blobUrl && (
|
||||
<img
|
||||
src={tile.blobUrl}
|
||||
alt={`Tile ${tile.label}`}
|
||||
className="w-full h-full object-cover"
|
||||
/>
|
||||
)}
|
||||
<div className="absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors flex items-center justify-center">
|
||||
<Download
|
||||
className={`h-3.5 w-3.5 text-white opacity-0 group-hover:opacity-100 transition-opacity ${
|
||||
downloadingIndex === i ? "animate-bounce" : ""
|
||||
}`}
|
||||
/>
|
||||
</div>
|
||||
<span className="absolute top-0.5 left-0.5 bg-black/60 text-white text-[9px] font-bold px-1 rounded tabular-nums">
|
||||
{tile.label}
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleDownloadZip}
|
||||
className="w-full py-2.5 rounded-lg border border-primary text-primary font-medium flex items-center justify-center gap-2 hover:bg-primary/5 transition-colors"
|
||||
>
|
||||
<PackageOpen className="h-4 w-4" />
|
||||
Download All as ZIP
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user